Backing up using Backblaze B2 and Restic

Sun Mar 29 2020

Backblaze is a pioneer in robust, scalable low cost cloud backup and storage services. Their B2 service is similar to Amazon's S3 where you have a bucket where you just throw stuff into and pay for the bandwidth and storage used.

The most important difference though is the pricing. Backblaze B2 is quite a bit cheaper than AWS S3.

But this isn't an entirely fair comparison as AWS offers another service next to S3 which is called S3 Glacier. Where S3 is mainly used a data storage that has frequent access to the data, Glacier is the opposite where you store data for long periods that don't get accessed. The use case is to back up data and not access it only in case we ever need to recover it so it makes more sense to compare the pricing with Glacier.

Their price data is quite similar to B2 even slightly cheaper. But there's one giant caviat... It's horrible to use. I've taken a look at it and tried setting it up to take automatic backups but everything regarding Glacier is soooooo badly designed user experience wise. It's such a pain that I just gave up and started looking for something else.

From what I understand people often use S3 as their main data storage and then set lifecycle rules on their data to expire to Glacier. But doing this for a simple file server storage backup feels like you're just bringing in extra costs to do something cool on such a small scale.

To make backing up to B2 easier there's a lot of tools:

  • duplicity
  • attic
  • duplicacy
  • restic

It's just a matter of personal preference though which one you would want to use. I've currently settled with restic as my main tool but am open to test others.

The writer of duplicacy did a benchmark which you can read here: Unsure if those results are still the same though with the newer versions of the tools.

To easen backing up I just wrote a simple bash script to run through a cronjob every now and then.

1#!/usr/bin/env bash 2 3echo "[LOG] Starting backup script at $(date)" 4 5# Additional restic options 6OPTIONS="--option b2.connections=50" 7 8# Iterate over directories and perform separate snapshots per dir 9dirs_to_backup=( /foo /bar ) 10for dir in "${dirs_to_backup[@]}" 11do 12 echo "[LOG] Creating backup of directory: ${dir}" 13 /usr/local/bin/restic ${OPTIONS} backup $dir 14done 15 16# Iterate over files and perform separate snapshots per file 17files_to_backup=( /foo/bar.yml ) 18for file in "${files_to_backup[@]}" 19do 20 echo "[LOG] Creating backup of file: ${file}" 21 /usr/local/bin/restic ${OPTIONS} backup $file 22done 23 24# Clean up and only keep the last snapshots available 25echo "[LOG] Cleaning up" 26/usr/local/bin/restic ${OPTIONS} forget --keep-last 1 --prune

For more information on Backblaze B2: For more information of Restic: