Brett Klamer

Backups with Tarsnap

Spideroak removed their warrant canary in early August. Whether it was through pure ignorance, or malfeasance, they’ve sent a clear signal to drop their service. One of the few, if not better, alternatives is

Install Tarsnap

See the documentation at

Automatic Backups

The easiest way to get started is a simple cronjob. Run sudo crontab -e and insert:

# tarsnap backup every 2nd hour of the day.
0 */2 * * * /root/

where the script below is created at /root/ Don’t forget to chmod +x /root/


# Make this an absolute path

# Save dry run stats
tarsnap -c -f dry_run --dry-run --print-stats ${BACKUP_DIR} 2> ${CHECK_FILE}

# Extract and edit size of new data that will be saved
## Get the 3rd and 4th columns of the 6th row
ACTUAL_SIZE=`awk '{ print $3,$4 }' /tmp/tarsnap-check.txt | sed '6q;d'`
## Remove the last character in the string
## Remove any spaces
## Make sure letter is capitalized
## Convert units to bytes
ACTUAL_SIZE=`numfmt --from=auto ${ACTUAL_SIZE}`

# If new data is more than baseline, run a backup
if (("$ACTUAL_SIZE" > "$BASELINE_SIZE")); then
    /usr/bin/tarsnap -c \
        -f "${BACKUP_NAME}-$(date +%Y-%m-%d_%H-%M-%S)" \
        --print-stats \

# remove temporary check file
rm -rf ${CHECK_FILE}

This script checks if there is new data to backup and, if so, will create a backup every two hours. This can leave a lot of old archives hanging around, so you may want to check out a few unofficial helper scripts that provide structured archive creation and deletion. The best of which look to be and

Otherwise you can just delete everything older than a chosen date by looking at

tarsnap --list-archives | sort > "./"

and modifying the file into a deletion script.


Restore an archive using:

# Restore whole archive directory in place
tarsnap -x -f imagename
# Restore whole archive directory to new location (no overwriting)
tarsnap -x -f imagename -C ./restore/path

After reinstalling an operating system or moving to a new machine, simply install tarsnap as usual, place the previously generated key at /root/tarsnap.key, then run sudo tarsnap --fsck to rebuild the local cache.

Tarsnap GUI

There is an official GUI for tarsnap at It provides basic interaction with the command line utility. The cron scheduler is hit-or-miss. The archive window is nice for sorting through and deleting old archives.