Energy dashboard historic data lost, maybe after OS upgrade or new sensor addition

After investigating more I’m having a moment of thinking is not worth adding another thread to the already too long lists of not totally useful threads on Database corruption shenanigans to the forum :grimacing:

But in the hope it will help in the future there we go…

Now I think is not an OS16 update related issue but rather data corruption due to my tests for a new Gas meter via door magnet sensor. As it is the only other change to my HA installation in the past 5 days that may have affected the energy dashboard data in the DB.

I have also discarded disk issues, since I’m running HASSOS on a VM on proper hardware and I have not had any power loss or unclean shutdowns in many months. Database size is small c. 370MB

After doing various resetting/deleting/restoring tasks and running a pragma integrity_check; on the DB, is confirmed that the “Database disk image is malformed” aka corrupted, so I’m back to square one.

Is clear now that I need to focus on trying to fix it, this thread seems to be a good source.