I want to use rsync to synchronise my home folder with a "backup" copy on another drive on an Ubuntu 11.10 machine. And I want it to happen every 15 minutes.
If I manually run:
rsync -ar --delete /home/user/ /backupdrive/
in the CLI, it works just fine - everything in in sync.
But I've added:
*/15 * * * * rsync -ar --delete /home/user/ /backupdrive/
to sudo crontab -e
and whilst it adds new files, it doesn't delete the old ones.
Any ideas?
Edit
The first three lines of the cron out.txt are:
sending incremental file list
./
IO error encountered -- skipping file deletion
This doesn't happen with the CLI version.
If you're using SSH authentication in your interactive shell implicitly for rsync, you'll need to set that up explicitly for use in cron. This can be tricky to lock down with SSH keys that need to work without passphrases, since ideally one would want to constrain where the rsync output can end up the far end.
You can use the ~/.ssh/authorized_keys file to configure the key to only run a given specific command when someone connects to the host. If rsync in daemon mode can be forced to put everything under a target directory specified in the /.ssh/authorized_keys file "command" entry, it'd even be fairly secure. The rsyncd.conf(5) page has some relevant options for this kind of thing.