[SOLVED] All Things lost from openHab

How to watch and look through logging might help you filter out the noise should you need to.

One thing to realize is that OH periodically writes out to the JSONDB, including when OH closes down. If OH ran out of heap while it was in the middle of writing to the JSONDB, or if you kill the process while it is writing to the JSONDB, the DB will become corrupted.

I thought it would be something like that in my case.

Nice post on the logs.
Maybe you could add a part on less instead of tail and the build in search?
I always recommend less, you can scroll up and it has other useful navigation keyboard shortcuts.
Granted, for piping into grep it doesn’t matter and maybe even uses a bit less system resources.

My event logs don’t show any sign of anything weird/broken, except they stop a few days ago.
Around the same time the openhab log starts showing out of memory exceptions on every action openhab was taking (polling my devices, sending stuff to influxdb,…).

So yeah, useless to identify the cause of the out of memory exception. I’ll see if it returns, if so, I’ll remove the HTTP binding and wait again for a few days.

But things are working again as they should with the backups

You just need to pipe the grep into the less. It’s nearly impossible to write a comprehensive tutorial on this sort of thing. It’s turn into a huge text processing on Linux tutorial and I’m not up for that.

Well you’re right. It is already a great post none the less

I don’t understand why this thread marked as solved. Is there anyway to fix or improve it, sometimes I remove things but it’s not removed in thing json db files, and when i restart a bundle, my things lost all channnels. Any advice or trick to makesure things are synchronized???

You first need to unlink all Channels from the Items for that Thing, then remove the Thing.

What? Please describe step by step what you are doing and check your openhab.log when this occurs. And please provide more information about your setup:

1 Like

Because the original poster flagged a post as the solution to his posted problem.

You are describing a different problem from the OP. Please answer sihui’s question, and perhaps open a new thread.

Hi! I can confirm that this bug is still round and now if wipes out the backup as well. My Things was gone when I restarted after OH2 stopped responding. The backups for Things database are all 0 bytes.

Any news on a solutions/fix for this?

It could be discussed but I mean that this is wrongfully marked as solved, the fix for the symptom is solved (or was) but not the problem itself.

We are sitting with a not working alarm system, watering system, lightning system and automation system…not in ideal situation :stuck_out_tongue:

Best Regards
Emil

RPi user? SD card wearing out?

Thanks for a quick answer sihui!

I use RPi :slight_smile:

No I don’t think that the SD is the problem, everything else runs fine.

Thinking does not help, test it.

I was just trying to be polite, not wanting to sound superior or rude.
I am 100% sure that it is not the SD as everything else runs, SD passed checks and other backups ea. Items have been successful at the same time of later.

Back to the problem;

Can the Things be recovered when the database has not done the backups correctly?

Can I manually create all Things again with the same names and the Items will work with them?

Best Regards
Emil

This thread is marked as solved, because my original question is answered. For me the issue seems to be related to OH or server shutdown, not to some file corruption, etc… That’s why I was able to restore from backup.

You can recreate the jsondb manually, it is a textfile, however not recommended, you can run into errors easily (I did this when I had to make some changes which was easier than doing in PaperUI, but I strongly won’t recommend this).
If you have a backup use it, extract the db from it…
Basically, don’t run OH (especially if you have a huge system which has crucial automations in it - ie.: you can’t live without it) without any backup. Do some manual or (better) automated backups, daily, weekly, monthly…

1 Like

Everything else what? Other stuff running on the same RPi?

Do you have a valid backup? If so I think it is just a matter of replacing your jsondb

I’m going to guess yes but I am guessing

I don’t see how OH could ever cause this to happen unless the copying of the “live” JSON files somehow failed (hence sihui’s comment, also note that when an SD card wears out all the tests you performed could and usually will pass and the fact that other stuff is still working is irrelevant, a worn out SD card just silently and slowly starts to gather weird behavior like copying a file from one location to another results in a zero length file at the copy, and maybe not every time, the files could have been zeroed out by a file system corruption caused by a power loss as well). Once OH copies the file it never touches it again. So the original copy command to create the backup must have failed, or something else came through and deleted the file contents.

If by recovered you mean recreated than yes.

Or automatically discover them again too. Just make sure to use the same ID for the bridge (e.g. MQTT Broker Thing, Zwave Controller Thing) and al the discovered Things will get the same ID they had before also.

Unfortunately I had problems with some bindings (which I can’t recall now precisely) that if configured from PaperUI, the ID is just a generated hash in general and you can’t explicitly change that in config, nor influence this behaviour. That’s why manually editing the jsondb was needed for me…

Yes you can when it’s first created.

image

Replace the randomly generated String with what ever you want it to be.

image

How?
If it’s auto-discovered, you can only click the blue tick, and you presented with a simple dialog, where you can only change it’s name…
How can you get to this page if it is not created manually but auto-discovered?

Thanks Kristof, I misunderstood your main question. I thought it was about why everything disappeared but you wondered how to restore it :slight_smile:

Why it happens is still a problem and that’s what I’m trying to find out :slight_smile:

Read my posting above again.

The name of the Thing is generated from the name of the Bridge Thing it is discovered under. If you name the Bridge Thing the same (e.g. zwave:serial_zstick:controller) than all the Things discovered through that Bridge will be named the same as well (e.g. zwave:device:controller:node9).

You used to have to rediscover all the Things every time you updated the Docker container (thank goodness that isn’t required anymore). I used to have to rediscover my Things every few days. I know this works.