Migrating OH3 from Linux to Windows: Script Errors, Main UI Black Screen/Won't Load

Hello,

I have been happily using openHAB for about five years now, always from a Linux server, and usually having setup everything via openHABian. I recently decided to switch my main home automation server from Linux to Windows 11 and am having a bit of difficulty getting everything migrated and setup. I’m also slightly confused about how to perform a number of tasks on Windows that I am easily able to complete on Linux.

I have a fresh installation of openHAB 3.3.0.M5 - Milestone Build running on my Windows 11 machine and I successfully setup OH to run as a Windows service. Next, despite knowing better, I decided to attempt to restore an “openhab-cli backup --full” backup .zip from my Linux installation to the new Windows server and have run into several challenges. My first question is - why are so many of the “openhab-cli” commands missing from the “C:\openhab\runtime\bin\client.bat” command-line interface? In fact, all of the “openhab-cli” commands are absent. How do I clear the cache? I did finally find information about backing up/restoring for Windows OH but it was not in the same place as the general backup/restore instructions (for Linux). I understand that Linux is probably the more-recommended way to go (and believe me, I much prefer Linux over Windows) but I really wish the Windows documentation for openHAB just had a few more of the basic details. The setup guide for Windows is lightyears improved from where it was several years ago (I have played around with installing on various Windows servers at times/before) but I really feel a lot of essential details are still not clearly stated/are difficult to find, or at least are missing if one is accustomed to the Linux-based OH way of doing things.

Anyway, I did find the restore.bat script and attempted to run this but ran into more problems. First of all I wasn’t certain what syntax to use exactly to point to my .zip file and tell it I wanted a full restoration. I tried to look at the actual code in the script itself but it seems to be outdated and mentions openhab2 in the example. I went ahead and made a “C:\openhab\backups” folder and dropped my .zip file from Linux there and then ran the restore.bat script. It found the .zip file and began unzipping it to a temp location but then became grumpy that there was not already a “things” folder existing in this temp location and errored out:

##############################################################################################################################################
#  Could not unzip C:\openhab\backups\openhab-backup-22_05_19-05_26_10.zip to C:\Users\richard\AppData\Local\Temp\openhab\restore - exiting  #
##############################################################################################################################################                                                                                                                                      PrintAndThrow : Cannot find path 'C:\Users\richard\AppData\Local\Temp\openhab\restore\conf\things\' because it does not exist.            At C:\openhab\runtime\bin\restore.ps1:127 char:24                                                                                         + ...      return PrintAndThrow "Could not unzip $ArchiveName to $TempDir - ...                                                           +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,PrintAndThrow

Error restoring from C:\Users\richard\AppData\Local\Temp\openhab\restore

Ok, fine mr. grumpy script… I’ll manually unzip everything for you… :face_with_symbols_over_mouth: and so I did, and re-ran the script. It went a little bit further but then started complaining about illegal characters and errored out again:

##############################################################################################################################################
#  Could not unzip C:\openhab\backups\openhab-backup-22_05_19-05_26_10.zip to C:\Users\richard\AppData\Local\Temp\openhab\restore - exiting  #
##############################################################################################################################################
PrintAndThrow : Exception calling ".ctor" with "1" argument(s): "Illegal characters in path."
At C:\openhab\runtime\bin\restore.ps1:127 char:24
+ ...      return PrintAndThrow "Could not unzip $ArchiveName to $TempDir - ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,PrintAndThrow

Error restoring from C:\Users\richard\AppData\Local\Temp\openhab\restore

Grrrrr. I tried to manually edit the .bat to see if I could comment out the unzipping part (since I’d already manually done this) but I only spent a few minutes attempting to look through the restore batch file (and the other restore scripts/powershell scripts it apparently calls) before I gave up. Ok fine, I’ll just start from scratch then, not the end of the world… except now I can no longer load the main OH web interface after logging in to an administrator account - there’s nothing but a black screen. I tried different browsers, tried clearing my browser cache, rebooted, have no idea how to run an “openhab-cli clean-cache”. I did find online a suggestion to run the command "openhab:users clearSessions " which did complete successfully but I still am just faced with a black screen. Inspecting this black screen with my browser’s developer tools shows the following errors:

Failed to load resource: the server responded with a status of 405 (Method Not Allowed)
app.js:38 
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'locale')
    at u.loadRootResource (app.js:38:6286)
    at Array.<anonymous> (app.js:17:17689)
    at u.dispatch (app.js:23:1047)
    at u.dispatch (app.js:17:14920)
    at app.js:33:123522

I guess at this point I’ll just uninstall everything and start again, skipping attempting to restore from a backup. I just wanted to ask is it at all possible to restore from a backup .zip when migrating from a Linux to Windows openHAB installation? I realize that there might be some issues with regard to filepaths and so I was going to use Visual Studio Code to open the unzipped backup .zip folder and try my best to “find and replace… in files” any references to Linux file paths and then hopefully could re-zip the folder and try again from there? Probably still just best to start fresh?

How do I clear the OH cache from the command line on the Windows version of openHAB?

Thank you for any guidance and feedback!

  * OS: Windows 11 Pro 21H2 1000.22000.675.0
  * Java Runtime Environment: Zulu11.56.19-ca-jdk11.0.15-win_x64
  * openHAB version:  3.3.0.M5 - Milestone Build

openhab-cli is a wrapper around the scripts and bat files you find in runtime/bin. But there really isn’t openhab-cli on a manual install of openHAB and since the only way to install on Windows is a “manual” install (i.e.unzip everything into a folder is the installation).

For many, a move from Linux to Windows would be a step backwards for this and other reasons. You are much more on your own on Windows.

Yes if it’s not a full backup (i.e. you didn’t supply the --full option). Also, the versions of OH have to be the exact same versions. I’m pretty sure the restore is not smart enough to upgrade/downgrade the configs on the fly.