Sunday, April 8, 2012

Automated backup on Debian Linux

To back up files automatically, I created a cron job:

gedit /etc/crontab

*/5 * * * *  user  /pathToCronJob/backUp.sh

The backUp.sh file contained:

#!/bin/bash
########## This file does some synchronization very five minutes

rsync -alhprtXH --port=80 --rsh='ssh -p80' --delete --numeric-ids  /sourceFolder/ /destinationFolder




80 was the port number I used for the port allowed in the firewall. --delete meant deleting the files in the destinationFolder if they are not found in the sourceFolder.

If not automated
The rsync script did not display anything. To display the progress, I used the command below without the task being automated:

rsync -avlhprtXH --port=80 --rsh='ssh -p80' --delete --progress --numeric-ids  /sourceFolder/ /destinationFolder

I could see the progress made. 

To be safe
I created the backups on a separate physical disk. If one disk failed, the other disk could help. The chance that two disks failed at the same time was small.

No comments:

RSS