Restore on startup if electicity goes down mapdb

Hi,
I noticed since OH3 upgrade, that the Restore on Startup based mapdb behave differently if Raspy is restarted from bash or if the electricity goes down:

IF the electricity goes down, the restored values are very far in time 4 / 5 weeks ago,
If i restart manually from line, the values are correctly restored on startup.

Can you give me some references to understand these ? Obviously I need to restore the lastvalues every time, even if there is a laks of current…

Thank you,
best regards,

Muplex

You are probably using ZRAM, knowingly or not. Openhabian? The “live” Mapdb database will be in volatile memory and lost at power failure.
You might find out how to configure ZRAM to leave Mapdb in real file store?

1 Like

Hi rossko,
thank you to be always one of the very first replyer.
Yeah, I’m for sure an openhabian user, but indeed I didn’t know nothing about ZRAM.

I will investingate Openhabian ZRAM on the official documentation to understand the possibile options.

I think I will try to toggle it OFF from persistence.
Some “Scenario” Items need to be alligned since short time, otherwise I encountered some strange restart status from these items Like → scenario = “In Holydays” but should be “At Home/Automatic” because I was in hoilydays under Xmas… just to make a fast example…

I would advise against that. The value of ZRAM is that it prevents extensive writes to your SD card, which will prolong the card’s failure. Depending on your persistence settings, MapDB will write very frequently.

I would instead suggest that you set up a small UPS with Network UPS Tools, enabling your OH server to do a proper shutdown when there’s a power outage. My UPS runs for about 10 minutes. This also prevents the possibility of your SD card being corrupted by the sudden power loss, which is really the bigger concern.

Hei,
thank you for your advice. I did not turn off ZRaM yet…and I would evaluate the possibilities bofore to do it.
One question:
is possible a compromise solution like to write 1 set of data on the SD card every 6 hour to be able to proper restore values with mapDB?
Or otherwise I did not choose a proper persistence service for my needs?

I can’t answer that, unfortunately. Since I have a UPS, I’ve never needed to consider it. I’d actually be surprised if MapDB didn’t write to permanent storage every once in awhile. 4-5 weeks seems like a long time to me, but I’m not an expert on it.

There’s nothing wrong with MapDB, which is also my preferred persistence service.

I think that everyone running OH on an SD card should have a UPS. Most power outages are unpredictable, and when your SD card gets corrupted a power loss will most likely be what causes it. Instead of your home going back to working how it always did when the power returns, you’ll be stuck with a dead SD card that has to be replaced. Persistence data will be the least of your worries, particularly if you happen to be away from home when it happens.

It’s also possible that you’re already seeing impact from power outages without realizing it. Last year, I set up OctoPrint on an RPi3, but didn’t get around to buying a UPS for it. Now the server keeps crashing, and it’s almost certainly due to SD corruption from power outages since nothing else has changed. I’m waiting on delivery of a UPS I ordered a couple of weeks ago.

I don’t know where you live, but in Canada a NUT-compatible UPS costs less than $100. That’s a small price to pay to increase the reliability of your OH server. Being able to recover from disaster is important, but being able to prevent it is even better.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.