Floating Octothorpe

Getting started with Bup

As a general rule of thumb you can never have to many backups. While this isn't always true, most people will have stories about how they lost data and didn't have a backup. Very few people will tell you about the time they had too many backups...

With the above in mind, this post is going to look at using Bup to manage backups. Before going any further, it's worth pointing out that Bup is still relatively new software, and has a few features that need to be ironed out. If that puts you off I would recommend having a look at rsync, which can be used to implement a relatively simple backup strategy.

What is Bub?

Bup is backup software which shares a few similarities with Git (it uses the same packfile format). However unlike Git, Bup has been designed to handle large files effectively. Some of Bups features include:

Installing Bup

The bup package is already available on Debian, so it can be easily installed using apt-get:

sudo apt-get update
sudo apt-get install bup

Once you've installed Bup you should be able to run bup --version:

$ bup --version

Alternatively Bup has also been packaged for several other distributions, or can be installed from source.

Creating a backup

Once you've installed Bup, the next thing to do is create a Bup repository using bup init. By default the repository will be saved to ~/.bup/, however the -d option can be used to override this:

$ bup -d /var/bup init
Initialized empty Git repository in /var/bup/

If you're familiar with Git repositories, the repository layout should look very familiar:

$ find /var/bup/

Creating a backup is split into two steps. The first thing to do is create an index of the files you want to backup:

$ bup -d /var/bup index /etc/
Indexing: 1100, done (5089 paths/s).

After the index has been created file contents can be backed up using the bup save command:

root@ein:/var# bup -d /var/bup save --name etc-backup /etc/
Reading index: 1100, done.
Saving: 100.00% (1869/1869k, 1100/1100 files), done.
bloom: creating from 1 file (1160 objects).

Note: the --name option is used to specify the backup name:

Restoring files

To restore files from Bup, you first need to work out which backups are available. bup ls can be used to list backup names:

$ bup -d /var/bup ls

You can then list the contents of a named backup:

$ bup -d /var/bup ls etc-backup
2018-07-27-233535  latest

Once you've worked out which backup you want to restore files from, you can restore the backup files to a directory using bup restore:

$ mkdir /tmp/bup_restore
$ bup -d /var/bup restore -C /tmp/bup_restore/ etc-backup/2018-07-27-233535/etc/
Restoring: 1100, done.
$ cat /tmp/bup_restore/hostname

Alternatively you can mount the Bup repository to access individual files:

$ mkdir /tmp/bup_mount
$ bup -d /var/bup fuse /tmp/bup_mount/
$ ls /tmp/bup_mount/
cat bup_mount/etc-backup/2018-07-27-233535/etc/hostname