Everytime recorder.purge runs I get the following error:
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) Could not decode to UTF-8 column 'attributes_id' with text '0g��S��|)('
(Background on this error at: https://sqlalche.me/e/20/e3q8)
2024-03-10 20:33:14.096 WARNING (Recorder) [homeassistant.components.recorder.util] Error executing purge: (sqlite3.OperationalError) Could not decode to UTF-8 column 'attributes_id' with text '0g��S��|)('
(Background on this error at: https://sqlalche.me/e/20/e3q8)
Result is that the database is discarted (home-assistant-v2.db.corrupt), a new database is grown and all my statistics data of the last years is… gone.
So killing the database and have HA generate a new one is not the answer I am looking for.
Please advise on a way to find this “faulty record”, delete it and save my statistics data.
rename database “home-assistant_v2.db” to “home-assistant_v2.statistics.db”
core start (new database was build)
core stop (again)
renamed database to “home-assistant_v2.db” to “home-assistant_v2.states_events.db”
copy both databases to a laptop
export databases from DB Browser:
a. selecting only the state & event tables from the “new” database to sql #1
b. selecting statistics from the “old” database to sql #2.
imported sql #1 into a new database called “home-assistant_v2.db”
imported sql #2 into the database
copied database back to Home Assistant
core start
(needed to writ that down before I try out)
As my database is just growing, testing is possible framed by backup and restores around the method above with out too much dataloss.
download from HA ok
export to sqls done integrity check would do some modifications, not saved
import of sqls done with some mistakes: foreign key restrictions were violated, should repair
ignored both, uploaded to HA via Samba as …db.new
ls command lists the file in green. ignored, stopped core and renamed to …db
core start: fail, new blank database created.
so over all: no success.
btw. upload via file-editor didn’t work
What did I do wrong? I am barely a user with som talents on command lines (not runnign away when it gets to them). I hav a strom feeling that there might be more to do in the DB Browser.
Just testing the method, no harm done no repair done to the actual db
The process should be without any errors. I do not know if the structure of the database changed in time when I did this, but in fact it should not matter. Try again making sure every step is error free.
I am too much DAU to understand really what to do. I will keep a Backup of the long term data for maybe further import options if I get motivation to try that.
Thanks for opening up a chance.
Maybe we have to overcome our “Datenverlust-Angst”