Database errors after restore to core-2021.2.3

I recently had to restore HA from a backup and now I’m getting the following error/


Logger: homeassistant.components.recorder
Source: components/recorder/__init__.py:526 
Integration: Recorder (documentation, issues) 
First occurred: 5:05:03 PM (2362 occurrences) 
Last logged: 6:25:24 PM

Error executing query: (sqlite3.DatabaseError) database disk image is malformed [SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id, context_parent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?)] [parameters: ('state_changed', '{}', 'LOCAL', '2021-03-14 22:25:15.272346', '2021-03-14 22:25:15.272346', 'a90f5f326a3842a191e1a235748ec408', None, None)] (Background on this error at: http://sqlalche.me/e/13/4xp6)
Error executing query: (sqlite3.DatabaseError) database disk image is malformed [SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id, context_parent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?)] [parameters: ('state_changed', '{}', 'LOCAL', '2021-03-14 22:25:17.463903', '2021-03-14 22:25:17.463903', '885272c5c45bb927c6af07d900a3b321', None, None)] (Background on this error at: http://sqlalche.me/e/13/4xp6)
Error executing query: (sqlite3.DatabaseError) database disk image is malformed [SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id, context_parent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?)] [parameters: ('state_changed', '{}', 'LOCAL', '2021-03-14 22:25:19.617478', '2021-03-14 22:25:19.617478', 'c53ba96dd09be08bf2e5637b81e35f85', None, None)] (Background on this error at: http://sqlalche.me/e/13/4xp6)
Error executing query: (sqlite3.DatabaseError) database disk image is malformed [SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id, context_parent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?)] [parameters: ('state_changed', '{}', 'LOCAL', '2021-03-14 22:25:21.599513', '2021-03-14 22:25:21.599513', '69ff4718d2e9fbfdd5233a9aeec89fe1', None, None)] (Background on this error at: http://sqlalche.me/e/13/4xp6)
Error executing query: (sqlite3.DatabaseError) database disk image is malformed [SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id, context_parent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?)] [parameters: ('state_changed', '{}', 'LOCAL', '2021-03-14 22:25:23.858074', '2021-03-14 22:25:23.858074', 'ca2fd0f7f49ac54512695fc949f114b2', None, None)] (Background on this error at: http://sqlalche.me/e/13/4xp6)

Not sure if this is related to the restore or not and no idea how to fix it?

Try deleting your .db

Thanks for the response. Didn’t work though. Deleted the db file. It was immediately recreated. Restarted HA. The error is still present.

Looks like I posted too soon. I had one db error entry in the logs after restarting. After my previous post I rechecked the logs and found an entry that the malformed db file was being renamed. Since that there have been no further errors. Looks like this issue is resolved. Thanks again.

You can try a .db repack. Take a look at Developers tool —> Services —>
Recorder: Purge —> repack