I would like a regular backup of files on my disk to a backup server. Since I have lots of files (millions) I want to use rsync so only the differences are sent.
from Ubuntu 18.04 terminal, this produces output to a file:
rsync -av /Disk2/ 192.168.1.80:/mnt/jjg-z2/39x-disk2/ &> /home/john/Desktop/nightly_disk2_logs.txt
But when I use crontab -e
, for the 16 minute mark of the hour (to test)
16 * * * * rsync -av /Disk2/ 192.168.1.80:/mnt/jjg-z2/39x-disk2/ &> /home/john/Desktop
I did not see the output in this file on my desktop.
In the comments, steeldriver suggested the fix to problem 1. The crontab -e
now looks like:
SHELL=/bin/bash
52 * * * * rsync -av /Disk2/ 192.168.1.80:/mnt/jjg-14TB-z2/3970x-disk2/ &> /home/john/Desktop/nightly_disk2_logs.txt
Problem 2: Now I have output in the file but rsync has permissions issues. Is crontab's environment with respect to SSH keys not the same as the terminal's environment? Here is the output in the file:
Permission denied, please try again.
Permission denied, please try again.
[email protected]: Permission denied (publickey,password).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(235) [sender=3.1.2]