I have a setup right now with a dev machine, a local NAS drive, and offsite cloud storage. I want annex content to flow that way: so I git annex sync nas
from my dev box, then I SSH into the NAS and git annex sync cloud
. It's this last part that I want to automate - I want to make sure that any content I sync to NAS, gets synced from NAS to cloud. I don't want my dev machine uploading directly to cloud unless I explicitly set that.
Apparently I can't run assistant in a bare repository, which is what's on NAS. And, I'm not even sure assistant is the right thing, I think maybe it does more than just sync content.
What's a good way to set this up so that when NAS receives annex sync
content, it immediately does its own annex sync
to cloud remote?
One thing I can think of is set up a update
/ post-receive
hook to touch a file on the NAS. Then have a cron job check for the file, and if it's there, start a cloud sync.
I guess you could just put something like this in your crontab:
*/5 * * * * cd /path/to/repo; flock -n .git/periodic-sync.lock git annex sync --content --all
As a optimization, you could only sync with
--content --all
if the git-annex branch changed since the last time it ran.