Duplicity backups to Backblaze B2 (Linux)

PROBLEM: I would like to backup files to the cloud.
SOLUTION: Pick Backblaze B2 with awesome pricing.

1.0 Create Application Key

Using official guide – https://help.backblaze.com/…Account-ID-and-Application-Key
Backblaze has a very easy and intuitive interface, so I bet you don’t need any guide to do it 🙂

2.0 Connection String

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

You should substitute real keys with variables, just to make the string more flexible. E.g.:

export ACC_ID="00011112223aaa"
export APP_KEY="AAABBBCCCDDD000"

b2://$account_ID:$application_key@my-fav-bucket/folder/

3.0 – Duplicity

3.1 Backup

Using Duplicity to Backblaze is very simple! You just need to generate GPG key (GUIDE: https://help.github.com/…/generating-a-new-gpg-key/). And I put the key ID as a variable $GPG_KEY. And here we go!

Duplicity makes incremental backup on the top of the full backup. So every time you run this command you will increment the first full backup.

duplicity --verbosity info --encrypt-sign-key=$GPG_KEY /directoryToBackup b2://$account_ID:$application_key@my-fav-bucket/backup-folder/

3.2 Restore

Restore is very similar to backup. The string is almost the same.

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

So in my case:

duplicity restore --file-to-restore /backup-folder b2://$account_ID:$application_key@my-fav-bucket/ /restored-data-folder

And that is it! You can create a CRON rule to run backups on a regular basis or anything you’d like to!

Leave a Reply

Your email address will not be published. Required fields are marked *