I’m sorry to bring up the old topic again. I have also migrated openHAB several times and would therefore like to add a little something.
With openHABian, I simply copied the SD card and then changed the host name accordingly and also made other minor adjustments to openHAB, which just points to the other host. You save the Zulu Java and openHAB installation. Maybe even a few configurations. I have also created some aliases that I use in the operation, etc. Maybe specific server configuration etc.
With virtual machines, you can theoretically proceed in a similar way and copy a VM. Possibly also create an image that can be reused for new instances. This would also be a standard process. The SD card images can also be retained. Not only as backups, but of course as installation images for new instances.
Otherwise, you can of course set up a system completely from scratch and then copy the necessary data. I leave the installations out of it. It depends on the system (Windows, Ubuntu, Raspbian).
Before each migration, it is generally recommended to create a backup. This is no different with openhab:
This possibility was mentioned, that you then simply play the backup.
sudo openhab-cli backup
...
Success! Backup made in /var/lib/openhab2/backups/openhab2-backup-21_07_05-03_54_49.zip
Restore openHAB then works with:
sudo systemctl stop openhab2.service
openhab-cli restore /var/lib/openhab2/backups
sudo systemctl start openhab2.service
I'll break it down using the example of Ubuntu Linux, how to do it manually:
sudo scp -r <user>@<ip>:/etc/openhab2/ /etc/
sudo scp -r <user>@<ip>:/usr/share/openhab2/addons/ /usr/share/openhab2
sudo scp -r <user>@<ip>:/etc/default/openhab2 /etc/default/openhab2
sudo scp -r <user>@<ip>:/var/lib/openhab2 /var/lib
sudo systemctl stop openhab2.service
sudo rm -rf /var/lib/openhab2/tmp/*
sudo rm -rf /var/lib/openhab2/cache/*
sudo systemctl start openhab2.service
sudo systemctl restart openhab2.service
sudo systemctl restart openhab2.service
I start from the target system. You connect to the system from which you want to transfer the data and copy it over via scp
.
Here is the explanation:
-
/etc/openhab2/: User configuration such as sitemaps, items, etc.
-
/usr/share/openhab2/addons/: manually installed add-ons that you did not install via PaperUI. These can be add-ons from GitHub or because you have disabled remote access and want openHAB to work without the internet as much as possible.
-
/etc/default/openhab2: The run configuration. For example, how much memory should be used. Possible adaptations are often necessary for Jython or also because of the Alexa binding.
-
/var/lib/openhab2: For bindings etc. that work via PaperUI, you must also copy this directory. Also so that all things created in PaperUI are available, as these are not stored in /etc/openhab2/.
I recommend clearing the cache and Tmp. Start and sometimes restart, because otherwise the import does not recognise all items, sitemaps, etc. and you then click on a group and the content is not displayed underneath. This is a well-known workaround.
With openHAB 3, it works largely the same. The only difference is that openhab2
changes in the path to openhab
.