Using IOT Cloud to measure cumulative value - rain gauge

I built a tipping bucket rain gauge. I used an ESP32 dev board and a technique similar to the usual and common for rain gauges (for example: Wireless weather station v2 - Rain gauge - Pluviometer by ZeSanglier - Thingiverse); The mechanism is such that each 'click' received from the sensor is converted to a fixed amount of rain in mm. For example, every 7 clicks is equivalent to one mm of rain falling.
In this way, I am interested in displaying the daily amount of rain in a graph using the Arduino IOT cloud.
The problem is that the data is an accumulated value received from the detector.
If there is any disconnection or restart of the board, the daily rain value resets and restarts, the new values ​​will rise from zero in the middle of the day (even though it has already rained) after the restart. That is, the graph shown on the dashboard is interrupted and resets every time you disconnect/restart instead of continuing from the previous measured value.
I would be happy to get guidance on a good option to overcome this problem.
Thanks!

Retain the values and increment with new values ONLY resetting at some time of day like midnight.

How should it be done? Do you maybe have sample code that does something like this? Should I use permanent flash memory?
I would also like to display the rate of rain continuously. Which will require saving the value every say minute.

Thanks!
Roi