Results 1 to 4 of 4
Hi all,
I am running Ubuntu server 10.04 and use rsync to do all my backups. I would like to backup multiple directories to my external hard drive, but I ...
- 07-20-2010 #1Just Joined!
- Join Date
- Jul 2009
- Location
- Nebraska
- Posts
- 24
Cron Job
Hi all,
I am running Ubuntu server 10.04 and use rsync to do all my backups. I would like to backup multiple directories to my external hard drive, but I am faced with a problem on how to set up crontab -e to allow each rsync statement to perform one after the other. Right now I have each one set to run on different nights, but I would like them all to run the same night to allow for a more efficient backup. I know I could just run them at different times in the same night, but I don't want to chance one not completing before the other starts. Can I just list them one after the other like so in crontab -e:
# m h dom mon dow command
00 4 * * 7 rsync -auv --delete /Godfather/Music /Backup
rsync -auv --delete /Godfather/Documents /Backup
rsync -auv --delete /Godfather/Setups /Backup
rsync -auv --delete /Godfather/Pictures /Backup
rsync -auv --delete /Godfather/Backups /Backup
rsync -auv --delete /Godfather/Videos /Backup
This is my current crontab -e
# m h dom mon dow command
00 4 * * 7 rsync -auv --delete /Godfather/Music /Backup
00 4 * * 6 rsync -auv --delete /Godfather/Documents /Backup
00 4 * * 5 rsync -auv --delete /Godfather/Setups /Backup
00 4 * * 4 rsync -auv --delete /Godfather/Pictures /Backup
00 4 * * 3 rsync -auv --delete /Godfather/Backups /Backup
00 4 * * 2 rsync -auv --delete /Godfather/Videos /Backup
Thanks in advance!
- 07-20-2010 #2Just Joined!
- Join Date
- Jul 2006
- Posts
- 51
An option could be creating a shell script to run all these tasks.
For example something like this (/home/user/scripts/backup.sh):
Then, program just one cronjob:Code:#!/bin/bash rsync -auv --delete /Godfather/Music /Backup rsync -auv --delete /Godfather/Documents /Backup rsync -auv --delete /Godfather/Setups /Backup ...
If you want, you could add more controls into the script, like "IF"...Code:# m h dom mon dow command 00 4 * * 7 /home/user/scripts/backup.sh
- 07-20-2010 #3Just Joined!
- Join Date
- Jul 2009
- Location
- Nebraska
- Posts
- 24
will that shell script wait for each rsync task to complete before the next one starts?
- 07-21-2010 #4Just Joined!
- Join Date
- Jul 2006
- Posts
- 51
I think that shell script is sequential, so every command starts when the last one finished.
Good luck!


Reply With Quote