@ming You have 2 strategies in my opinion:
- Do regular EEPROM put of the data you need to do a “resume” after power restored. Then there is the issue that your last commit of recovery data may have been a while ago but writing only when changes means you could call this every loop - assuming you are changing recovery values with less frequency.
- Catch the system event for power outage/brownout and do a put to EEPROM at that point (of course this may not complete).
A hardware solution is to have a coin cell battery powering VBAT and to use retained RAM to store your recovery data. Have you considered this?