Data loss after uncontrolled reboot for several days


I am using openHAB 3.3 with openHABian on a Raspberry Pi 4. ZRAM is activated. RRD4J is the default persistence service, no special settings. When I do a controlled reboot (“sudo reboot”) everything works fine, all persistence values are restored.

Today, however, there was an uncontrolled reboot (my fault) and persistence data was restored up to July 21. The last days were lost. I had, however, a backup from yesterday which I could use.

My question is: I could understand that RRD4J because of ZRAM looses some data (maybe some hours) when there is an uncontrolled reboot, but days? Is there a (ZRAM?) setting which stores the data more regularly on the SD card?

Thanks for any help!

ZRAM prevents write access to the SD-Card. This is done via overlay file system (afaik). ZRAM will write all data to SD-Card if rebooting (or shutting down), but this is a “one big write access”. If cutting power :wink: there is no way to save data from RAM to SD-Card.

When ZRAM was added to openHABian there was a major problem with ZRAM periodically writing out to disk except at controlled reboots. I don’t know if it got fixed in upstream and never adopted by openHABian or if it’s still broken.

thanks for your answers. So there is no way to tell ZRAM “Save data on SD card more often”?

It got fixed and I haven’t seen any reports indicating it wouldn’t work in quite a long time.

No there isn’t.
After a power loss you’ll fall back to the point in time ZRAM was started the last time, usually that’s when the box was (intentionally) booted the last time before.
You can restart ZRAM (and OH) without booting or take daily backups (as recommended).

thanks for your clear answer. As a “layman” I thought that ZRAM does only “spare” write cycles for the SD card, yet writes the data to the SD card from time to time. I did not know that it only writes on reboots.