2014-02-11

Using Burp for backup of Raspberry Pi

I am currently running two Raspberry Pi, one for Icinga (see here for another blog post about this) and the other for OpenHAB. The experience has shown, that the SD cards in the Raspberry can get broken quickly. It is no problem to install Raspian, but I spent hours configuring everything and therefore I want to have a backup of my configuration. I have chosen "burp" as backup solution.

Burp contains of two parts:

  • A server that can run singly on your local network, ideally on the NAS
  • A client that runs on each machine in the network, sending the backup data to the centrally running server.
I use burp a little bit different. I don't want to run any custom software on my NAS, but still want the data to be stored centrally on the NAS, so the architecture is:
  • The QNAP NAS has a /Backup directory which stores all the backup data
  • This Backup directory is exported via NFS to all machines
  • On each machine there is a burp server and client running that stores the data on the mounted Backup directory.

Create and export the Backup directory via NFS

In this step we will create a Backup directory and export it via NFS to all clients that need it.

Create NFS export on NAS

In my case I want the data to be stored on my QNAP NAS which is able to provide a directory using NFS. NFS used IP-based authentication, so this is how I need to configure it. First I create the backup directory:


and make it available to the two RPi IP addresses:

Mount the backup media

This step needs to be done on all machines that do backup and run burp. In my case I want to backup to an NFS share that is provided by by NAS, I add the following line to /etc/fstab:


Now, after running "mount -a" I see the mounted drive with "mount":


I the configuration is wrong you will see this error message:


In this case, check your configuration.

Install and configure Burp

Burp has a more detailed documentation, but for the impatient, here is a short version.

Install Burp

Burp can be installed by simply running "apt-get update" and "apt-get install burp":


We need some dependencies, so additionally run "apt-get install librsync-dev libz-dev libssl-dev uthash-dev" for the rest that we need.

Configure the burp server

Edit the file /etc/burp/burp-server.conf to tell the server to do the backups to /media/backup:

Start the server

Edit the file /etc/defaults/burp and change the value of RUN=no to RUN=yes:


Now start the service using "service burp start" verify that it is running:


The server will also automatically start after a reboot.

Configure the client

We need to configure the client in the file "/etc/burp/burp.conf". Change cname to a unique name, in my case "openhab" and a "include=" line for each directory that needs to be backed up:


and


In /etc/burp/burp.conf we tell the client that we are "openhab" and the we have the password "abcdefgh". In order for the server to accept that, we need to copy the file /etc/burp/clientconfdir/testclient to /etc/burp/clientconfdir/openhab which contains the password for our client "openhab":

Initial start of the client

Simply launch "burp" and there will be some certificate magic which happens only the first time.


On subsequent starts of "burp" there will only this message:


Note: "burp" implies "burp -a l" which is the command for list existing backups. So calling "burp" anytime will do no harm.

First backup

Run "burp -a b", you will see some lengthy output of the backup process ending with the following screen:


Verify the backup with "burp" (which implies "burp -a l" for listing the backups).


There is now one single backup with the number "0000001". After a few days (on another machine) it looks like this:


In this case we can see, that there were 88 backups done (one daily), each about after 24 hours.

Activate cron for periodic backups

Add the file "/etc/cron.d/burp" and put the following content inside:


This will launch "burp -a b" three times per hour. Note that the server configuration automatically reduces the frequency of backups to one daily. You can change this behavior if you need a higher frequent backup.

Using Burp

Burp now runs and will automatically do daily backups. Surely burp allows you to browse historic backups, list the files and do restores. For example will "burp -a l -b 82" list all files that are contained in backup number 82. "burp -a r ..." allows you to restore files.

Verify the backup location

Last, but not least: Take a look on the NFS directory to really verify that the backups are located on the right place. I mounted the backup directory on my Mac and can see the following filesystem structure:


You can see the following:
  • The machines "icinga" and "openhab" store their backups in different directories.
  • "icinga" has a directory called "deltas.forward" which contains the historic backups since this machine does backups for some longer time.
  • I am able to access the files directly without any magic, which can be really nice in emergency situations. Some backup solutions work good, but require a running client installation in order to access the backup data.
If you like this solutions, please add a comment.