Future timestamps after powerloss, how to fix DB by removing incorrect entries

Hello,

I’m having a peculiar issue, after a recent blackout my system on which I have the HomeAssistant docker running booted up in the year 2066. This resulted in faulty entries in statistics and such.

The system issue i managed to fix and return to the year 2024, however the incorrect entries remained and are messing up my statistics pages.

I have tried manually removing all entries above 2032 (either by using timestamps or date formats depending on the table) from the statistics, statistics_runs and events tables in the DB. However after restarting the container the DB gets purged completely and the old one is dumped as corrupted. Same thing happens if I only remove entries from one of the tables.

I tried looking in the UI for an option to manually remove entries from statistics, but i couldn’t find anything.

As I couldn’t find a solution on google nor on this forum I decided to create a new thread. Hope someone can help, as I’d hate to loose my statistics, and keeping these entries screws up all graphs.

Few examples:
Przechwytywanie
Przechwytywanie