Introduction
Here’s the deal. I was performing an rsync backup of my website using an Ubuntu server but decided I’d also start backing up from my PC, Linux of course. I thought it would be a straight copy the scripts job and set the crontab up. Shock horror. . . it wasn’t.
Fix
So I had to do a number of things to get this working. First I found there were these generic errors in the logs for the crontab
Permission denied, please try again. Permission denied, please try again. Permission denied (publickey,password). rsync: connection unexpectedly closed (0 bytes received so far) [Receiver] rsync error: unexplained error (code 255) at io.c(226) [Receiver=3.1.0] Permission denied, please try again. Permission denied, please try again. Permission denied (publickey,password). rsync: connection unexpectedly closed (0 bytes received so far) [Receiver] rsync error: unexplained error (code 255) at io.c(226) [Receiver=3.1.0]
Pointed to the fact that permission being denied so I setup another set of keys for backup purposes with no password in use using ‘ssh-keygen.’ Still no dice though.
Turned out I needed to actually add the full path for both the rsync and ssh commands and key locations into the crontab. This changed my original script code from:
rsync -avd --delete -e ssh dave@ip-life.net:/var/www/html/wp-content/<blah>/ /home/dave/Website\ Backups/ip-life.net/
to . . .
/usr/bin/rsync -avd --delete -e "/usr/bin/ssh -i /home/dave/.ssh/backup_id_rsa" dave@ip-life.net:/var/www/html/wp-content/<blah>/ /home/dave/Website\ Backups/ip-life.net/
Found the answer on the Ubuntu forums.
http://ubuntuforums.org/showthread.php?t=1428104