inside the mind of a linux admin

automated rsync backups


From time to time, I’ll hear a request from a customer to setup custom nightly automated backups using ftp, rsync, or scp. I’ve created this script for my own personal backup needs, but have since realized it’s value for implementing in customer environments as well.

The script relies on rsync, and can be setup to run backups nightly. I prefer rsync due to its’ reliability and optionality. The -u option allows rsync to compare the file lists and size consistencies between two hosts, and only upload the files that have changed or been modified since the last rsync backup. The bandwidth limiting feature allows all of this to go on behind the scenes, even during peak hours during the day with only using the amount of valuable bandwidth that you designate in the options.

This script automates much of everything for you, so here’s where you start:

1. First, download my bash based shell script engine for rsync. [download runbkp.sh]
2. Setup keys between your backup source & destination. [help with setting up keys]
3. Edit runbkp.sh with your variables, most importantly: “HOST, DEST, USER, BACKDIR”
4. Setup a crontab to execute the backup on your desired frequency. [help with crontabs]

You can pipe the cron output to a log file, or have it e-mail its’ results to you. Tah dah, automated backups, made simple.

Alternatively, if you wish to setup local backups (on the same server) and not transfer them remotely, you can use this modified (and simplified) script: [download runbkp-local.sh]

If you have any questions, feel free to contact me.

Leave a Reply

Your email address will not be published. Required fields are marked *

Tweeter button Facebook button Myspace button