Backup and Restore Questions

I’m (potentially) planning to redo my Ubuntu Machine from scratch and curious about how OH2 restores a backup.

I ran the backup command and I see it backs up the primary 2 directories of:


But I think it is NOT backing up the /usr/share/openhab2 directory where some users may have a few bindings that are still in development; ie, the z-wave security, osram-lightify, and perhaps some others.

So if you do a backup and restore, do you then also need to ensure you have that /usr/share/openhab2 directory also backed up?

A second question is… On a restore to a new/refresh Ubuntu or other. Do you need to first install OH2 and then run the restore process? Or does a restore act like an install? I’m unsure if the OH2 service would start after a restore unless you actually did an install first. And I think its possible a fresh install of OH2 first could potentially install a new/latest version then what you backed up? So you may need to ensure your versions match? What if you tried to restore an older snap shop on top of a newer one?

Of course you would still need to add the OH2 repository key and sources to ensure you can do an upgrade.

And maybe last question is if do you need to actually reinstall bindings in PaperUI or Habmin after a reinstall? And guess that since the usr/share/openhab2 directory is possibly not backed up, those bindings may need to copied back over and manually started via the console the first time?

I can’t answer all of your questions but I suspect some of them can be figured out through a review of the backup and restore scripts. I’m running a version of OH before those scripts were written, or they are not deployed with the Docker image.

Anyway, you need to be a little careful because not all of /var/lib/openhab2 is backed up. In particular, there are a number of files in /var/lib/openhab2/etc that need to be specific to the version of OH you are running. You also do not want to back up the cache and tmp folders there.

If the script doesn’t then you will want to do that as well.

This would be best I think as you will want the specific files in /var/lib/openhab2/etc that goes with that version.

No, the retore is designed to migrate a configuration between different versions of OH as well as migrating to other installs or recovering from a corrupted config and the like.

It wouldn’t because the restore only copies config files, not the actual program itself.

This is why the backup and restore scripts are selective in what files get backed up and restored. The scripts will work to migrate your config between versions. If you just blindly copy the whole /var/lib/openhab2 folder you will have problems. If you use the scripts you will be fine.

I’m mostly certain that the backup and restore scripts handle this for you.

1 Like

All of what @rlkoshak says is correct. The scripts were intended to backup configurations and are intended to be compatible with newer versions and even different OSes or installation methods. For that reason, /usr/share/openhab2 is not backed up as the development binding files can’t be guaranteed to work across different versions. You only need to backup the changes you’ve made to that folder in addition to what the script does.

For bindings installed through configuration files or paperUI, these bindings will be installed as part of the restore process. This also means that if you have bindings installed and they aren’t part of the backup when you restore, they will be removed. You should add the development bindings again after the script completes.

The scripts will not allow you to continue if it does not detect any existing openhab2 folders.

For peace of mind, you can always leave your current setup as is and try restoring zip file on another system to see what it does.

1 Like