This rsync based script is used to automate a backup procedure by offering some nice features.
- Normal mode: This is a useful mode when the machine(s) that keep(s) backups are common PC, which you turn off regularly.
- Always online mode: This mode is used when the machine(s) that keep(s) backups are always online. In this mode to set the backup intervals you have create an appropriate cron job.
- Compression: The older backups will be archived in tar.gz files.
- Rotated backups: You are able to rotate a certain number of backups so you wont run out disk.
- Synchronized backup lists: You are able to setup multiple machines to backup a single one.
- Log keeping: This way you will be able to know what happened and when.
- Download it and make it executable.
- Set all the configuration options that are mentioned below.
- Create a backup list file in the remote machine.
- If you want to fully automate the backups you should consider seting up an key authenticated ssh connection between the computers running this script and the one that you want to backup.
- Test the execution. In this step you might want to temprary add "--dry-run" to RSYNC_OPTIONS.
- If you want it fully automated you should add a cron job. In normal mode it is adviced to set a frequent cronjob to make sure that when you turn on your PC and the MIN_DAYS have passed a backup will be taken. In always online mode you just have to set the cron job to the interval you want to backup.
Edit the configuration section in the script.
- BACKUP_NAME: This is used as a prefix in the tarball files.
- BACKUP_DIR: The disk path where the backups will be located.
- BACKUP_LIST: The filename of the rsync list that will be used for
- BACKUP_LIST_REMOTE_DIR: Path of the backup list file on the remote
- USER: User for the ssh connection.
- RSYNC_OPTIONS: Options passed to the rsync.
Example: RSYNC_OPTIONS="-ahog --delete";
- TAR_FILES_NUM: The number of the old backups you would like to have.
This must be set to a value that suits your needs. If you want to have
a large history of backup images (and you don't have a disk space issue)
you can set this to a high value.
- MIN_DAYS: This sets the interval in days of the backup for the normal mode.
If this is set to zero the script will run in "Always online" mode.
Backup lists format
Read the include/exclude patterns in rsync's man page.
+ etc/ + etc/apache2** + var/ + var/www** - **
Some useful details
The script creates a directory named "cur" in which you will find the last taken backup uncompressed.
There are also some logfiles located under the BACKUP_DIR, the one that is in BACKUP_DIR will have messages for the backup that hasn't been completed yet. In the BACKUP_DIR/cur dirctory you will find a logfile for the last taken backup and finally there are logfiles in every tar file and this way you will know when the backup was taken.