Problems Migrating OH3 on a Windows PC to a Raspbury Pi running OpenHabian

Over the past few weeks, I have built a fairly large OpenHAB 3.3 system on my Windows PC. I now want to migrate it to a Raspberry Pi 4 running OpenHabian. This has become a frustrating experience as nothing I have tried has worked. Before anyone asks, I have read the documentation, searched on the community and looked at a number of videos. This is where I am now.

OpenHAB 3.3 is fully configured and works on my PC.

I have flashed an image of openHABian v.17.3 onto a 64Gbyte SD card with Etcher. This will boot correctly on the Pi and give me a working, but unconfigured openHAB server, so I know that the hardware and my network are both working correctly.

1. Using Initial Configuration.

My first approach was to make an initialisation zip (initial.zip) and place it on the boot partition of the SD card as outlined in the documentation.

Initial configuration

You can have openHABian import a working openHAB configuration right from the start at installation time like when you migrate or reinstall: make the initialconfig parameter point to either a file or URL. Note that you can only place config zipfiles on the 1st (Windows) partition, and that partition will finally be accessible as /boot . So a filename would need to be /boot/xxx.zip . Default is /boot/initial.zip . So if you have a openHAB configuration backup zipfile (created e.g. by using menu option 50), put it to the E: device that the first partition of your SD card shows up as on a Windows PC and change its name to 'initial.zip

My assumption from reading other posts is that the initial.zip file should contain both USERDATA and CONFIG directories. When I zip up these two directoreis, I get an initial.zip file which is 460MBytes in size. When I try to write this file to the 1st (Windows) partition, I get an error message because the boot partition is only 256MByutes in total of which 50MBtes is already used.

I have tried reformatting the SD card under windows to create a 2GByte initial partition, but Etcher ignores this and reduces it to 256 Mbytes. I have also the Raspberry Pi Imager which loads openHABian correctly, but again the 1st partition is only 256MBytes so I cannot write the initial.zip file to it. As I can see no way of creating a larger partition, this is a dead end

2. Using cli backup

On my Windows system, I used a console session to try to run the openhab-config tool to create a backup file that I could move with WinSCP to the Pi. I started the console with the default username (openhab) and password (habopen).

This is the console;

What password do I use? I have used “habopen”, “openhabian” and my administrator password for the windows OpenHAB server, but none work.

3. Create a backup using a zip tool.

On the Pi running openHABian, I can use PUTTY to access the console. I can now run

sudo openhabian-config

with password “openhabian” to open the Configuration Menue. I can now use option 50 to create a new backup file

/var/lib/openhab/backups/openhab-backup-22_11_09-14_38_01.zip.

I the used WinSCP to copy the file back to the PC. So far so good. I have already created a initial.zip file which I could copy back to the same directory on the Pi. However if I try this I get the following error

So I cannot write the backup file to the Pi.

Can anyone help to find a way through this. It strikes me that the migration of a system from a development machine to another for deployment should be simple. What am I missing.

PJG

You’re thinking too complicated! :wink:

I think, you’re mixing the “Console”, which is a administrative tool for the application server running openHAB. This “console” is the same regardless of your operating system. With this you can’t simply export a configuration, but you have access to the configuration of the application server (normally you don’t want to do anything in it, only if asked here on the forum or for some veeeeery special tasks)

What you are looking for is a way to export your OH3-configuration into a ZIP-file from a installation running on windows. There is a “backup-Skript” within the installation, which you can reach via a simple commandline command in windows. So you open “cmd.exe” (aka “shell”) in windows, and then you export your configuration running a batch-file called backup.bat. This one is located usually under YOUROPENHABFOLDER/runtime/bin/backup.bat - you just have to call that batch-file and it will create a zip-file for you.

Then you copy that very zip-file (via WinSCP) to your openHABian - at best into /var/lib/openhab/backups/.

After that you can simply use openhabian - Menu 50 to restore your configuration, which means the Windows-configuration is now identical to your openHABian configuration.

PS:
And please read some info on “how to use linux” - the password for “sudo” is the “administrator” password (initially “openhab”), which has nothing to do with a password for the openhab-cli console or even with the OH3-GUI password… I know, this sounds crazy for an absolute beginner, but eventually you’ll get it sorted!

Thanks for such a fast reply. The first part is now clear. I have used backup.bat to create a backup on my windows machine. However I still get Permission denied Error Code 3 when I try to copy this file to the /var/lib/openhab/backups directory with WinSPC. I have started WinSPC with username:openhabian and password:openhabian. Do I need to login with a different username and password to allow writing to the backups directory.

PJG

nope. the openhabian-user should have access to that file.
try sudo openhabian-config and then use “fix permissions” in menu “14”. After that you should be able to write in that directory.

Fix permissions worked so I can copy backup.zip file. However, when I run option 51 to restore the file I get an Error or Interruption occurred :thinking:, plus a suggestion to read a lot of stuff about debugging. I will try again tomorrow.

PJG

Almost.

sudo is a command to ask the operating system to “run this command using the root user (or some other user if the -u option was used.” To determine whether or not that’s allowed it usually needs two things:

  1. authentication of the user calling sudo
  2. authorization

For 1, it will ask the user to enter their own password. So if you are logged in a openhabian, you use openhabian’s password to prove that you really are user openhabian.

For 2, it looks in the sudoers config file to see if the user is permitted to run sudo for that command.

It’s not root’s password. On an openHABian system, root doesn’t even have a password. The only way to run a command as user root is through sudo. This is a security and safety measure.

Thank you for the password explanation. I have managed to access my Raspberry pi with Putty and run the openhabian-config tool, but I still get errors in trying to load the backup file created on my PC system. So either openHab on the PC and openHabian on the pi are not totally compatible, or I have in some way corrupted the PC installation.

In the end I decided to simply use the UI to recreate my system on the pi. Funny, the only things I could cut and paste between the two machines were my custom widgets in YAML. I would like to cut and paste BLOCKY scripts as well, but that is not possible. In any case, I have used the exercise to tidy up a lot of the naming of parts which should make it easier to maintain in the future.

PJG

Yes it is. In the rule page there is a “Code” tab. You can copy and paste that between the systems.