Things disssapearing after restart on openhabianpi 2.4

This was something that was happening to me and I could not find the solution in the forum, so I am documenting how I fixed it.

The reason for my issue was that the openhab user did not have access permission to the jsondb folder, and I found it the openhab log. Look for an error like this:

2019-09-22 07:26:49.452 [ERROR] [me.storage.json.internal.JsonStorage] - Error writing JsonDB to /var/lib/openhab2/jsondb/backup/1569133609452--thing_status_storage.json. Cause /var/lib/openhab2/jsondb/backup/1569133609452--thing_status_storage.json (No such file or directory).

If that’s the issue it’s easy to fix, just access the openhabianpi using ssh, and type:

sudo chown -R openhab:openhab /var/lib/openhab2/jsondb

That should do. Just restart the server and you should be fine. The error will dissapear and things will save.

There is also a special command for openHAB:

sudo openhab-cli reset-ownership

This will restore ownership of every directory that belongs to openHAB.