Restoring Backups Made With rdiff-backup

If you’ve set up a backup regime using rdiff-backup as described here, you may have accidentally deleted a file, or lost a hard drive, and now need to restore the data. This howto tells you how.

If you’ve backed up a directory to another place on the same file, you can restore the backed up directory like this:

cp -a backed_up/dir original/dir

It’s that simple. Just copy the backed up directory back to where it should be, and the files will be restored. However, if you’ve done a remote backup as described here, then the cp command won’t work. You will need to use the rdiff-backup command to restore the files. You can get rdiff-backup to restore the current version of that file using either of these:

rdiff-backup --restore-as-of now host.net::/remote-dir/file local-dir/file

The –restore-as-of (or -r for short) switch tells rdiff-backup to restore instead of back up, and the now option indicates the current time. However, one of the cool things about rdiff-backup, is that you can restore older versions of a file/directory. This command restores host.net::/remote-dir/file as it was 10 days ago into a new location /tmp/file:

rdiff-backup -r 10D host.net::/remote-dir/file /tmp/file

Other acceptable time strings include 5m4s (5 minutes and 4 seconds) and 2002-03-05 (5 March 2002).