I’m trying to move my openhab installation from an installed version (raspbian) to a dockerized version.
I thought this is possible, however, backup/restore does not work as it restores a lot of files with paths /var/log/openhab2 instead of /openhab/userdata (docker)
Can anyone tell me how to do this? I assume just replacing the paths is not enough…
this is definitely possible. I moved some weeks ago from my Pi3 (OH2.3 openHABian installation) to a container on my NAS.
But for me it also not worked to do this with the backup&restore scripts and some manual effort was needed. I’m not sure I remember all steps but I roughly performed the following steps:
Make backup on Pi3 with the backup script
Moved the created zip to my desktop and unzipped
Setup a new container on Synology
Started this container once without any restored files
Moved the files step by step from the backup to the container volumes
for userdata/config I only kept habpanel.config
for userdata/etc I compared all files from the container with my backup (via VS Code compare function) and decided for each and every file which version to use (for most of them I think I kept the version from the container)
I ignored all other folders in userdata
Important: If you use UI based config you also must keep the userdata/jsondb files with things, items, etc. (I only use text-based config and thus ignored these)
Moved conf and checked for path’s or IP’s to change (e.g. when using EXEC Binding)
Hint: As a first shot I tried to start with moving all conf and userdata files from the backup to the container but this led to a not working container. Not sure what exactly was the issue but I assume some files in userdata prevented the container from starting, that’s why I did it step by step
I’m very interested in your solution because it looks much easier than comparing, replacing, copying files. But I’m not that familar with docker to directly understand what you meen with your explanations.
May you explain in more detail what is necessary to do.
What I need to know exactly is to what destination I have to mount the /restore folder from the host (edit: I found in your command. Destination must be /openhab/runtime/bin/restore/restore/ ) and how and where I can replace the command in the container.
Currently I have running a OH3 directly on RPi and will move/migrate it into a Docker container. What I did until now is to prepare a backup by the openhapb-cli backup command. Also I set up a containter by a docker-compose.yml. Here is a snipet of the content:
Thanks @hannibal29 - worked like a charm! I moved my OH3 install from Docker on my main computer to Docker on a Raspberry Pi without issue. The Pi took a long while to load on first boot (expected), but all transferred across fine, including API keys for Nest, openHAB.org, etc.
I’m trying to do this but I can’t find where the data is that it uses in my openhab container to replace the files … The path / var / local / containers-data / openhab / does not exist for me.
Those paths are created during first run of your container with openhab. However, if you are migrating from system native openhab (installed on a native os) you should create those paths by yourself seeded with files from your current openhab installation. Then you run the container with binded volumes pointing to this paths.
you should have a folder on the host system called restore from where you start the docker container.
For me it’s this folder structure:
pi@raspberrypi:/opt/openhab $ ls
addons backup conf docker-compose.yml restore userdata
every time you start the docker container it will restore the files from restore/restore.zip. unless you remove the restore/restore.zip file from the host system.
you can run the command to store the backup in the additional mount available ./backup/backup-latest.zip: