Tool that watches files / folders and upload on change on OS X? I am looking for an SFTP or rsync (?) tool (or script?) that watches a certain folder or certain files and uploads them to a remote server securely on change.

The background:

I've been using Sublime SFTP for that, it works quite well, but sometimes "forgets" its watching duties. Also, I'm giving Atom a go as an alternative editor and there are no tools that live up 100% to Sublime SFTP.

Most editor-based SFTP tools just upload files upon save, but that doesn't cover files built buy gulp or CodeKit.

We've been adding gulp-sftp to our build scripts, but that also has drawbacks.

So what I've been wondering: isn't there a standalone application that simply can watch files or folders for changes and upload them via SFTP, rsync or scp?
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=&lt;1-9&gt;)
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.