Tarsnap - Online backups for the truly paranoid

Navigation menu

Tarsnap general usage

How Tarsnap archives work

Unlike many backup systems, Tarsnap works with a concept of immutable archives. Similar to backups stored on Write Once Read Many drives, once a Tarsnap archive has been created, it cannot be modified; each archive is cryptographically signed to ensure that it cannot be silently modified. For obvious reasons, this also means that archives cannot be overwritten; each archive must be created with a new name.

Tarsnap also makes creating new archives very fast: Because Tarsnap deduplicates archives against data stored in previous archives, if you have an archive already stored with a previous version of the data you're placing into a new archive, Tarsnap will automatically recognize the duplicated data and only upload the new blocks. Similarly, when you delete an archive, Tarsnap figures out which data was only in that archive, and deletes it, while leaving behind any data which is still needed by other archives.

In short, to use Tarsnap you should start by forgetting everything you know about managing backups. If you want a backup of your data every day, then just ask Tarsnap to create a backup of your data every day.

Tarsnap command line

The examples here assume that you're using a Tarsnap configuration file including keyfile and cachedir directives. The sample configuration file provided with Tarsnap specifies these (the default key file location is /root/tarsnap.key, and the default cache directory location is /usr/local/tarsnap-cache). Each keyfile defines a separate namespace for archive names.

Create an archive named "mybackup" containing /usr/home and /other/stuff:
tarsnap -c -f mybackup /usr/home /other/stuff
Create another archive a day later from the same directories; this will be much faster because Tarsnap will recognize and avoid uploading data which was stored previously:
tarsnap -c -f anotherbackup /usr/home /other/stuff
List all the archives which have been stored:
tarsnap --list-archives
Delete the first archive, leaving the second archive intact:
tarsnap -d -f mybackup
List the files in the "anotherbackup" archive
tarsnap -tv -f anotherbackup
Restore a single file
tarsnap -x -f anotherbackup usr/home/auser/important-file.txt
Restore two users' home directories
tarsnap -x -f anotherbackup usr/home/auser usr/home/anotheruser
Print how much data would be uploaded (without uploading anything or spending any money)
tarsnap -c -f mybackup --dry-run --print-stats /usr/home
Create another archive, printing some statistics once the uploading is completed:
tarsnap -c -f anotherbackup2 --print-stats /usr/home /other/stuff

Tarsnap cache directory

The tarsnap -c and tarsnap -d (archive creating and deleting) operations use a "cache directory" which allows Tarsnap to identify which blocks of data have been previously stored; this directory is specified via the cachedir directive in the Tarsnap configuration file or via the --cachedir option to Tarsnap. If the cache directory is lost or out of date, the tarsnap -c and tarsnap -d operations will exit with an error message instructing you to run tarsnap --fsck to regenerate the cache directory.