Backups with rdiff-backup and mysqldump

I’ve been using rdiff-backup for my server backups along with mysqldump for the sql data for years now, as it gives me the ability to browse the increments on file system level and is extremely efficient and easy to use, both for local files and remote.

So what is rdiff-backup anyway?

rdiff-backup backs up one directory to another, possibly over a network. The target directory ends up a copy of the source directory, but extra reverse diffs are stored in a special subdirectory of that target directory, so you can still recover files lost some time ago. The idea is to combine the best features of a mirror and an incremental backup. rdiff-backup also preserves subdirectories, hard links, dev files, permissions, uid/gid ownership, modification times, extended attributes, acls, and resource forks. Also, rdiff-backup can operate in a bandwidth efficient manner over a pipe, like rsync. Thus you can use rdiff-backup and ssh to securely back a hard drive up to a remote location, and only the differences will be transmitted. Finally, rdiff-backup is easy to use and settings have sensical defaults.

– Taken from the official rdiff-backup page,

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

On Ubuntu/Debian:
apt install librsync-dev rdiff-backup

On Fedora:
dnf install librsync rdiff-backup

rpm -ivh epel-release-7-9.noarch.rpm
yum install librsync rdiff-backup

rdiff-backup usage examples

Backup of a local directory:
rdiff-backup foo bar

Backup a local directory to a remote location:
rdiff-backup /local-dir hostname::/remote-dir

Restoring a local directory:
cp -a bar/dir foo/dir

Restoring files backed up 10 days ago:
rdiff-backup -r 10D hostname::/remote-dir/file /tmp/file

You can also backup and restore from a remote location to another remote location.
Detailed examples can be found here:

Here is a script that I use to backup my web and sql servers to a NFS mount on my backup server:

Related Posts

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.