Every now and then I have a corrupted home-assistant.DB file . The frequency is higher than 1 time per month but so far I have not found a pattern in the day or date. Yet, in the the time there is a major similarity, i.e. many of the corrupted files are renamed as home-assistant_v2.db.corrupt.YYYY-MM-DDT03:12:SS or 1 hour difference with daylight saving.
Therefore I think there is a job started early in the morning that triggers this problem. I think a second trigger is that there have been elements been added/removed/changed. And the effect is that all history is gone.
Is there anyone out there that can help me find the culprit. Thanks in advance.
I can’t help you find the culprit, but I can give you a pointer on what happens at that time. 04:12 in your local time (so 03:12 if you’re in UTC+1) is when the recorder auto purge occurs.
Check if the days are Sundays. The auto repack occurs every second Sunday too.
OK, good starting point. Is there a place where I can look for logfiles?
If this job finds an error and renames the old DB, I expect to find proof in a logfile.
The logfile should be in the same directory as the .db file.
(home-assistant.log)
Depending on the media you use there are programs from the manufacturer of the card. For a SSD or NVMe you could use smartctl on linux os.
@yann1420 if you want to see the log files, you can either access them from the settings page (click the link above for steps), or else you can install this custom integration to get your log files back.
Yesterday I updated a HACS-integration (Daikin) and the new version of the integration made 20 entities superfluous. Per suggestion of HA, I removed/deleted these entities and immediately all history got truncated.
This makes me think that it something in the DB rather than the storage device.