How to configure Backblaze B2 with Duplicity on Linux

Millions of Linux installations around the world include duplicity, an open source backup tool which supports encryption, compression, data retention and many other powerful features. Duplicity can store backup data in many destinations, including Backblaze B2. This guide will help you get setup and give you the commands to do a full backup and restore of a specific folder.

Installation

While duplicity is pre-installed on many Linux systems, you need version v0.7.12 or newer, which has been available since March 2017. 

The easiest way to upgrade on Ubuntu, Debian and other Linux systems that support apt is via the terminal:

$ duplicity --version
duplicity 0.7.06
$ sudo add-apt-repository ppa:duplicity-team/ppa $ sudo apt-get update $ sudo apt-get --only-upgrade install duplicity
$ duplicity --version
duplicity 0.7.13.1

Create Backblaze account with B2 enabled

First, you have to create a Backblaze account and enable B2. If you already have a Backblaze account, login, visit "My Settings" and enable "B2 Cloud Storage" on your account under "Enabled Products" 

My_Settings.png

Second, create an Private bucket in your B2 account.

B2_Cloud_Storage_Buckets.png

Third, retrieve your account id and application key. You will need to specify these in duplicity to perform backups and restores. 

Performing a backup of your home directory

While duplicity is a sophisticated tool with many features, getting started is very easy. For example, if you want to create a backup of your home directory, use the following command, replacing your Backblaze B2 account id, application key and bucket name appropriately:

$ duplicity ~ b2://[account id]:[application key]@[B2 bucket name]

On first run, duplicity will create an encryption key for you and run a full backup. After the backup is complete, duplicity will give you stats about how much was backed up and stored. Each subsequent run of duplicity will only do an incremental backup, which will be considerably faster.

--------------[ Backup Statistics ]--------------
StartTime 1503518136.97 (Wed Aug 23 12:55:36 2017)
EndTime 1503518593.19 (Wed Aug 23 13:03:13 2017)
ElapsedTime 456.22 (7 minutes 36.22 seconds)
SourceFiles 456
SourceFileSize 2157364972 (2.01 GB)
NewFiles 456
NewFileSize 2157364972 (2.01 GB)
DeletedFiles 0
ChangedFiles 0
ChangedFileSize 0 (0 bytes)
ChangedDeltaSize 0 (0 bytes)
DeltaEntries 456
RawDeltaSize 2156938988 (2.01 GB)
TotalDestinationSizeChange 1449185876 (1.35 GB)
Errors 0
------------------------------------------------- 

Restoring a folder from your duplicity backup

To restore a folder from your backup, use the following command:

$ duplicity restore --file-to-restore [folder name from backup] b2://[account id]:[application key]@[B2 bucket name] [restore path]

The [folder from backup] is the folder's name in your duplicity backup. The [restore folder] is the folder on your filesystem where you want this folder to be restored.

Just specify the encryption passphrase you set above, and the folder will be restored.

What else can I do?

We got great inspiration from Logan Marchione's post on how to setup Duplicity and B2. It includes instructions on setup up your own GPG key, and a script you can run daily to do full backups every 30 days. 

Other resources include Ubuntu's howto page for Duplicity and the duplicity man page.

I want a GUI. Where can I get a GUI? 

There is a popular GUI for duplicity, Déjà Dup. While it does not support Backblaze B2 today, there has been some interest to implement this. If you'd like to see B2 support, make sure you share your interest.

Another open source backup tool that supports Backblaze B2 and has a web based GUI is Duplicati. There are commercial tools with GUIs too: Cloudberry, qBackup, and Duplicacy.

 

Special thanks to Matthew Bentley for adding the Backblaze B2 support to duplicity.

 

 

Have more questions? Submit a request

8 Comments

  • 0
    Avatar
    logan

    Hey, thanks for the mention! Great article!

  • 1
    Avatar
    hanno

    Per-bucket API keys please. Thank you :)

  • 0
    Avatar
    daddy

    Duplicity support was exactly the reason I've started using backblaze!

  • 0
    Avatar
    mike.hewitt

    Hopefully I will get past the stage of getting the files to download.  For example I receive:

    Failed to fetch http://ppa.launchpad.net/duplicity-team/ppa/ubuntu/dists/jessie/main/binary-amd64/Packages 404 Not Found

    W: Failed to fetch http://ppa.launchpad.net/duplicity-team/ppa/ubuntu/dists/jessie/main/binary-i386/Packages 404 Not Found

     

     

  • 0
    Avatar
  • 0
    Avatar
    ron.siesta

    I have had no luck with the restore. The backup seems to work fine. If I do a backup with the following command.:

    duplicity /etc b2://myaccount:mykey@duplicity-davis/etc

    I have a bucket called duplicity-davis, it has a folder in it of etc, in the folder is the encrypted file dataset.

    I now want to restore that folder /etc. All the combinations I have tried all result in

    etc not found in archive - no files restored.

    Can someone please give me the syntax to restore the /etc folder to the current directory?

    duplicity restore --file-to-restore /etc b2://myaccount:mykey@duplicity-davis/etc ./

    is one format I have tried.

     

     

     

     

     

     

     

     

     

     

  • 0
    Avatar
    ron.siesta

    I guess I totally misunderstood the example command to restore above, to do what I wanted I used

    duplicity restore b2://myaccount:mykey@duplicity-davis/etc ./etc

     

  • 0
    Avatar
    greg

    Using these instructions, I ran into a problem backing up a large directory:

    Attempt 1 failed. URLError: <urlopen error [Errno 104] Connection reset by peer>
    Attempt 2 failed. URLError: <urlopen error [Errno 104] Connection reset by peer>
    Attempt 3 failed. URLError: <urlopen error [Errno 104] Connection reset by peer>
    Attempt 4 failed. URLError: <urlopen error [Errno 104] Connection reset by peer>


    Apparently the sig file was larger than the 5 GB limit imposed by Backblaze, so the backup failed. To fix this, I added "--max-blocksize=20480" to the backup command:

    duplicity --max-blocksize=20480 ~ b2://[account id]:[application key]@[B2 bucket name]
    Edited by greg
Please sign in to leave a comment.
Powered by Zendesk