Recommended way to backup/restore OH2 configurations and things?

True, I was only addressing the OH part since that is what Andrea was asking about.

As far as I know, there is no automated or even complete guide for dealing with migrating everything that openHABian can install to a new machine.

1 Like

and what about Oracle Java? still makes sense to use the 32 bit or can I install the 64 bit version?

Unless you are running an ARM VM the 64-bit should be fine.

https://docs.openhab.org/installation/index.html#prerequisites

Take heed of Markus’s posting though. Copying the etc and var/lib folder only addresses OH’s configuration. Any custom configuration you have done with any services installed by openHABian needs to be backed up and moved over as well.

Nice script. Helps me avoiding all the trouble I have with Amanda. Do you have a script for restoring the data as well?

Just wondering how I get access to or where to I find the files under /var/lib/openhab2/backups ?

Use a SSH client… Like Winscp or something simular.

I am currently using Putty is that the same ?, if so how do I look at the files ?

Go to the path you wrote in your previous post

Yeah - In the name of community publish your recover script here :slight_smile:

Hi,

I have two questions regarding the OpenHab2 backup script
/usr/share/openhab2/runtime/bin/backup

(I hope asking this in this thread is correct, otherwise pelase tell me and I will open a new one).

Q1: the copy command for the /userdata folder uses the “-R” option, as a result of this all copied files will have a timestamp of the copy operation. This way you cannot see the date&time of the underlying original file and therefore it is harder to see which files might have changed in the configuration compared to the backup.

Why wasn’t the “-a” copy option used?

find “${OPENHAB_USERDATA:?}/”* -prune -not -path “${OPENHAB_BACKUPS:?}” | xargs -I % cp -R % “$TempDir/userdata”

Q2: is it necessary to stop the openhab2.service before executing the backup script?

1 Like

No.

Good to know, thank you!

The script is very good and work fine.
Can you provide the script for the restore?
Thank you.

I use the following shell script to backup to an network share and it works like a charme:

#!/bin/bash
#Mount network share
mount -t cifs -o user=USERNAME,password=PASSWORD,domain=DOMAIN,rw,file_mode=0777,dir_mode=0777 //192.168.1.1/Backup /mnt/backup
#Variables
BACKUP_PATH="/mnt/backup/Openhab/onflow"
BACKUP_COUNT="15"
BACKUP_NAME="Backup"
#Create Backup
openhab-cli backup ${BACKUP_PATH}/${BACKUP_NAME}-$(date +%Y%m%d).zip
#Delete old backup files
pushd ${BACKUP_PATH}; ls -tr ${BACKUP_PATH}/${BACKUP_NAME}* | head -n -${BACKUP_COUNT} | xargs rm; popd
#unmount
umount /mnt/backup
2 Likes

Can you post the restore script please?

-deleted-

Hey! some time ago I made an update to v3 and for my own reason rolled back to v2.
everything works well except for the backup script.
openhab-cli now looks for /usr/share/openhab instead of /usr/share/openhab2
where can i fix this?
Im want to go to v3, but a little later

/usr/bin/openhab-cli: 88: /usr/bin/openhab-cli: /usr/share/openhab/runtime/bin/backup: not found

that is nothing to fix… It is intended to have different directories for OH2 vs. OH3.
Depending on the bindings that you use there are incompatibilities / breaking changes between the versions. So I think things may get worse in case you restore OH3 configuration into OH2.

In case you want to go that route have a look into openhab-cli resp. backup resp. restore script which are called from openhab-cli. You can find the paths that are used inside of the scripts.

i’ve developed this script to backup openhab3, grafana and influxdb: https://github.com/oliranks/openHAB3-full_backup_and_restore
let me know how it works for you

To reiterate statements made here and on various threads, the recommended way to backup (and restore, eventually) an OH config is the openhab-cli script which is part of the UNIX distribution package(s).
To backup anything beyond pure OH config such as homegrown scripts, mosquitto setup etc the recommendation is to install openHABian and use the Amanda backup system it comes with.

Remember anyone will benefit from going with a common solution.