"Howto" update from OH 4.3.x 32bit to OH5 64bit on Pi

Hey,
I was faced with the task of updating my setup to OH5. I was on a Raspberry Pi with 32 bit and therefore first had to convert the system to 64 bit.
For me, as someone with no real knowledge of Linux, looking for the individual commands wasn’t exactly easy. So I’ll summarize it now for anyone who might feel the same way as me.

Before you start with your system, prepare a new(!) SD Card with the latest openhabian for Pi 64bit.
Make sure your Pi is at least a model 4 with 2GB RAM or (better) more.

Download the Raspberry Pi Imager here
Select your model
Select the OS. “Other specific-purpose OS” / “Home assistants and home Automation” / “openHAB” / “openHABian (64 bit)”
Select your SD Card and let it write the file.

In the meantime prepare the running system.

First step is to backup the config with the build in backup tool.

Log in via ssh. On windows you can use the cmd with this command:

ssh openhabian@yourIP

pwd: openhabian

I use a NAS as location for the backup so it is stored not on the SD. Alternatively you can copy the backup file via a networkshared folder.Then skip this part.

This is how I mounted my NAS as a folder.

First create a directory where your NAS will be mounted:

sudo mkdir /var/FOLDER

After that mount the folder:

sudo mount -o username=USER,password=‘YOURPW’ ``//Your.NAS.IP.ADDRESS/FolderNAS`` /var/FOLDER

Backup the config like this:

sudo openhab-cli backup /var/FOLDER/FolderNAS/backup.zip

After that I would recommend to update the system via openhabian-config the to the latest version. In my case it was 4.3.5

sudo openhabian-config

If this was successfull and everything is working as expected, make a backup again.

sudo openhab-cli backup /var/FOLDER/FolderNAS/backup_2.zip

Now stop the openhab Service with:

sudo systemctl stop openhab.service

And shutdown the system with

sudo shutdown

After the system is down, remove the SD Card and keep it. If the update won’t work you still got your working OH4 setup on this SD.

Now insert the new sd, after it was successfully written by the Pi imager, into your Pi and power it up.

Wait for about 15min.

Connect to your Pi via ssh like before.

If the Pi uses the same IP like it did before, there will be a warning when you try to connect via ssh because the shh keys changed.

Delete the old key in the file

DRIVE:\Users\YOURUSER.ssh\known_hosts

and connect again.

Now we need to roll back the version so it will match our old 32 bit installation.

Check the available versions:

apt-cache showpkg openhab

Now use the version your 32bit system was updated to. E.g 4.3.5

sudo apt-get install openhab=4.3.5-1 openhab-addons=4.3.5-1

After this was done you got a 64bit system with the same version as your 32bit system.

Now restore the backup:

sudo openhab-cli restore /var/FOLDER/FolderNAS/backup_2.zip

Confirm the restore with yes.

Now the system should be running the same like it did with the other 32bit SD card.

If yes you can now finally update to the latest OH5 Version with the

sudo openhabian-config

If openHab won’t be running, start the service with

sudo systemctl start openhab.service

Hopefully this will help someone. I wish I have had something like this.. haha.

Best regards
Dirk

3 Likes

Detailed description, which works!

I want to add you don’t need to access a NAS (it is recommended, if you want to backup your openHAB regularly, of course!). But if you have another backup solution in place you could do as Dirk described, but use a FTP-Client to handle backup/restore from your PC/Mac like this:

  1. create backup either via openHABian option or via CLI (e.g. sudo openhab-cli backup /root/backup_2.zip
  2. use an FTP-Client and connect to your PI with the openhabiancredentials
  3. download the zip to your local PC/Mac
  4. spin up the new PI with OH5 SDcard
  5. use FTP-Client and upload the zip (e.g. to root or to /var/lib/openhab/backup, which is the typical location for openHABian backups)
  6. restore via CLI or openHABian
1 Like

Note that you can edit openhabian.conf before that first boot with the new 64-bit SD card. There you can configure the version of OH you want to install and you can put the backup on the SD card and tell openHABian to restore the backup. That will save a couple of steps. Details are in the openHABian docs.

2 Likes

Oh this is nice to know. Wasn’t aware of the ftp option as I am using a NAS from day 1 :see_no_evil_monkey:

Wow this would be much easier…never heard of that, sorry.

This is what I’ve found. Would this be correct?

“Change the branch to clonebranch=openHAB4 in /boot/openhabian.conf

“Rename the backup file to initial.zip and put it in /boot/” openHABian scripts will do the restore.

1 Like

Yes, assuming you pulled those from the docs. The change to openhabian.conf tells openHABian what version of OH to install and the presence of initial.zip tells it to use that zip file as the initial verison of the configs to start with.

Do you mind sharing the link to the docs? I’m having problem finding it. I want to understand why openHAB4, not just openHAB (the default option).

1 Like

OK, thank you! I found it, but it tells a slightly different story: “initialconfig=“/boot/firmware/initial.zip”“ so the backup should be in a different location? I could not place it there anyway due to the lack of space. Also nothing about openHAB5? Anyway, I fired the vanilla version and will be restoring config when it boots.