---
title: "rdiff-backup"
id: "5401"
type: "epkb_post_type_1"
slug: "rdiff-backup"
published_at: "2010-03-23T23:26:33+00:00"
modified_at: "2022-03-25T17:51:31+00:00"
url: "https://docs.rc.fas.harvard.edu/kb/rdiff-backup/"
markdown_url: "https://docs.rc.fas.harvard.edu/kb/rdiff-backup.md"
excerpt: "rdiff-backup can be used for local and/or remote incremental backups. Incremental means that successive backups use previous backups and the rsync delta-transfer algorithm in order to save space. The syntax is like that of rsync, except two colons are used..."
taxonomy_epkb_post_type_1_category:
  - "Storage"
---

# rdiff-backup

[rdiff-backup](http://rdiff-backup.nongnu.org/)
 can be used for local and/or remote incremental backups.

*Incremental* means that successive backups use previous backups and the rsync delta-transfer algorithm in order to save space.  
 The syntax is like that of [rsync](/kb/linux/rsync/)
, except two colons are used to separate the username/hostname and the path (instead of one) and trailing slashes on paths are not significant.  
 The latest versions of files in the backups are stored as normal files, and reverse increments are stored in a directory named `rdiff-backup-data`.  
 The `rdiff-backup` command can be used to pull data from the incrementals and restore files to previous states.  
 You can setup your environment on the FASRC cluster to use the `rdiff-backup` software by issuing the command:  
 `module load hpc/rdiff-backup-1.2.8`  
 It’s most commonly used on linux systems, but is also available for Mac OS X and Windows (under Cygwin).

### **Creating Backups**

The following two command will make a backup of `/some/path` as `/some/path-backup`:  
 `rdiff-backup /some/path /some/path-backup`  
 The `rdiff-backup` software automatically preserves file attributes and all the other things (and more) that `rsync`‘s `-a` does.  
 You can prefix the destination with a network path in order to backup to a remote machine instead of the localhost:  
 `rdiff-backup /some/path USERNAME@HOSTNAME::/some/path-backup`  
 Likewise, you can pull from a remote host by adding such syntax to the source.  
 The `rdiff-backup` software must be installed on both the source and destination machines.

### **Purging Old Data From Backups**

Running the command: `rdiff-backup -v2 --force --remove-older-than 14D /some/path-backup` will remove any incremental data that’s over 14 days old. Note that this is independent of the actual file modification times. Combining this command with one of the previous backup commands in a script and running it as a daily cron job is a simple way to setup automated backups.

### **Listing and Restoring Files from Backups**

The command: `rdiff-backup -l /some/path-backup` where `/some/path-backup` is either the local or remote `DESTINATION` as specified above, or a path to a subdirectory within it, will list all the past versions of the specified directory/file that are available. Increments are only created if data changed — do not be alarmed if you backup on a regular basis but find `rdiff-backup -l` does not list an increment for every time the command ran.  
 To restore the file `some/file` from the latest backup, use:  
 `rdiff-backup --restore-as-of now /some/path-backup/some/file /place/to/put/it`  
 To restore the backup that was current as of, say, 1 week, 2 days, 3 hours, 4 minutes, and 5 seconds ago:  
 `rdiff-backup --restore-as-of 1W2D3h4m5s /some/path-backup/some/file /place/to/put/it`  
 You can also copy-n-paste one of the increment times listed by the `rdiff-backup -l` command.  
 The options `--compare`, `--compare-at-time`, `--list-changed-since`, and `--list-at-time` are often quite useful for finding the version of a file that you need.  
 To restore all available backups, use something like the following:  
 `restoresource=/some/path-backup/some/file restoretarget=/place/to/put/them rdiff-backup -l "$restoresource" | tail -n +2 | head -n -1 | while read dname date; do rdiff-backup --restore-as-of "$date" "$restoresource" "$restoretarget"/"${dname%%.dir}"; done`

Bookmarkable Links

- [1. Creating Backups](#Creating_Backups)
- [2. Purging Old Data From Backups](#Purging_Old_Data_From_Backups)
- [3. Listing and Restoring Files from Backups](#Listing_and_Restoring_Files_from_Backups)

Last UpdatedMarch 25, 2022
