It is external but that doesn’t mean unchanging. When the Docker container first starts up there is a script that runs to see if the files it has mounted to conf and userdata match the version of openHAB that will run in the container. If they don’t match, the script:
backs up $OH_USERDATA, putting a copy in $OH_USERDATA/backup
performs a clear the cache
only then does it start OH.
The script doesn’t touch $OH_CONF because it makes no changes there.
I know a lot about this as I was the one who first submitted this to the Docker repo.
If you perform an upgrade and something really breaks or you need to roll back for some reason:
restore $OH_USERDATA from the tar file that was created during the upgrade
restart the openHAB container with the older openHAB version Docker Image.
You will be rolled back at that point.
NOTE: this automated mechanism is not meant to be a replacement for taking backups. You should always backup your userdata and conf folders independently.
openhab-cli is not available when running OH in Docker. It really makes no sense to have it since you cannot directly access the command line of the container. But the equivalents of the backup and restore commands are:
docker exec -it <openhab container ID or name> runtime/bin/backup
docker exec -it <openhab container ID or name> runtime/bin/restore
Note that the file paths are those from inside the container.
For me, I prefer to spread out the upgrade so I practice upgrading early and often. The number of differences and amount of work that you need to do and therefore the risk of something breaking during an upgrade is less from one upgrade to the next when you upgrade more often. I upgrade one of my instances a couple times a week and the other one follows the milestones.
Thus, my overall risk of needing to spend hours and hours because of an upgrade is much lower than if I only used the releases.
But even then, there is a risk that something breaks. So I have the following:
If the update breaks something I need, I’ll just roll back to the previous version using the steps described above.
If the update requires a lot of changes like it did when we went from OH 1 to OH 2, I’ll create a copy of my conf and userdata folders, shutdown the production container and start up the upgrade container to work on it. When I’m done for the day, stop the upgrade container and restart production. When everything is working in the upgrade container, I simply delete the old Image, container, and config directories.
OK, Backing up is easy with docker. Just cp folders to a different location.
Would you guys go with a clean (empty folders) installation and add one binding and config files after the other to check if it is working (a lot of work, i guess) or is it good to go for update after backup?
Only if an in place upgrade failed big time. Then I might roll back and do a clean install. But I should say that in the fiveish years I’ve been running openHAB, I’ve only done that once in the move from OH 1.8 to 2.0. I don’t expect to do it again until the move from 2.5 to 3.0.
i started with a clean docker, restored my config, after that i get the following:
2020-01-01 15:10:11.319 [INFO ] [port.EventAdminConfigurationNotifier] - Sending Event Admin nofification (configuration successful) to org/ops4j/pax/logging/Configuration
2020-01-01 15:10:12.323 [WARN ] [org.apache.felix.fileinstall ] - /usr/share/openhab2/addons does not exist, please create it.
2020-01-01 15:10:12.328 [ERROR] [org.apache.felix.fileinstall ] - Cannot create folder /var/lib/openhab2/tmp/bundles. Is the folder write-protected?
2020-01-01 15:10:12.354 [WARN ] [raf.features.internal.osgi.Activator] - Error starting activator
java.io.IOException: Unexpected end of input at 1:1
at org.apache.karaf.util.json.JsonReader.error(JsonReader.java:337) ~[bundleFile:?]
at org.apache.karaf.util.json.JsonReader.expected(JsonReader.java:331) ~[bundleFile:?]
at org.apache.karaf.util.json.JsonReader.readValue(JsonReader.java:93) ~[bundleFile:?]
at org.apache.karaf.util.json.JsonReader.parse(JsonReader.java:58) ~[bundleFile:?]
at org.apache.karaf.util.json.JsonReader.read(JsonReader.java:52) ~[bundleFile:?]
at org.apache.karaf.features.internal.region.DigraphHelper.readDigraph(DigraphHelper.java:93) ~[bundleFile:?]
at org.apache.karaf.features.internal.region.DigraphHelper.loadDigraph(DigraphHelper.java:72) ~[bundleFile:?]
at org.apache.karaf.features.internal.osgi.Activator.doStart(Activator.java:146) ~[bundleFile:?]
at org.apache.karaf.util.tracker.BaseActivator.run(BaseActivator.java:312) [bundleFile:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_232]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_232]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_232]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_232]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_232]
2020-01-01 15:10:12.330 [ERROR] [org.apache.felix.configadmin ] - [org.osgi.service.cm.ManagedServiceFactory, id=39, bundle=10/mvn:org.apache.felix/org.apache.felix.fileinstall/3.6.4]: Unexpected problem updating configuration org.apache.felix.fileinstall.7979daf3-5f6e-413a-a48e-07bf17c27c2c
java.lang.RuntimeException: Cannot create folder: /var/lib/openhab2/tmp/bundles
at org.apache.felix.fileinstall.internal.DirectoryWatcher.prepareDir(DirectoryWatcher.java:647) ~[?:?]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.prepareTempDir(DirectoryWatcher.java:627) ~[?:?]
at org.apache.felix.fileinstall.internal.DirectoryWatcher.(DirectoryWatcher.java:179) ~[?:?]
at org.apache.felix.fileinstall.internal.FileInstall.updated(FileInstall.java:248) ~[?:?]
at org.apache.felix.fileinstall.internal.FileInstall$ConfigAdminSupport$Tracker.updated(FileInstall.java:378) ~[?:?]
at org.apache.felix.cm.impl.helper.ManagedServiceFactoryTracker.updated(ManagedServiceFactoryTracker.java:159) ~[bundleFile:?]
at org.apache.felix.cm.impl.helper.ManagedServiceFactoryTracker.provideConfiguration(ManagedServiceFactoryTracker.java:93) [bundleFile:?]
at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceFactoryUpdate.provide(ConfigurationManager.java:1253) [bundleFile:?]
at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceFactoryUpdate.run(ConfigurationManager.java:1197) [bundleFile:?]
at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:138) [bundleFile:?]
at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:105) [bundleFile:?]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_232]
i would like to have your advice how to do the restore correct
i have a new docker, all files are created in (conf/userdata), the mounted volumes have read and write permissons (subdirs are created during install)
openhab:latest is running i can access paperui … as it was lasttime
so, how do i get my configuration from my old instance running ? restore backup files …?