I have a backup.sh file that launch an rsync command. This rsync is to backup my dedicated server on a RaspberryPi running raspbian.
(I use keychain so I don't need to type any password etc ...)
The problem is that when I launch the batch manually everything works, but when it's crontab (with the same user) I have the following error :
2013/10/07 19:36:02  rsync: connection unexpectedly closed (0 bytes received so far) [Receiver] 2013/10/07 19:36:02  rsync error: error in rsync protocol data stream (code 12) at io.c(605) [Receiver=3.0.9]
Here is my backup.sh file
#!/bin/bash echo "_ backup start "$(date +%H:%M:%S) echo " " /usr/bin/rsync -avh --rsync-path='/usr/bin/rsync' --delete --log-file='/home/user/rsync.'$(date +%d%m%Y-%H%M%S)'.log' --rsh='ssh -p 1234' email@example.com:/path/to/archives/ /media/backup/ echo " " echo "_ backup end "$(date +%H:%M:%S)
And now the crontab line (crontab -e)
# m h dom mon dow command 30 5 * * * /home/user/backup.sh | mail -s "Backup RPi "$(date +\%d/\%m/\%Y-\%X) firstname.lastname@example.org