HA-DB frequently corrupts

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.

… and check for errors or warnings for the underlying media (sd-card, ssd or nvme).

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.

Thank you for the suggestion. But where would I find these type of errors?

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.

It is no longer generated as a file as of the “improvement” in the 2025.11 release 3 weeks ago.

@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.

This is true for HAOS, not for Home Assistant Docker. The OP did not say what kind of installation he is using.

1 Like

Power supply adequacy, memory capacity, storage capacity, unreliable media, etc could be contributing factors.
Not enough info on where to focus.

see a

homeassistant.log.1
homeassistant.log.fault
homeassistant.old

but no homeassistant.log . Is there maybe an option that switches off the log function?

smartctl not found, when given in the HA-terminal.

I found the HACS integration as mentioned above and now see the homeassistant.log again.

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.