Slow migration to Openhab3 and then migrating it from one host to another

I want to share my journey to migrate from OH2 to OH3 in order other find hints when googling for it. I did setup a second host to do a slow migration from Openhab2 to Openhab3. After I transferred/recreated all things and items, I migrated/fixed rule after rule. I could fix all issues by searching the forum, many of it where related to time like changing
now.getHourOfDay to now.toLocalTime.getHour and updated plugins like Mystrom and Gardena. Since I used sitemap and the native mobile app before, I wanted to stay with it. My sitemap was working in the browser on OH3 but not in the native app. Two issues there:

  1. I removed all frames and only used curly brackets to encapsulate elements (see here under blocks)
    Here an example where I use the group state from gLight to indicate a status of the group:
    sitemap:
Text item=gLight label="Licht" icon="light" valuecolor=["OFF"="black", "ON"="orange"] {
    Switch item=L_EG_A icon="light"
    Switch item=S_EG_B icon="light"
...
}
  1. I had groups defined in the new OH3 GUI. Those groups where not working in sitemaps. Well it working in the browser but not in the native app. When I removed those groups in the GUI and recreated them in text config, the native app start to work…
    Here an example of a group that I moved into a item-file instead of defining it in the GUI:
    items-file:
    Group:Switch:AND(OFF,ON) gPresence "Anwesenheit [MAP(unifi.map):%s"

Once finished I wanted to migrate the new instance back to my original host. I’m using an Intel NUC with Ubuntu 18.04.6 and Openhab 3.3.

Here the process I used:

Backup of my new Openhab3 installation (on my temporary host). I copy the config backup to S3 on AWS and disable openhab to start automatically (in case I will reboot the new host and create a potential conflict).

TempHost> sudo openhab-cli backup
TempHost> aws s3 cp /var/lib/openhab2/backups/openhab2-backup-yyy.zip s3://mybucket/oh3backup/
TempHost> sudo /bin/systemctl disable openhab.service
TempHost> sudo /bin/systemctl stop openhab.service

Removing old Openhab2 Installation:

OH2> sudo openhab-cli backup
OH2> aws s3 cp /var/lib/openhab2/backups/openhab2-backup-xxx.zip s3://mybucket/oh2backup/
OH2> sudo /bin/systemctl stop openhab.service
OH2> sudo apt remove openhab2
OH2> sudo rm -rf /etc/openhab2/
OH2> sudo rm -rf /var/lib/openhab2/

Preparing old host for OH3:
Includes changing the Openhab repos, updating Java and install OH3.

OH2> sudo rm /etc/apt/sources.list.d/openhab2.list*
OH2> sudo apt-get install openjdk-11-jdk
OH2> sudo update-alternatives --config java
-> choose Java11
OH2> curl -fsSL "https://openhab.jfrog.io/artifactory/api/gpg/key/public" | gpg --dearmor > openhab.gpg
OH2> sudo mv openhab.gpg /usr/share/keyrings
OH2> echo 'deb [signed-by=/usr/share/keyrings/openhab.gpg] https://openhab.jfrog.io/artifactory/openhab-linuxpkg stable main' | sudo tee /etc/apt/sources.list.d/openhab.list 
OH2> sudo apt-get install openhab
OH2> sudo /bin/systemctl daemon-reload
OH2> sudo /bin/systemctl enable openhab.service
OH2> sudo /bin/systemctl start openhab.service
-> run setup Wizard by connecting to OH-IP:8080

Restore Openhab3 backup:

OH2> sudo /bin/systemctl stop openhab.service
OH2> cd /var/lib/openhab2/backups/
OH2> sudo aws s3 cp s3://mybucket/oh3backup/openhab-backup-yyy.zip .
OH2> sudo openhab-cli restore openhab-backup-yyy.zip
OH2> sudo /bin/systemctl start openhab.service

→ be patient here!
After checking /var/log/openhab/openhab.log I saw that first the plugin where not installed but Openhab restarted automatically after throwing many errors to install all plugins, transformations etc.

The only issues I needed to fix where:

  1. Adjusting KNX things file to reflect my new local IP address
    Error was:
    2022-09-18 12:43:59.261 [ERROR] [Xnet/IP Tunneling 192.168.1.10:3671] - communication failure on connect
  2. Manually install openHAB Cloud Connector
    → openHAB Cloud Connector was not installed at all. However /lib/var/openhab/uuid and /var/lib/openhab/openhabcloud/secret where restored correctly.

Well done dear Openhab developers!