OpenHAB Backup

Suggestions on setup backup procedures

How to setup an automatic daily backup for the most important OpenHAB configurations. Here some addons to the backup tutorial.

Using the openhabian-config item:

50 | Backup/Restore       Manage backups and restore your system ?    

it is possible to install all the needed backup environment for the open-source software Amanda.

The github backup tutorial explains well enough (and it’s strongly suggested to read it all before proceeding with the installation) but there are some details to take care in order to have a system working fine.
There are many threads on the OpenHAB community related to installation issues (example). Most of them are related to how the backup volume is mounted, either a NAS or a USB local drive.

In this installation it’s mounted on an 8GB USB pen drive on one of the two USB sockets.
First of all, it’s better to format the volume with an EXT4 filesystem to be able to use all the Linux capability. With a FAT32 filesystem for example, it’s not possible to create the symbolic links needed by Amanda to run.
After the mount point is created, to have the volume mounted at startup it needs to add a line to /etc/fstab file. In this example:

dev/sda1 /media/usb ext4 defaults,noatime 0 1

Only after the backup volume is correctly configured the Amanda installation can proceed.
As well as in this example can happen that the installation is not correctly executed. The script returns no errors, but exiting from openhabian-config it’s possible to read the console messages. Has suggested from the script author on the aforementioned thread, it needs to manually create the symbolic links shown on the error messages to have the system working:

openhabian@cm3-home:/media/usb/backup/slots$ sudo ln -s /media/usb/backup/slots/drive0 drive0
openhabian@cm3-home:/media/usb/backup/slots$ sudo ln -s /media/usb/backup/slots/drive0 drive1

The rest of the installation script works fine creating all the virtual tapes structure on the backup volume, the configuration files and the cron entry to start the full and incremental backups in rotation every day at one o’clock in the morning.

Then check the configuration:

openhabian@cm3-home:/media/usb/backup/slots$ su backup
backup@cm3-home:/media/usb/backup/slots$ amcheck openhab-dir

Amanda Tape Server Host Check
slot 1: contains an empty volume
Will write label 'openHABian-openhab-dir-001' to new volume in slot 1.
NOTE: skipping tape-writable test
NOTE: host info dir /var/lib/amanda/openhab-dir/curinfo/cm3-home does not exist
NOTE: it will be created on the next run.
NOTE: index dir /var/lib/amanda/openhab-dir/index/cm3-home does not exist
NOTE: it will be created on the next run.
Server check took 1.145 seconds

Amanda Backup Client Hosts Check
Client check: 1 host checked in 3.145 seconds.  0 problems found.

(brought to you by Amanda 3.3.9)

It’s advisable to add to the /etc/amanda/openhab-dir/disklist configuration file some more folders to backup, in addition to the default ones, according to your own needs, binding and external programs installed. In this installation:

cm3-home  /etc/openhab2             user-tar
cm3-home  /var/lib/openhab2         user-tar
cm3-home  /usr/share/openhab2       user-tar
cm3-home  /etc/default              user-tar
cm3-home  /home/openhabian          user-tar
cm3-home  /etc/amanda/openhab-dir   user-tar

To do that the user openhab must be added to backup group

sudo adduser backup openhab

Remember to save this and any other configurations somewhere, re-installing Amanda the disklist file will be replaced with the default one.