Using rdiff-backup: Backup Remote Clients With Ease


Backups are awesome! Unless, you don't have any. Also, it's hard to find space for them and setting them up isn't always fun. Without backups the day will come when we lose data and need to get it back and can't. Whether it's an accidental delete of the project you've been working hard on; a disk issue resulting in partial or complete data loss; or something completely different, data loss is only a matter of when not if.

The Problem

Backing up clients behind NAT and other network obfuscation techniques adds another set of challenges to the equation. These can be solved by initiating them client side and having management set up around the idea of a data dump.

The Solution

rdiff-backup allows us to initiate backups from the client, use SSH as the communication protocol, keep incremental backups, &c.

Automating backups with rdiff-backup isn't overly challenging but isn't outlined (with required nuances). The magic lies in a little known option, --remote-schema.

For example, the following BASH snippet is the cron entry (could be moved to a proper script) that backs up my laptop to a remote site (split across lines for readability):

/usr/bin/rdiff-backup \
--remote-schema 'ssh -i /home/alunduil/.ssh/backup_dsa %s rdiff-backup --server' \
--exclude-other-filesystems \
--print-statistics \
/home/alunduil \ && \
/usr/bin/rdiff-backup \
--remote-schema 'ssh -i /home/alunduil/.ssh/backup_dsa %s rdiff-backup --server' \
--remove-older-than 7D \
--force \

Breaking this down, we have a few things that require explanation:

  The rdiff-backup script
  The magic! This specifies the way that SSH is called by rdiff-backup allowing particular control over the SSH tunnel used to communicate with the server
  Don't cross filesystem boundaries when finding files to backup
  Print a nice report of the files uploaded, &c when finished
/home/alunduil: The local directory to backup
  The remote host and directory to backup into
  Remove any backups older than the time passed
--force: Force the action even if warnings might occur


Creating backup strategies for remote clients with rdiff-backup is quite easy. This solution is ideal for mobile and spottily connected clients like laptop machines that might not be able to phone home for a variety of reasons.


Comments powered by Disqus