This solution is limited to PaperUI defined Things. If you are using .things files this document will not apply to you.
Where are the Things stored?
In a manual installed instance of OH are stored in a file in
For installed instances of OH (e.g. openHABian, apt installed, yum installed) they are stored in a file in
There may be several files in this folder. It should be obvious which one stores the Things, but if your Things have disappeared, you will want to do the steps described below for all the files.
Why did the Things disappear?
It’s hard to say. They may be corrupted. OH periodically writes out to the JSONDB files and if OH is killed (e.g. loss of power to the machine) before it completes a write then the file will be incomplete and likely malformed. If you are running off of an SD card, loss of power instead of cleanly shutting down can corrupt files. In rare circumstances, an SD card wears out causing writes to no longer take or completely take which can result in corrupted files.
How to recover?
Periodically OH makes a backup of the JSONDB files. You will find these in the backup folder under the jsondb folder. Each backup is prepended with a timestamp in epoch (i.e. number of milliseconds since Jan. 1, 1970 00:00:00). The most recent backup will be the file with the largest number in front of it and the most recent modification date.
To recover your Things (Items, Links, Rules, etc.):
Stop openHAB. openHAB does not read these files except when starting so if you modify them while OH is running, your changes will likely become overwritten instead of applying.
Copy the most recent backup of all the files from backup to the jsondb folder, removing the timestamp from the front of them. It is a good idea to recover all your files so you have a complete backup of the state of your JSONDB at a given point in time. Don’t just recover the Things file.
Start openHAB running again. Watch the logs for errors.
If there were no errors in the logs, check in PaperUI to see if your Things are back. If not, you may need to restore one backup prior to the most recent one.