Watermeter keep values after powerfailure

Hi,

I did build a water meter with works great. But if there is a power failure or the device reboots it loses his current reading. I try to find something about store the value in the flash memory but I have no idea how. Or is there a better solution for this?
Has anybody some examples?