All Things Added with Paper UI gone

openhab2
Tags: #<Tag:0x00007f0155c884f0>

(Eamonn O'connell) #1

Hi All,

I had added a number of Things with the Paper UI: 1 with the network binding and another 4 or 5 with the Zwave.
Today, thanks to a couple of power cuts meant the raspberry pi was restarted a couple of times.

This evening something is not right (my shutters didn’t close), and I discover all Things have disappeared. Not one of them left. The bindings I had added are still there. The rules, items, and sitemaps defined in files still exist. But nothing works anymore because all the Things have disappeared.

Can anyone guess how this could happen? Was there some update that could have wiped the database?

Thanks,
Eamonn


(Antares2001) #2

Hello!

This has happened to me also two to three times already randomly after reboots / power cuts. Perhaps some database corruption?

Is there any suggestion, what kind of backup could help to restore things as quickly as possible, in case they disappear? Thought it does not solve the problem, but I think some backup/restore for OpenHAB could help in this and many other cases.


(Eamonn O'connell) #3

Happy to hear I’m not the only one !
The only idea I have so far is to redefine my Things in a .things file after the initial discovery with PaperUI.


(Eamonn O'connell) #4

Are you running Openhab from an sdcard by any chance ?
This thread is hinting its a hardware issue


PaperUI, Control no longer showing items after power failure
(Angelos) #5

For PaperUI discovered Things, you can backup the /var/lib/openhab2/ directory.
In there, you will find the jsonDB (in folder /var/lib/openhab2/jsondb) where OH2 stores (and creates and autobackup) your Items, Links, Things and other stuff that you manage via the PaperUI.

For manual configs, backup the /etc/openhab2/ directory.

Most likely: filesystem corruption that affected your /var/lib/openhab2/jsondb/org.eclipse.smarthome.core.thing.Thing.json file (check to see if it’s still there and if it’s readable. If yes, copy the contents, delete it, recreate it and paste the contents back).
It’s highly unlikely that a system update would wipe out your json database.


Storage of items authored in PaperUI
(Eamonn O'connell) #6

Thanks Angelos. Very useful indeed.
Do you know how the backups of the jsondb work? I only see a backup up taken this morning; is it a daily backup that wipes out the previous one?


(Angelos) #7

From the author of the jsonDB service for OH2 (@chris):

You can configure the Json Storage in PaperUI->Configuration->System->Json Storage

Here you can find more info on how the jsonDB works on OH2:

a) http://docs.openhab.org/administration/jsondb.html
b) Replacement of mapdb by jsondb
c) https://github.com/openhab/openhab-docs/pull/281/files (easier to read version: Here)

I need to implement © into (a)… I still haven’t done that and @ThomDietrich will shoot me soon :stuck_out_tongue:


(Eamonn O'connell) #8

Made for interesting reading. Thanks Angelos!

The pull request looks like a nice improvement to the docs - get busy :wink:


(Eamonn O'connell) #9

Angelo,

I took a look at where I can configure the Json Storage in PaperUI->Configuration->System->Json Storage
and I see a “Backup files” field. Am I correct to assume every time JsonDB writes to the file system it makes a backup?


(Angelos) #10

correct assumption. I think that it keeps up to 5 copies of each of the backed up file(s). The 6th (oldest) one(s) gets removed.


(Antares2001) #11

Hello @Dim

thanks a lot for those indeed very useful information. This will be very helpful.

One question I have is - why is it that JSON files are used as a database? Wouldn’t it be better to have, e.g., MongoDB (which uses JSON to store documents) running with OpenHAB (or to use a simple H2, which is damn fast and easy to use per Java project)? That would also be more robust against things like power outages, etc.

Best and thanks again!


(Angelos) #12

I don’t have the answer to this question. Imho, I think that the jsonDB storage service performance and low resource utilization is very good, especially for small “embedded” systems (like rPi3 etc). JsonDB replaced mapdb as the storage service in OH2 sometime ago (Nov '16).

It fits nicely in my opinion with the OH2 ecosystem. I am not a developer of OH2, so I am not the best to answer your question :wink:


(Rich Koshak) #13

Previously MapDB was being used and it was opaque and slow. Chris (our fearless zwave binding developer) did some experiments with JSON DB and found it solves two major complaints that the community had with MapDB.

  1. It’s slow
  2. It’s not human editable (i.e. doesn’t work well for backups and source control mechanisms like git)

I suspect services like MongoDB were not considered as something like this really belongs in an embedded database. MongoDB would be WAY overkill to store what amounts to a few dozen kilobytes worth of configuration data. Solutions like SQLite, H2, Derby et. al. all failed at no. 2 because they store everything in a non-human readable binary blob.

Do not underestimate no. 2. There was much wailing and gnashing of teeth over the mapdb solution which almost universally focused almost entirely on the fact that it was not human readable or editable.

Probably not. When a RPi loses power it can cause havoc with anything on your file system including databases.


(Antares2001) #14

Hi @rlkoshak

thanks a lot for the explanation. True, this makes perfectly sense. Well, and now I’ve actually learned something new which I’m very happy about :slight_smile:

Thanks!


(Eamonn O'connell) #15

@antares2001 have you considered an UPS for your RPi? I’ve attached a RavPower 26800mAh battery. No power cuts since, but it seems to work well.


(Antares2001) #16

Hi @Eamonn_O_Connell

thanks for the hint. I bought an external battery, but was not satisfied with it, as it took to long to switch from powered mode to battery mode, so the Raspberry Pi still turned off and immediately on again (so basically doing a reboot like after a power outage).

I will look at the one you suggested and give it a try.


(Eamonn O'connell) #17

Could be related: