OpenHAB2 Migrating from Windows to Linux

I have Win 7 mini PC that runs OpenHab 2.4.
I have also set up 2 Raspberry Pi-es on remote locations with OpenHab, so I am familiar with Linux.

Win_Linux

I am planning to use Pepermint OS on the same mini PC but on another drive now…

I have attempted to backup OH2 on W7 but it returned an error that it can’t backup?

Lately, I have taken some of my devices, that connect via MQTT to OH2, to an event and I had to clone some of the W7 OH2 functionality to OH2 on RaspberryPi.

So I copied conf and org.eclipse.smarthome.core.thing.Thing.json to appropriate locations locations on Raspberry ( /etc/openhab2 and /var/lib/openhab2/jsondb )

BUT I had to fork the org.eclipse.smarthome.core.thing.Thing.json (set up different MQTT broker manually) to make it work, as any changes that I did in Paper UI didn’t persist after OH2 restart.

I also noticed that the mosquitto broker was way more responsive (time<5ms) on Raspberry in comparison to the embedded broker (time>500ms), not sure why, so I changed it, I used OH 2.5 on Raspberry though.

These were my struggles with migration to Linux, now how to mitigate them properly without hacking and forking them to make it work, as Paper UI config on that forked Raspberry setup isn’t persistent.

Can anyone suggest how to migrate Thing.json properly as I have most of the OH2 Things(MQTT devices…) configured via Paper UI, others like rules, Items, and sitemaps I have in the text config.

Thanks,
Matej

The documentation tells you the proper way to back up the configuration. It is not just by copying the JSONDb files.

I also looked in windows documentation, but i can’t see exact procedure what to do in case win oh2 script doesnt work, would copying whole userdata to linux even work, I know it works Win to Win and Linux to Linux. I can’t see working scenario with that information yet.

Thanks, @Bruce_Osborn for fast response
If i missed something, i appriciate sugestions…

Can you give us the details of the error you saw when you tried to back up please. What commands did you use and what was the output?

I’m not certain but I think you can restore a backup from Windows on a Linux install. There is a backup.bat script you can run to generate the backup on Windows, copy the file to the Linux machine and run openhab-cli restore.

I don’t understand what you mean by “forking” the jsondb file. Just copying the file should be sufficient but you need to do so while OH is not running and you have to make sure the file permissions are correct after the copy.

Hi
@higgers
That is the error I get on windows when I start backup.bat, it seems it needs a path, not sure which one…

@rlkoshak
By forking I mean - openhab didn’t write changes from Paper UI to thing.json at all so I did manually to make it use another MQTT broker…

Hm is it possible that openhab doesn’t have permission to edit thing.json on Linux, but I have done chmod -R 777 on jsondb directory for user pi (I installed OH via repository).

I will check what permissions it has oroginally when openhab makes thing.json

Matej

And what user is OH running as? If installed via apt, or if you followed the full manual instructions than it’s running as user openHAB, not pi.

Installed via apt … Can that thing.json file happen to have less permissions (so OH can’t modify it)as it was copied directly from windows to jsondb dir on Pi, after permissions were changed to the directory…

I will check these permisions when i get to the Pi tomorow … it is on remote location now.

Any idea how to fix backup.bat on windows that doesn’t work?

Matej

I’ve never run oh on Windows and don’t even have a Windows machine at home anymore to test it on.

If you installed via apt than the openhab user needs permissions to read that file. If yo called the files over it’s probably owned by use pi and the openhab user does not have permission to wire to it.

3 Likes

You can look at your environment variables on windows. Look for the openhab variables, copy those directories somewhere.

Then run the bac kup script on linux you will see what files get backed up. You can manually ooy those from your windows fi les.

For sure you need the conf directories and files. As well as some or all of the user data.

1 Like