|
|||
|
Creating Incremental Backups with rdiff-backup Let's start with a basic script that performs backups of specified directories onto a local backup directory: #!/bin/bash DIRS="etc home var usr/local" DEST="/mnt/backup" cd / for dir in $DIRS ; do rdiff-backup $dir "$DEST/$(basename $dir)" done You can run this script as often as you like. I would suggest running it once per day. If the data is very important (like a corporate CVS repository), running it once per hour wouldn't be unreasonable. Altering this script to back up to a remote system is as simple as changing the $DEST variable. Here is an example: DEST="backup.mydomain.com::/mnt/backup" This causes rdiff-backup to connect to the host backup.mydomain.com via SSH and place the backup in its directory /mnt/backup. Regardless of what system contains the backup data, it will be almost an exact mirror of the source directory. Permissions, special files, hard/soft links, and ownership will all be preserved, if possible. The backup directory is exactly like the original, except for the additional rdiff-backup-data/ directory. This directory contains the backup logs and, most importantly, the diff files that can be used to generate older versions of files. It is very important that you do not manually change the files in the backup directory in any way. Doing so can permanently damage the backup data, probably preventing the correct recovery of any versions of the modified files. If you are backing up the data to a remote host, you will usually want to use a directory on that system based on your system's hostname. Here is a simple example: #!/bin/bash DIRS="etc home var usr/local" DEST="/mnt/backup" shorthost='hostname | sed 's/\..*$//'' cd / for dir in $DIRS ; do rdiff-backup $dir "$DEST/$shorthost/$(basename $dir)" done |
![]() |
| Bookmarks |
| Tags |
| backup, backup with rdiff-backup, incremental backups, rdiff, unix |
| Thread Tools | |
| Display Modes | |
|
|