I've got this
rsync command that works just fine when I run it from the command line (Ubuntu Server 12.04.1 LTS). I'd like it to run every hour, on the hour, and output the results (along with errors) to a log file. Here's the command I've put into crontab:
0 * * * * root rsync -av --delete -e "ssh -i /root/.ssh/id_rsa" user@host:/path/to/dir/ user@host:/path/to/another/dir/ /destination/dir --exclude='.DS_Store' &> /var/log/backup/`date '+%Y_%m_%d_%H:%M'`_hourlybackup.log
Despite working exactly as I expected from bash, nothing happens when it's in crontab. It doesn't even write any errors to the file. Running
ps aux | grep rsync shows nothing of interest. I can't seem to find the issue. Any ideas?
UPDATE: Thanks to the answers I received I was able to tweak the command so that it works properly, although none of them solved the issue on their own. Here's what I found works this morning:
0 * * * * /usr/bin/rsync -av --delete -e "ssh -i /root/.ssh/id_rsa" user@host:/path/to/dir/ user@host:/path/to/another/dir/ /destination/dir --exclude='.DS_Store' > /var/log/backup/_hourlybackup.log 2>&1
For some reason the
date '+%Y_%m_%d_%H:%M' (enclosed in backticks) is causing the issue. If I remove that from the command, it works just fine ... although it's important to me that I have comprehensive backup logs, so I'd still like to find a solution to this. I'll keep hacking away at it, but if anyone knows, be my guest.