Wiki2
Tarsnap

Tarsnap on OpenBSD

tarsnap is a nice online backup service where you pay only for actual data transfer. Currently you pay 0.30 USD / GB of transferred data. Tarsnap makes transfers efficient by using data from previous snapshots in a differential way.

Tarsnap is also designed after common tar utility, which makes adaption easier. After account setup and client installation a snapshot is transferred as as easy as.

tarsnap -cf home-peter-`date +%Y%m%d%H%M` /home/peter

Setup and account

First you need to setup an account at http://www.tarsnap.com/. In the process you will also transfer some money to cover for your traffic.

Installation on OpenBSD

You need to compile tarsnap on your architecture.

On OpenBSD I did the following steps. I believe that tarsnap make use of scrypt. So I installed that from packages to simplify the build.

wget --no-check-certificate https://www.tarsnap.com/download/tarsnap-autoconf-1.0.27.tgz
tar -xzf tarsnap-autoconf-1.0.27.tgz
cd tarsnap-autoconf-1.0.27
pkg_add scrypt
./configure –sysconfdir=/etc –mandir=/usr/local/man
make all install clean

The parameters supplied to configure is used to map the configuration file and manual pages to suitable locations in OpenBSD. See history of this article to see what I needed to do before I understood this.

Then you need to edit the configuration file to your needs. I changed some default values to adhere to my likings. First I created a .tarsnap to keep the tarsnap key file in.

cd /root
mkdir .tarsnap
chmod 700 .tarsnap/

Then I create the key file in this folder. The password used at registration will be asked for. Note that archives is only accessible from this single machine if the key file is not copied to the other machine used.

cd .tarsnap
tarsnap-keygen --keyfile /root/.tarsnap/tarsnap.key --user <email> --machine `hostname`

KEEP THE tarsnap.key FILE IN A SAFE LOCATION AS THIS IS THE ONLY WAY TO GET ACCESS TO THE UPLOADED DATA!

I also chose another location for the tarsnap cache. /var/cache/tarsnap-cache instead of the default one. The complete /etc/tarsnap.conf is show below.

cachedir /var/cache/tarsnap-cache
keyfile /root/.tarsnap/tarsnap.key
nodump
print-stats
checkpoint-bytes 1G
#exclude
#include

After this tarsnap is ready to be used …

Usage

Tarsnap is used in the same way as tar is used. In the example below I first create a new snapshot of my home directory (this takes some time the first time), then list the archive and contents of the uploaded snapshot.

tarsnap -cf home-peter-`date +%Y%m%d%H%M` /home/peter
tarsnap --list-archive
tarsnap -tvf home-peter-201007182350

Add --keyfile <machine_tarsnap_key> if you want to access an archive from another machine.

Simple isn’t it?

References