Using borg for backups

2 minute read Published:

Weekly encrypted, incremental and deduplicated Backup using borg

Introduction

It is a widely accepted pattern in IT business to make regular backups of important data. I decided to make a weekly one of my /home. Since within a week usually most filed won’t change I decided for an incremental backup, to only include new data. In the past I used different tools to archive that.

rsyn-incr

Durin my time at university, I used a small Shellscript, rsync-incr to run by an hourly cronjob of root to backup my Uni folder so I could not accidently delete it.

/etc/cron.hourly/backup.sh
#!/bin/sh
/usr/local/bin/rsync-incr 24 /home/dex/Uni /home/backup/Uni

Déjà Dup

This solution helps for the most dangerous kind of data loss: stupidity. But of course a backup should not be on the same box that is backuped.

Thats why I gave Déjà Dup a go. Its a nice graphical tool using duplicity as backend and thus can backup local, on USB devices, SSH and some cloud based storrages.

Also you can use GnuPG for a keyphrase (or even Public Key) based encryption.

Since it also integrates nicely with Gnome Desktop or KDE you get some popup in the specified intervall and it will automatically start as soon as you plug the USB drive in.

Problem with it: it takes hours to complete. At least for large data like my home.

Attic

Since Déjà Dup was simply too slow to be realy usefull I tried Attic next.

Attic is primary a deduplication software written in Python, but it also works as backup solution. It also allows encrypting the data.

borg

Borg is the sucessor of attic and more maintained and with a modern codebase.

So what I use now for my weekly backup:


sudo borg create -v --stats /run/media/dex/Backup1.5TB/Backup::`date +%Y-%m-%d` /home/dex/

Enter passphrase for key /run/media/dex/Backup1.5TB/Backup:
------------------------------------------------------------------------------
Archive name: 2017-03-04
Archive fingerprint: 841c72fd98f0c60cd6e2e35fbd75078aa11ff7c23d97872dbd652ee0e3f6e916
Time (start): Sat, 2017-03-04 10:38:19
Time (end):   Sat, 2017-03-04 12:10:48
Duration: 1 hours 32 minutes 29.07 seconds
Number of files: 4801125
------------------------------------------------------------------------------
                       Original size      Compressed size    Deduplicated size
This archive:              770.20 GB            599.42 GB              7.50 GB
All archives:               50.33 TB             36.95 TB            928.24 GB

                       Unique chunks         Total chunks
Chunk index:                20360785            976958239
------------------------------------------------------------------------------

Quite impressive, I think. 😎