Using rdiff-backup under Linux

From Thomas-Krenn-Wiki
Jump to navigation Jump to search

rdiff-backup makes space-saving backups under Linux easy. The data content of the last backup can be accessed through the file system. In older versions of a backup file, rdiff-backup stores only the changes. These older versions can be restored using the rdiff-backup tool.

Video

Creating a Backup

The following, simple command will create the backup.

rdiff-backup SourceDirectory TargetDirectory


Here is a simple example:

[root@tpw mnt]# rdiff-backup /mnt/daten-verzeichnis/ /mnt/backup-verzeichnis/
[root@tpw mnt]#

You can also execute rdiff-backup on a backup server and download the backup data from a client using Secure SHell (SSH).

rdiff-backup root@IPAddress::SourceDirectory TargetDirectory

Displaying Versions of a Backup

The existing versions of the backup can be displayed using the following command.

rdiff-backup -l BackupDirectory


Here is another example:

[root@tpw mnt]# rdiff-backup -l /mnt/backup-verzeichnis/
Found 4 increments:
    increments.2009-06-03T15:13:24+02:00.dir   Wed Jun  3 15:13:24 2009
    increments.2009-06-03T15:13:58+02:00.dir   Wed Jun  3 15:13:58 2009
    increments.2009-06-03T15:22:45+02:00.dir   Wed Jun  3 15:22:45 2009
    increments.2009-06-03T15:23:57+02:00.dir   Wed Jun  3 15:23:57 2009
Current mirror: Wed Jun  3 15:25:55 2009
[root@tpw mnt]#

Restoring from the Backup

As can be seen above, the actual data from June 3 2009 (15:25:55) is stored in the backup directory. This version can be accessed directly.

[root@tpw mnt]# ls -l /mnt/backup-verzeichnis/
total 117348
-rw-r--r-- 1 root root 30000000 2009-06-03 15:12 datei1
-rw-r--r-- 1 root root 30000000 2009-06-03 15:13 datei2
-rw-r--r-- 1 root root 30000000 2009-06-03 15:22 datei3
-rw-r--r-- 1 root root 30000000 2009-06-03 15:25 datei4
drwx------ 3 root root     4096 2009-06-03 15:25 rdiff-backup-data
[root@tpw mnt]#

To restore the datei1 file, copying this file to the desired target directory will suffice.

[root@tpw mnt]# cp /mnt/backup-verzeichnis/datei1 /mnt/restore-verzeichnis/datei1
[root@tpw mnt]# ls -l /mnt/restore-verzeichnis/
total 29336
-rw-r--r-- 1 root root 30000000 2009-06-03 15:27 datei1
[root@tpw mnt]#

Restoring an Older Version

To get an older version of a file, the rdiff-backup tool is used with the following command.

rdiff-backup BackupDirectory/rdiff-backup-data/increments/IncrementalFile TargetRestoreDirectory/FileToRestore

In the example, the datei4 file has been changed between the last two backup operations. To restore the datei4 file with time index 15:23:57, the Increments file must be accessed.

[root@tpw mnt]# rdiff-backup /mnt/backup-verzeichnis/rdiff-backup-data/increments/datei4.2009-06-03T15:23:57+02:00.diff.gz /mnt/restore-verzeichnis/datei4
[root@tpw mnt]#

The restore-as-of flag may be used as an alternative. You will find more information regarding this on the rdiff-backup man page.

Additional Information

Related articles

Linux Kernel Versions
PCIe Bus Error Status 00001100
Restoring a Clonzilla Image