Even though openHAB has a build-in backup system, as described in openHAB#Backup, I have found out that the backup for sure is not complete (at LEAST the addons folder is not backed up).
So I made a short story alternative backup (on Ubuntu LTS), before testing stuff etc:
#!/bin/bash now=`date +"%Y_%d_%m"` cd /etc/openhab2/ tar -cvzf /home/bnp/openhab-etc-$now.tgz /etc/openhab2/* cd /usr/share/openhab2/ tar -cvzf /home/bnp/openhab-usr-share-$now.tgz /usr/share/openhab2/*
Or, alternate as (with nice openHAB shutdown first):
#!/bin/bash now=`date +"%Y_%d_%m"` /etc/init.d/openhab2 stop cd /etc/openhab2/ tar -cvzf /home/bnp/openhab-etc-$now.tgz /etc/openhab2/* cd /usr/share/openhab2/ tar -cvzf /home/bnp/openhab-usr-share-$now.tgz /usr/share/openhab2/* /etc/init.d/openhab2 start
This simply dumps all files under /etc/openhab2 and /usr/share/openhab2 into 2 tar files with the current date, for easy recovery:
root@robin:~# ls -l -rw-r--r-- 1 root root 119693 Feb 13 19:31 openhab-etc-2019_13_02.tgz -rwxr-xr-x 1 root root 206 Feb 13 19:32 openhab-tar-backup.sh -rw-r--r-- 1 root root 260385606 Feb 13 19:31 openhab-usr-share-2019_13_02.tgz root@robin:~# file openhab-etc-2019_13_02.tgz openhab-etc-2019_13_02.tgz: gzip compressed data, last modified: Wed Feb 13 19:31:11 2019, from Unix root@robin:~#