Restore my configuration on rebuild/svn checkout - with addons

I know I can load manual or non “official” bindings in the /usr/share/openhab2/addons folder

But where are those installed via the paper UI living, and it that worth backing up as part of a restoration process?

I guess what I’m really after, is in the event of an rebuild, I can pull all my items, rules and sitemaps etc (which is why I also tend to write .things files rather than using the jsondb), but how can I restore all of the addons that I’ve installed, all the transformation addons, zwave, network, networkups?

I think I’ve seen that you can update a .cfg file somewhere with the loaded addons, and they are downloaded for me (Is that correct?) and so if I add via paper ui is that .cfg file updated, or do I have to remember to do it each time if that addon becomes part of my build.

There is a backup/restore script, either use it directly https://www.openhab.org/docs/installation/linux.html#backup-and-restore
or through

openhab-cli backup

and

openhab-cli restore /path/to/zipped/backup

This will backup /etc/openhab2/ and /var/lib/openhab2/
This way, the information about installed addons is backuped, but not the addons itself, so when installing openhab2 new, the actual version of the bindings will be installed.
The only things to backup in addition, are the manually installed addons.

1 Like

How will the actual bindings be installed? Do I manually have to hit install on all of them (and therefore remember what I’d installed), or is it held in some config that tells the system in a restore to automatically get x, y and z bindings as that’s what was installed.

conf/services/addons.cfg (where conf is your config folder, /etc/openhab2 on an installed OH).

No. If you use addons.cfg then you must manage the installation of ALL of your addons through that config file. If that file is not empty (or all commented out) then any addon not listed in that file will become uninstalled.

The latter. It would be a pretty poor backup and restore if you had to reinstall everything after a restore.

This is incorrect. You can configure only the bindings if you so wish. Or only the transformations and actions…
Any line uncommented will take over from the PaperUI config.

I have gradually moved all my config to the addons.cfg

WARNING: For market place binding you need to add “binding-########” to the binding comma separated list.

SECOND WARNING. During major openHAB updates the addons.cfg will be replaced. Keep a copy of your file so that you can restore your lists of installed bindings, actions… and modify the new file after the update.

Using the addons.cfg is far more reliable than the paperUI

Reliable in what ways? I’ve used addons.cfg almost from the beginning because the Docker configuration did not handle upgrades meaning every time I created a new container I would have to clear out my userdata and rebuild the whole OH config.

However, now that the Docker image does handle upgrades properly I wouldn’t hesitate to recommend using PaperUI for binding installation.

PaperUI installed addons have been known to uninstall themselves when something is updated or another addon is installed. It doesn’t happens with addons.cfg

I thought that was fixed. Is this still a problem with the release?

Possibly. But because I have everything in addons.cfg I wouldn’t notice.

To be more precise: apt as the tool for update will ask before overwriting any manually changed file, and more… if choosing to overwrite, the old file will be renamed to <filename>.dpkg-old, while the other decision would result in a new file with <filename>.dpkg-dist, so in case of update, you don’t need a backup to prevent data loss. :slight_smile:

1 Like

And just to add to the discussion, you will always want to copy your content to the new file, whether you say yes or no during the apt-get as when this happens it is usually because something was added, removed, or the format of the file has completely changed and the old version of that file may not work as is.

A couple of months on, I’d like to revisit this.

I’ve gone docker…and will use svn to populate the conf directory. That bit I’m pretty happy with and I can happily move between machines, and install all my addons form addons.cfg.

The other bit though is all my zwave channels/things and persistent mapdb data that live in userdata.

I like to retain this as I move machines, should I be pulling that from svn as well, or should I be trying to keep in in sync some other way? it tends to create permissions issues

I use git for my source control but the same concepts should apply. I include userdata as well as conf in source control using the following .gitignore file.

userdata/*
!userdata/etc
!userdata/jsondb
userdata/jsondb/backup

Which basically says ignore everything in userdata except for etc, jsondb, and jsdondb/backup. Put another way, add etc and jsondb and the backup to source control. Ignore the rest.

However, I define all my add-ons to be installed using add-ons.cfg so I don’t know if there should be something else saved to preserve installed addons.

Ahh good that was similar to what I’d had anyway. I added mapdb though under persistence.
As there’s values in there like start/end times for timers.

1 Like

That is a good point. I should probably also include my mapdb. I’ve not had to restore from git in so long I doubt I would have noticed until something broke.

Yeah I did have issues getting the openHAB docker container to read those values.

It seemed to need to start, create its stuff, be stopped, then update the jsonfb mapdb overwriting anything that was creating automatically.

I wonder if the docker file might need some altering or if I need a “build container” script

If so it will be changes to entrypoint.sh.