How to restore or rebuild Openhabian and loose as little as possible

So, I gotten to the point that OH won’t start. This is the result of trying to get back to a running system after installing a daily snapshot that broke MQTT.

Various attempts were made to remove and re-install OH. Status is it was running 2.5, now there is some buggered version of 2.4 on the raspberry pi.

This is the output of " sudo journalctl -u openhab2 -b" when attempting to start OH:

 sudo journalctl -u openhab2 -b

Apr 05 13:04:24 openHABianPi karaf[5067]: !SESSION 2019-04-05 13:04:24.439 -----------------------------------------------
Apr 05 13:04:24 openHABianPi karaf[5067]: eclipse.buildId=unknown
Apr 05 13:04:24 openHABianPi karaf[5067]: java.version=1.8.0_152
Apr 05 13:04:24 openHABianPi karaf[5067]: java.vendor=Azul Systems, Inc.
Apr 05 13:04:24 openHABianPi karaf[5067]: BootLoader constants: OS=linux, ARCH=arm, WS=gtk, NL=en_US
Apr 05 13:04:24 openHABianPi karaf[5067]: !ENTRY org.eclipse.osgi 4 0 2019-04-05 13:04:24.440
Apr 05 13:04:24 openHABianPi karaf[5067]: !MESSAGE Error reading configuration: Unable to create lock manager.
Apr 05 13:04:24 openHABianPi karaf[5067]: !STACK 0
Apr 05 13:04:24 openHABianPi karaf[5067]: java.io.IOException: Unable to create lock manager.
Apr 05 13:04:24 openHABianPi karaf[5067]:         at org.eclipse.osgi.storagemanager.StorageManager.open(StorageManager.java:698)
Apr 05 13:04:24 openHABianPi karaf[5067]:         at org.eclipse.osgi.storage.Storage.getChildStorageManager(Storage.java:1776)
Apr 05 13:04:24 openHABianPi karaf[5067]:         at org.eclipse.osgi.storage.Storage.getInfoInputStream(Storage.java:1793)
Apr 05 13:04:24 openHABianPi karaf[5067]:         at org.eclipse.osgi.storage.Storage.<init>(Storage.java:132)
Apr 05 13:04:24 openHABianPi karaf[5067]:         at org.eclipse.osgi.storage.Storage.createStorage(Storage.java:85)
Apr 05 13:04:24 openHABianPi karaf[5067]:         at org.eclipse.osgi.internal.framework.EquinoxContainer.<init>(EquinoxContainer.java:68)
Apr 05 13:04:24 openHABianPi karaf[5067]:         at org.eclipse.osgi.launch.Equinox.<init>(Equinox.java:31)
Apr 05 13:04:24 openHABianPi karaf[5067]:         at org.eclipse.osgi.launch.EquinoxFactory.newFramework(EquinoxFactory.java:24)
Apr 05 13:04:24 openHABianPi karaf[5067]:         at org.apache.karaf.main.Main.launch(Main.java:256)
Apr 05 13:04:24 openHABianPi karaf[5067]:         at org.apache.karaf.main.Main.main(Main.java:178)
Apr 05 13:04:24 openHABianPi systemd[1]: openhab2.service: Main process exited, code=exited, status=255/n/a
Apr 05 13:04:26 openHABianPi karaf[5177]: /var/lib/openhab2/tmp/port shutdown port file doesn't exist. The container is not running.
Apr 05 13:04:26 openHABianPi systemd[1]: openhab2.service: Control process exited, code=exited status=3
Apr 05 13:04:26 openHABianPi systemd[1]: openhab2.service: Unit entered failed state.
Apr 05 13:04:26 openHABianPi systemd[1]: openhab2.service: Failed with result 'exit-code'.
Apr 05 13:04:31 openHABianPi systemd[1]: openhab2.service: Service hold-off time over, scheduling restart.
Apr 05 13:04:31 openHABianPi systemd[1]: Stopped openHAB 2 - empowering the smart home.
Apr 05 13:04:31 openHABianPi systemd[1]: Started openHAB 2 - empowering the smart home.
Apr 05 13:04:33 openHABianPi karaf[5287]: java.lang.RuntimeException: /var/log/openhab2/openhab.log (Permission denied)
Apr 05 13:04:33 openHABianPi karaf[5287]:         at org.apache.karaf.main.util.BootstrapLogManager.getDefaultHandlerInternal(BootstrapLogManager.java
Apr 05 13:04:33 openHABianPi karaf[5287]:         at org.apache.karaf.main.util.BootstrapLogManager.getDefaultHandlersInternal(BootstrapLogManager.jav
Apr 05 13:04:33 openHABianPi karaf[5287]:         at org.apache.karaf.main.util.BootstrapLogManager.getDefaultHandlers(BootstrapLogManager.java:70)
Apr 05 13:04:33 openHABianPi karaf[5287]:         at org.apache.karaf.main.util.BootstrapLogManager.configureLogger(BootstrapLogManager.java:75)
Apr 05 13:04:33 openHABianPi karaf[5287]:         at org.apache.karaf.main.Main.launch(Main.java:244)
Apr 05 13:04:33 openHABianPi karaf[5287]:         at org.apache.karaf.main.Main.main(Main.java:178)
Apr 05 13:04:33 openHABianPi karaf[5287]: Caused by: java.io.FileNotFoundException: /var/log/openhab2/openhab.log (Permission denied)
Apr 05 13:04:33 openHABianPi karaf[5287]:         at java.io.FileOutputStream.open0(Native Method)
Apr 05 13:04:33 openHABianPi karaf[5287]:         at java.io.FileOutputStream.open(FileOutputStream.java:270)
Apr 05 13:04:33 openHABianPi karaf[5287]:         at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
Apr 05 13:04:33 openHABianPi karaf[5287]:         at org.apache.karaf.main.util.BootstrapLogManager$SimpleFileHandler.open(BootstrapLogManager.java:19
Apr 05 13:04:33 openHABianPi karaf[5287]:         at org.apache.karaf.main.util.BootstrapLogManager$SimpleFileHandler.<init>(BootstrapLogManager.java:
Apr 05 13:04:33 openHABianPi karaf[5287]:         at org.apache.karaf.main.util.BootstrapLogManager.getDefaultHandlerInternal(BootstrapLogManager.java
Apr 05 13:04:33 openHABianPi karaf[5287]:         ... 5 more
Apr 05 13:04:33 openHABianPi karaf[5287]: !SESSION 2019-04-05 13:04:33.911 -----------------------------------------------
Apr 05 13:04:33 openHABianPi karaf[5287]: eclipse.buildId=unknown
Apr 05 13:04:33 openHABianPi karaf[5287]: java.version=1.8.0_152
Apr 05 13:04:33 openHABianPi karaf[5287]: java.vendor=Azul Systems, Inc.
Apr 05 13:04:33 openHABianPi karaf[5287]: BootLoader constants: OS=linux, ARCH=arm, WS=gtk, NL=en_US
Apr 05 13:04:33 openHABianPi karaf[5287]: !ENTRY org.eclipse.osgi 4 0 2019-04-05 13:04:33.912
Apr 05 13:04:33 openHABianPi karaf[5287]: !MESSAGE Error reading configuration: Unable to create lock manager.
Apr 05 13:04:33 openHABianPi karaf[5287]: !STACK 0
Apr 05 13:04:33 openHABianPi karaf[5287]: java.io.IOException: Unable to create lock manager.
Apr 05 13:04:33 openHABianPi karaf[5287]:         at org.eclipse.osgi.storagemanager.StorageManager.open(StorageManager.java:698)
Apr 05 13:04:33 openHABianPi karaf[5287]:         at org.eclipse.osgi.storage.Storage.getChildStorageManager(Storage.java:1776)
Apr 05 13:04:33 openHABianPi karaf[5287]:         at org.eclipse.osgi.storage.Storage.getInfoInputStream(Storage.java:1793)
Apr 05 13:04:33 openHABianPi karaf[5287]:         at org.eclipse.osgi.storage.Storage.<init>(Storage.java:132)
Apr 05 13:04:33 openHABianPi karaf[5287]:         at org.eclipse.osgi.storage.Storage.createStorage(Storage.java:85)
Apr 05 13:04:33 openHABianPi karaf[5287]:         at org.eclipse.osgi.internal.framework.EquinoxContainer.<init>(EquinoxContainer.java:68)
Apr 05 13:04:33 openHABianPi karaf[5287]:         at org.eclipse.osgi.launch.Equinox.<init>(Equinox.java:31)
Apr 05 13:04:33 openHABianPi karaf[5287]:         at org.eclipse.osgi.launch.EquinoxFactory.newFramework(EquinoxFactory.java:24)
Apr 05 13:04:33 openHABianPi karaf[5287]:         at org.apache.karaf.main.Main.launch(Main.java:256)
Apr 05 13:04:33 openHABianPi karaf[5287]:         at org.apache.karaf.main.Main.main(Main.java:178)
Apr 05 13:04:34 openHABianPi systemd[1]: openhab2.service: Main process exited, code=exited, status=255/n/a
Apr 05 13:04:35 openHABianPi karaf[5396]: /var/lib/openhab2/tmp/port shutdown port file doesn't exist. The container is not running.
Apr 05 13:04:35 openHABianPi systemd[1]: openhab2.service: Control process exited, code=exited status=3
Apr 05 13:04:35 openHABianPi systemd[1]: openhab2.service: Unit entered failed state.
Apr 05 13:04:35 openHABianPi systemd[1]: openhab2.service: Failed with result 'exit-code'.

If there is a way to recover at this point I’d love to know.

Failing that. I have a OH backup from before the snapshot was installed. (sudo openhab-cli backup --full bckup-, so I don’t know how much of OH is there, but, I should be able to get my configs, .rules, .items, .things, persist files, etc. I think?) (I don’t have an image of the SD card…next time! :roll_eyes: )

The question is, where do I start and what steps I need to do to get back to the way it was.

I don’t find a openhabian image for 2.5 or 2.4. Does this mean I need to use a 1.x image? then go through al the updates to 2.5?

Or install raspbian image and install 2.4 with apt?

And, once that’s done, how do I get my backup overlaid onto 2.4?
(What does openhab-cli restore actually restore? For example, does this actually tell OH what bindings I had installed? I’m assuming I’l need to set up mapdb and influx again?)

  1. I’d first stop OH.
  2. Then Clear the Cache.
  3. Run openhabian-config and under 10 Apply Improvements and choose 14 Fix Permissions.
  4. Finally restart the RPi.

That should clear the locks problems and the file not found problems.

All of OH config is there. None of the external services you might be using are there though (e.g. Mosquitto, NodeRed, InfluxDB, Grafana, etc.).

If the steps above don’t work, the most expedient way may be to start fresh. Install openHABian again. Copy your openHAB backup to the newly configured image and run openhab-cli restore.

The version numbers of openHABian are independent of openHAB versions because openHAB != openHABian. openHABian is just a bunch of scripts to automatically configure your whole environment in a well known and stable configuration. openHABian itself installs openHAB using apt. You can choose in openhabian-config between the latest release (currently 2.4), testing (currently 2.5 M1) or snapshot (the latest build from last night) under 40 openHAB related.

See above, copy the file over to the backups folder (var/lib/openhab2/backups) and call openhab-cli restore.

Yes.

Yes for InfluxDB, no for MapDB. Everything needed for it will come over with the restore.

You should be able to get this current system back up and running without resorting to starting over from scratch though.

Thanks for the reply.

Result:

sudo openhab-cli stop
[sudo] password for openhabian:

A systemd service configuration exists...
Use 'sudo /bin/systemctl stop openhab2.service' to stop an openHAB service
Stopping any instance of openHAB...
/var/lib/openhab2/tmp/port shutdown port file doesn't exist. The container is not running.

No messages.

Result:

sudo openhab-cli start

A systemd service configuration exists...
Use 'sudo /bin/systemctl start openhab2.service' to start an openHAB service
Launching an instance in this terminal..
Launching the openHAB runtime...

                          __  _____    ____
  ____  ____  ___  ____  / / / /   |  / __ )
 / __ \/ __ \/ _ \/ __ \/ /_/ / /| | / __  |
/ /_/ / /_/ /  __/ / / / __  / ___ |/ /_/ /
\____/ .___/\___/_/ /_/_/ /_/_/  |_/_____/
    /_/                        2.5.0-SNAPSHOT
                               Build #1566

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown openHAB.

Error in initialization script: /var/lib/openhab2/etc/shell.init.script: session is closed
Error in initialization script: /var/lib/openhab2/etc/scripts/shell.completion.script: session is closed
Error in initialization script: /var/lib/openhab2/etc/scripts/shell.colors.script: session is closed

(it now reports 2.5 because the last thing I did was use openhab-config to select snapshot.)

Did you run step 3 above?

  1. stop OH
  2. Clear the Cache
    3. Fix permissions
  3. Then restart the whole RPi, not just openHAB.

I listed four separate steps on purpose.

1 Like

@drmacro use command sudo reboot for this step.:wink:

1 Like

Haha…funny. :smirk:

I do use that when I’m in a hurry or lazy (the latter most of the time…:relaxed:)

But, old habits die hard, and I was “lurned up” in the old UNIX ways, so typically muscle memory goes with:
‘’’
sudo shutdown -r now


Old dog...old tricks. :sunglasses:

Well, my bad, I saw the 4th step, but, with all the errors I didn’t complete that step.

I re-did ALL 4 steps and there seemed to be a instance of OH running but nothing in the logs.

I looked fro my .thing, .items, etc. and they weren’t there.

So I noted this directory was also missing, but my backup zips are in ~/openhabian (maybe different on openhabian, which is how this pi was built originally?), so I did a restore from the latest zip and now even MQTT is working. (Presence of phones via arping seems buggered, have to look at that.)

Log shows this error, not sure what’s from:

2019-04-06 08:25:39.714 [ERROR] [ersey.server.ServerRuntime$Responder] - An I/O error has occurred while writing a response message entity to the container output stream.

org.glassfish.jersey.server.internal.process.MappableException: org.eclipse.jetty.io.EofException

Thanks again @rlkoshak !!!

Not sure if this is related to this whole recovery or not.

I have an item that is used in several rules. That item shows under items in PaperUI, but I can’t edit it (the fields are greyed out).

I don’t see any errors in the log with reference to it. But, it is not defined in any of my .items files.

I’m not sure what the error is but you can try deleting the item from PaperUI, add it to your items file and restart OH. If you still get the error, clean the cache and reboot OH.

This may or may not fix the error but you could rule out the item as the cause.

Well, that’s rub…there is no error being reported in the logs. And, rules that use the item do appear to work.

I’d like to know what Paper UI is trying to tell me by having the Item properties grayed out.

All I can suggest is PaperUI thinks it is unable to edit that Item. I couldn’t tell you why. Typically, Items defined in .items files will have all the entries grayed out in PaperUI.

Yeah, that’s what I thought…but, the item is not defined in item files…hmm.

Edit: duh…found it, in the item file I didn’t expect it to be. Should’ve done a find in files to begin with :roll_eyes: