Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Kodeblok
titleopenhab-tar-backup.sh
#!/bin/bash

now=`date +"%Y_%d_%m"`

cd /etcopt/openhab2openhab/
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/openhab2opt/openhab/*


Or, alternate as (with nice openHAB shutdown first):

Kodeblok
titleopenhab-tar-backup.sh
#!/bin/bash

now=`date +"%Y_%d_%m"`

/etc/init.d/openhab2docker stop openhab
cd /etcopt/openhab2openhab/
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:

Kodeblok
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:~#docker start openhab