# Rdiff-backup

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Rdiff-backup
> Markdown URL: https://mediated.wiki/source/Rdiff-backup.md
> Source: https://en.wikipedia.org/wiki/Rdiff-backup
> Source revision: 1285263862
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{Short description|Backup software}}
{{more footnotes|date=May 2020}}

{{lowercase}}

{{Infobox software
| name                   = rdiff-backup
| logo                   = 
| screenshot             = <!-- File: -->
| caption                = 
| collapsible            =
| author                 = Ben Escoto (2001–2005)<br>Dean Gaudet, Andrew Ferguson, Edward Ned Harvey (2005–2016)<br>Eric Lavarde, Otto Kekäläinen, Patrik Dufresne (Python 3 rewrite beginning in 2019)
| developer              = 
| released               = 2001
| latest release version = {{wikidata|property|preferred|references|edit|P348|P548=Q2804309}}
| latest release date    = {{Start date and age|{{wikidata|qualifier|preferred|single|P348|P548=Q2804309|P577}}|df=yes}}
| discontinued           =
| programming language   = [Python](/source/Python_(programming_language))
| operating system       =
| platform               = Unix-like systems, MacOS, Windows
| size                   =
| genre                  = backup software
| license                = [GPL-2.0-or-later](/source/GNU_General_Public_License)
| website                = {{URL|https://rdiff-backup.net/}}
}}
'''rdiff-backup''' is a [backup](/source/Data_backup) software written in [Python](/source/Python_(programming_language)) that creates [reverse incremental backups](/source/Incremental_backup). The most recent backup is thus directly accessible, while earlier backups will be reconstructed from [diff](/source/diff) files by rdiff-backup. 

As the name implies, rdiff-backup uses the [rdiff](/source/rdiff) method (more exactly, the reimplementation of [rsync](/source/rsync) within librsync) to compute the differences between file versions. rdiff-backup is able to back up files across different machines via [ssh](/source/ssh).

== Usage ==
Beginning with version 2.2, the flags passed to rdiff-backup are either general, or specific to the operation. For example, disabling fsync (see below) is an option that is general, and thus comes after <code>rdiff-backup</code>. <code>--no-compression</code> is specific to the backup mode, and thus comes after <code>backup</code>. 

===Backup===
Normal operation is <code>rdiff-backup backup <source directory> <backup directory></code>. [gzip](/source/gzip) compression of increment files can be disabled with <code>--no-compression</code> after the <code>backup</code> flag. The options <code>-v 5</code> and <code>--print-statistics</code> show the backup's progress and some statistics.

Specifying <code>--no-fsync</code> will disable [fsync](/source/fsync) and write the backup to [RAM](/source/Random-access_memory) instead of directly to the physical disk, causing a significant speedup. This comes with an elevated risk of data loss, though.

=== Restoration of files or directories ===
<code>rdiff-backup --restore-as-of <date> <backup> <source></code> will restore to <code><source></code> the entire backup, a single file or a sub-directory. <code><date></code> can be specified in one of several ways:
* as a date, for example "2020-02-14" (which will be interpreted as [midnight](/source/midnight) of the day in question), or as a datetime string like "2020-02-14T12:26:53+02:00" (which can be found by running <code>rdiff-backup --list-increments <backup></code> first)
* as a time span, for example "1M" will restore the files as they were one month ago
* as a number of backups, so "10B" will restore the 10th most-recent version
* or "now", which will restore the most recent backup.

It is also possible to find the relevant time-stamped file in the <code>rdiff-backup-data/increments</code> directory, and run <code>rdiff-backup <time-stamped file> <file or folder to be restored></code>.

Simpler (but not always correctly, as the [file permission](/source/file_permission)s might not be properly restored), the most recent backup can also be restored by copying a backed-up file or directory with <code>[cp](/source/Cp_(Unix)) -a</code> or <code>[rsync](/source/rsync) -a</code>. A deleted file – recognizable by the suffix <code>snapshot.gz</code> – can also be restored by retrieving it in the <code>rdiff-backup-data/increments</code> directory, copying it to the source directory, and unpacking with [gzip](/source/gzip).

===Deleting old backups===
Only the oldest backups can be removed, with <code>rdiff-backup --remove-older-than <date> <backup directory></code>. The ability to delete the oldest versions of specific files (or directories) is scheduled to appear in version 2.2.

When deleting old versions, <code><date></code> takes the same arguments as when restoring files or directories (see above).

=== Problems ===
rdiff-backup does not work under Linux with [SSHFS](/source/SSHFS) and [exFAT](/source/exFAT) file systems, though [FAT](/source/File_Allocation_Table) and [NTFS](/source/NTFS) do work.
This is mostly due to their implementation as [FUSE](/source/Filesystem_in_Userspace) module, causing delays in certain operations, making it probably unfit for backup purposes.
No file system is explicitly supported or unsupported, but rdiff-backup does tests before starting a backup, and refuses to progress on file systems deemed unfit.
Regarding exFAT, by using the [newer in-kernel exFAT-driver](/source/ExFAT), this limitation ''should'' be overcome.

rdiff-backup cannot backup to a SFTP destination.

rdiff-backup recognizes changed files only by file size as well as modification time ([mtime](/source/stat_(system_call))). To make sure all changed files have been backed-up, running <code>rdiff-backup --compare-hash <source directory> <backup directory></code> (or <code>rdiff-backup --compare-full <source directory> <backup directory></code> for a byte-wise comparison) will display all changed files. Then, using <code>[touch](/source/Touch_(command))</code>, the modification time of all problematic files can be reset to now, and thus, they will be included during the next rdiff-backup run.

== References ==
<references />
== External links ==
* {{Official website|https://rdiff-backup.net/}}
* {{GitHub|rdiff-backup}}
* [https://linux.die.net/man/1/rdiff-backup man page for rdiff-backup]

Category:2001 software
Category:Free backup software
Category:Cross-platform software

---
Adapted from the Wikipedia article [Rdiff-backup](https://en.wikipedia.org/wiki/Rdiff-backup) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Rdiff-backup?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
