Jump to content

Rsync cron job won't work no matter what


CrazyMaurice

Recommended Posts

Hey all,

 

I'm trying to automate a backup from one server to another via SSH - I've got this working (mostly) pretty nicely when I just paste my rsync command in terminal:

 

rsync -avz --delete -e "ssh -i /root/.ssh/TODD-rsync-key" [email protected]:/mnt/user/SoundDesign/ /mnt/user/SoundDesign/

 

However when I try to create a cron job for this it isn't running:

01 00 * * * rsync -avz --delete -e "ssh -i /root/.ssh/TODD-rsync-key" [email protected]:/mnt/user/SoundDesign/ /mnt/user/SoundDesign/

Its in a file called backupSoundDesign.cron in boot\config\plugins\cronjobs. The file was created from terminal.

I ran update_cron and also restarted etc but I'm still not seeing new files in the destination after I get back the next day. 

 

Any thoughts? I must be missing something simple I imagine.

 

Cheers
Harry

Link to comment

Have you checked whether the cron job is actually getting added to /etc/cron.d/root?   Also I think that when running under cron you need to specify the full path to rsync as you do not have the default environment set up to give you a search path.

 

i would have thought a better way to set this up would be via the User Scripts plugin?     That would handle setting it up in cron on your behalf.    It would also allow you to better test your script as you can try running it in foreground mode to check it is working as expected before scheduling it to run as a background job.

Link to comment

Thank you so much for pointing me to this! I believe this solves the problem. I wasn't fully aware stuff needed to be added to /etc/cron.d/root. I've created a custom user script to run using the custom cron schedule. To check this should I just have a look in the /etc/cron.d/root directory?

 

Cheers

Link to comment
19 minutes ago, CrazyMaurice said:

Thank you so much for pointing me to this! I believe this solves the problem. I wasn't fully aware stuff needed to be added to /etc/cron.d/root. I've created a custom user script to run using the custom cron schedule. To check this should I just have a look in the /etc/cron.d/root directory?

 

Cheers

The technique you mentioned should have resulted in entries in /etc/cron.d/root (the update_cron script is an Unraid specific one intended for use by plugins to avoid them ever editing /etc/cron.d/root directly).

 

if you are doing it via the User Scripts plugin then it sorts out the cron issues on your behalf.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...