Rdiff-backup

From Linuxintro
Revision as of 11:45, 25 April 2009 by imported>ChrisM
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Introduction

rdiff-backup is a tool written in Python to create incremental backups which allow you to go back to any point of time (where you made a backup) and extract files from then.

Since rdiff-backup actually makes reverse-incremental backups, the latest state (created the last time you ran rdiff-backup) is accessable in plain text, which means:

  • If you want the latest version, you can just throw away the "rdiff-backup-data" folder containg meta information.
  • Going back in time takes longer, the more far back you want to go.
  • Deleting old "snapshots" is a very fast operation, because it involves only deleting the oldest diffs but not rebasing any diffs to other plain text content.

Installation

rdiff-backup is available as a package for all major distributions, including Ubuntu, Debian, Gentoo, Fedora and OpenSuSE. See install software.

Usage

Backing up

Making a backup is very easy:

rdiff-backup source target

Both source and target can specify remote hosts (if doing so, the rsync algorithm is used to save bandwidth). For example, if I might want to save /home to a remote machine:

rdiff-backup /home/ user@backup-host:/var/backups/remote-home/

If everythings works, [target] is made an rdiff-backup location, which means, that the folder "rdiff-backup-data" should have been created there. From now on, you can use the above command to make a backup of the source, as often as you like.

Inspecing

To see, what backups there were created at a given target, run

rdiff-backup -l target

Recovering

With

rdiff-backup --restory-as-of [time] [target] # Short: rdiff-backup -r [time]

you can extract a backup from [target] whereas [time] denotes the date of the backup you want to extract. These time strings are very flexible, you can give * "now" for the latest backup

  • a time string in different formats, like YYYY-MM-DD, or even including hours, minutes or seconds
  • a relative timestamp like "1W" which means "one week ago" (allowed: (s)econds, (m)inutes, (h)ours, (D)ays, (W)eeks, (M)onths, (Y)ears)
  • seconds since Epoch.

Deleting old backups

Eventually, your backup target might grow to large or even use up all available space. In this case, you will probably delete very old backups that you are sure, you will not ever need.

You can accomplish this by running

rdiff-backup --remove-older-than [time]  # Format for [time]: See above.

The "--force" switch can be used to delete multiple backups at once. Otherwise, the command will just remove the very oldest increment, so will need to run it multiple times until all backups to your given timestamp have been deleted.

Going further

There are a very lot of more options that can be used, to include or exclude files or directories having a certain pattern or attribute, getting statistics and changing verbosity or comparing different snapshots.

Have a look at the rdiff-backup man page.