rdiff-backup: making effective and incremental backups

March 2017


rdiff-backup is a backup software. It allows you to create an image copy from one directory to another in the same way like rsync or as a simple cp command.
In addition, it retains the old versions of files, so you can restore a file as it was earlier and allows recovery of deleted files.
rdiff-backup allows you to make a backup to / from a local directory or to/from a server ssh.
rdiff-backup transmit only the modified parts of files. It is therefore optimize the use of disk space and bandwidth.
The syntax is simple and allows you to filter the files to be saved.
rdiff-backup can also make backups to systems that do not support Unix/Linux rights management.

Installing rdiff-backup

Under Debian based system:
sudo aptitude install rdiff-backup

Making a Backup

rdiff-backup /source /backups

The backup of the latest version of your files is available in / backups.
The directory / backups / rdiff-backup-data contains the different older versions of files.

Listing available backups

rdiff-backup -l /backups

list-increment-sizes to see the place occupied by each backup.

Deleting old backups

For example, eliminate all backups older than 8 days:
rdiff-backup --remove-older-than 8D --force /backups

Restoring files

For example, to retrieve your /source/myfile.txt file as it was 3 days ago

rdiff-backup -r 3D /backups/myfile.txt /source/ancien.txt

-R stands for "restore" and 3D = 3 Days. You can also specify in hours, minutes, or even a specific date

Miscellaneous options

There are many other options allowin you to filter files (name, path, size ...), directories to restore full, with specific dates, make backups through ssh,
just make a man rdiff-backup to list the options.

Setting up default backup options

Here's is a simple example on how to set up a daily backup of personnal directories (/home) to /var/rdiff.backups/home, keeping 30 days of historical files. We exclude files larger than 50 MB

Set up as root and create /etc/cron/rdiff_backup_home file containing:

test -x /usr/bin/rdiff-backup || exit 0
logger "rdiff_backup_home: delete old backups (>30 jours)"
/usr/bin/rdiff-backup --remove-older-than 30D --force /var/rdiff.backups/home
logger "rdiff_backup_home:  backup directory /home (files <50Mo only)."
/usr/bin/rdiff-backup --max-file-size 50000000 /home /var/rdiff.backups/home
logger "rdiff_backup_home: end back up."

Make the following file executable: chmod 755 rdiff_backup_home

Once procedure completed, the directories / home will be saved daily.
rdiff-backup will retrieve old versions of files up to 30 days back while minimizing the disk space used.

To force a backup, type: sudo /etc/cron.daily/rdiff_backup_home
To list the backups done, type: sudo rdiff-backup -l /var/rdiff.backups/home
To restore a file: sudo rdiff-backup -r 3D /var/rdiff.backups/home/toto/myfile.txt /home/toto/ancien.txt

You can check out back up status by looking in the /var/log/syslog. Type in: rdiff /var/log/syslog


Published by jak58.
This document, titled "rdiff-backup: making effective and incremental backups," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).