Securely and remotely backup your server using Tarsnap
Tarsnap is a great service. It’s extremely affordable and secure. I mentioned it briefly in my previous post about MySQL backups.
Tarsnap is only $0.25 / GB-month for storage and $0.25 / GB for bandwidth, which is extremely affordable. You can add funds to your account whenever you like, which is also very nice. Your initial fund deposit must be at least $5. You can signup for a Tarsnap account here.
Installing it on a stock Ubuntu 14.04 LTS installation requires some additional steps to get everything working nicely.
1. Install dependencies
sudo apt-get install build-essential ext2fs-dev zlib1g-dev libssl-dev
2. Install Tarsnap
Download Tarsnap, I do it like this with wget:
wget --no-check-certificate https://www.tarsnap.com/download/tarsnap-autoconf-1.0.35.tgz
Now we need to extract, configure, and compile Tarsnap.
tar xfz tarsnap-autoconf-1.0.35.tgz cd tarsnap-autoconf-1.0.35 ./configure sudo make install clean
3. Configure Tarsnap
First, copy the example config to the live config:
sudo mv /usr/local/etc/tarsnap.conf.sample /usr/local/etc/tarsnap.conf
If you receive an error with that command, like mkdir: cannot create directory
, ignore it and continue on.
Next, we need to generate a tarsnap key for your machine. I like to keep my tarsnap key in my home directory, so I run something like this:
mkdir ~/.tarsnap tarsnap-keygen --keyfile /home/youruser/.tarsnap/tarsnap.key --user your@email.com --machine your-machine-name
You’ll be prompted for your Tarsnap password when running tarsnap-keygen
.
Now, edit the tarsnap.conf
file:
sudo pico /usr/local/etc/tarsnap.conf
Point the keyfile directive to the key file we created a couple steps ago. The top of your tarsnap.conf file should look similar to this now:
### Recommended options # Tarsnap cache directory cachedir /tmp/tarsnap-cache # Tarsnap key file keyfile /home/youruser/.tarsnap/tarsnap.key
4. Use Tarsnap to Make a Backup
You’ll want get familiar with the Tarsnap manpages. To create your first archive, with a name of servername-20140805, do this:
tarsnap -c -f servername-20140805 /home/youruser
That will backup the /home/youruser folder to Tarsnap! Depending on the size of the backup and speed of your connection, it could take quite some time to finish the backup.
Below is the output of tarsnap –help, if you’re interested.
You can read more about Tarsnap at their homepage, tarsnap.com. They also have a page describing their infrastructure setup, which is kinda neat. Tarsnap also runs a bug bounty program.
I’ve only tested this on DigitalOcean VPS’s running Ubuntu 14.04 x64, but it should work on most Ubuntu variants.
Did I miss something or get something totally wrong? If so, please let me know, the comments are open!
Well, now what?
Work with Me
I'm available for hire and always taking new clients, big and small. Got a project or an idea you'd like to discuss? Startup plan but no developer to make it happen? Just get in touch, I'd love to see if I can help you out!
Leave some Feedback
Got a question or some updated information releavant to this post? Please, leave a comment! The comments are a great way to get help, I read them all and reply to nearly every comment. Let's talk. 😀
Longren.io is proudly hosted by DigitalOcean

Thanks for your interest in Tarsnap! The wget line hard-codes 1.0.35, but Tarsnap 1.0.35 is 5 years old (July 25, 2013). The latest release is 1.0.39.
In general, I would suggest that people go to https://tarsnap.com to find the latest version, to avoid out-of-date documentation.