Try cron
. It's a tool that runs commands at a specific time or interval. It may not be exactly what you're looking for (clone on build) but it works quite well.
To set up cron: from Terminal, type crontab -e
.
This should bring up a text editor (depending on which text editor you set as default) and a nice header explaining what each field does.
minute, hour: does as it says
dom: day of month
mon: month
dow: day of week
Now, we'll take a look at your command to do regular backups. A great tool for backups is rsync. You'll need to set up SSH keys for it to work without a password prompt.
Here's the command I use:
rsync -vzhaPE --delete-after /path/to/local/file ip.address.of.server:/path/to/backup/location
Options used: -vzhaPE
v: verbose
z: compress (good for slow connections. Adjust compression level with --compress-level=<1-9>)
h: human readable numbers
a: archive mode. This preserves timestamps and practically clones everything over as it were.
P: progress bar.
E: keep partial files. This means that if the connection was interrupted, rsync will pick up on the partial files and continue where it left off. Good for copying multiple large files over a slow network.
delete-after: deletes files from the server that have been deleting from the sending side
Options v, h and P are more for human debugging, so we won't introduce them into our cron job.
So, to put it together in cron:
(run every ten minutes, for example)
*/10 * * * * rsync -zaE --delete-after /path/to/local/file ip.address.of.server:/path/to/backup/location
This command will back whatever files in are the directory specified to the server's specified directory every ten minutes. No duplicates will be made as rsync will delete the files it copies over.
Additionally, if you'd like, you can also run a script that moves the copied backup over to another folder if you're interested in a Time Machine-like versioning functionality. You'll need enough storage space though, and some minor tweaks to the backup command (rsync push to rsync pull). If this is what you're looking for, let me know and I'll expand on it.
fswatch
withduck
trac.cyberduck.io/wiki/help/en/howto/…