JoryHogeveen / home-assistant-merge-db

Simple tool to merge two HA SQLite DB's in case of a corrupted file
7 stars 1 forks source link

I click on run and nothing happens #1

Open UK-JustinSmall opened 10 months ago

UK-JustinSmall commented 10 months ago

i click on run and nothing happens

JoryHogeveen commented 10 months ago

Hi @UK-JustinSmall This code hasn't been touched since published and HA has changed since then, I'm not sure if it still merges correctly. In any case, you'll need a PHP server with these files in the root folder for it to work.

UK-JustinSmall commented 7 months ago

Managed to finally get it to work - however I get to the end it says

init_db | Database copy created | home-assistant_v2.db > home-assistant_v2_new-1707560095.db | true

but when I check the files there is one file that keeps changing size every few seconds

home-assistant_v2_new-1707560095.db-wal I assume this is some write ahead log file but when would this stop? How do I know it has finally finished. It seemed to run rather quickly from other posts it suggested it should take some time to complete.

UK-JustinSmall commented 7 months ago

Failing that it seems the new DB only contains the Old DB data

I seem to get the following errors

SQL Exec: SQLSTATE[23000]: Integrity constraint violation: 19 UNIQUE constraint failed: statistics.metadata_id, statistics.start_ts

on merge_long_term Interval/done shows as False and data looks like this

INSERT INTO main.statistics (created,created_ts,metadata_id,start,start_ts,mean,min,max,last_reset,last_reset_ts,state,sum) VALUES (NULL,1702925012.150921,101,NULL,1702850400,NULL,NULL,NULL,NULL,1702771200,34.09899999999999,34.09899999999999)

arough007 commented 6 months ago

Managed to finally get it to work - however I get to the end it says

init_db | Database copy created | home-assistant_v2.db > home-assistant_v2_new-1707560095.db | true

but when I check the files there is one file that keeps changing size every few seconds

home-assistant_v2_new-1707560095.db-wal I assume this is some write ahead log file but when would this stop? How do I know it has finally finished. It seemed to run rather quickly from other posts it suggested it should take some time to complete.

What was your original problem?

I get SQLSTATE[HY000]: General error: 11 database disk image is malformed in the network tab. I got it working by manually fixing the db and then running the tool again. I'm working on adding a check and fix to the tool and just wanted to check if this was your initial error too.