rdiff-backup – A Remote Incremental Backup Tool for Linux

rdiff-backup is a powerful and easy-to-use Python script for local/remote incremental backup, which works on any POSIX operating system such as Linux, Mac OS X or Cygwin. It brings together the remarkable features of a mirror and an incremental backup.

Significantly, it preserves subdirectories, dev files, hard links, and critical file attributes such as permissions, uid/gid ownership, modification times, extended attributes, acls, and resource forks. It can work in a bandwidth-efficient mode over a pipe, in a similar way as the popular rsync backup tool.

rdiff-backup backs up a single directory to another over a network using SSH, implying that the data transfer is encrypted thus secure. The target directory (on the remote system) ends up an exact copy of the source directory, however extra reverse diffs are stored in a special subdirectory in the target directory, making it possible to recover files lost some time ago.

Dependencies

To use rdiff-backup in Linux, you’ll need the following packages installed on your system:

Python v2.2 or later

librsync v0.9.7 or later

pylibacl and pyxattr Python modules are optional but necessary for POSIX access control list(ACL) and extended attribute support respectively.

rdiff-backup-statistics requires Python v2.4 or later.

How to Install rdiff-backup in Linux

Important: If you are operating over a network, you’ll have to install rdiff-backup both systems, preferably both installations of rdiff-backup will have to be the exact same version.

The script is already present in the official repositories of the mainstream Linux distributions, simply run the command below to install rdiff-backup as well as its dependencies:

On Fedora

How to Use rdiff-backup in Linux

As I mentioned before, rdiff-backup uses SSH to connect to remote machines on your network, and the default authentication in SSH is the username/password method, which normally requires human interaction.

There are two other important flags we can set for file selection; --max-file-size size which excludes files that are larger than the given size in bytes and --min-file-size size which excludes files that are smaller than the given size in bytes:

The screenshot below shows the root file on remote server 192.168.56.102 and the backed up files on the back server 192.168.56.10:

Backup Remote Directory on Local Server

Take note of the rdiff-backup-data directory created in the backup directory as seen in the screenshot, it contains vital data concerning the backup process and incremental files.

rdiff-backup – Backup Process Files

Now, on the server 192.168.56.102, additional files have been added to the root directory as shown below:

Verify Backup Directory

Let’s run the backup command once more time to get the changed data, we can use the -v[0-9] (where the number specifies the verbosity level, default is 3 which is silent) option to set the verbosity feature:

And to list the number and date of partial incremental backups contained in the /backups/192.168.56.102_rootfiles.backup directory, we can run:

# rdiff-backup -l /backups/192.168.56.102_rootfiles.backup/

Automating rdiff-back Backup Using Cron

We can print summary statistics after a successful backup with the --print-statistics. However, if we don’t set this option, the info will still be available from the session statistics file. Read more concerning this option in the STATISTICS section of the man page.

And the –remote-schema flag enables us to specify an alternative method of connecting to a remote computer.

Now, let’s start by creating a backup.sh script on the backup server 192.168.56.10 as follows:

That’s it for now! In this tutorial, we showed you how to install and basically use rdiff-backup, an easy-to-use Python script for local/remote incremental backup in Linux. Do share your thoughts with us via the feedback section below.

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.