I have a web server (odin) and a backup server (jofur). On jofur, I can run the following code to rsync my web directories (via key authentication) from odin to jofur:
rsync -avz -e ssh [email protected]:/home/backups /home/myuser/odin
If I enter this into the command line, everything rsyncs perfectly:
myuser@jofur:~$ rsync -avz -e ssh [email protected]:/home/backups /home/myuser/odin
receiving incremental file list
sent 23 bytes received 1921 bytes 1296.00 bytes/sec
total size is 349557271 speedup is 179813.41
I want this to run every morning, so I edited my crontab to read this:
0 4 * * * rsync -avz -e ssh [email protected]:/home/backups /home/myuser/odin
This doesn't work. The following message is deposited in /var/mail/myuser:
Could not create directory '/home/myuser/.ssh'. Host key verification failed. rsync: connection unexpectedly closed (0 bytes received so far) [Receiver] rsync error: unexplained error (code 255) at io.c(605) [Receiver=3.0.9]
I'm not sure what this error means. I'm wary of futzing blindly with permissions because I don't want to leave any backdoors open. Any suggestions?
/usr/bin/rsync
But when I add this to the end of my cron command:> /tmp/cron_output.log 2>&1
crontab fails to run at all, even when set to run every minute. I know this because when I set it to run every minute (* * * * * *) it will throw errors to mail, but if I put your code in, it doesn't throw any errors, nor does it update the output log. – Hakan