Domoticz: restore database

install sqlite with putty: sudo apt-get install sqlite3

Recover your malformed database:

cd domoticz
sqlite3 domoticz.db
.mode insert
.output dump.sql
.dump
.exit
sqlite3 -init dump.sql repaired.db
mv repaired.db domoticz.db

or another way:

install sqlite
sudo apt-get install sqlite3

cd ~
cd domoticz
sqlite3 domoticz.db
.mode insert
.output dump.sql
.dump
.exit

Remove first line of dumped database:
tail dump.sql -n +2 > dump1.sql

Make back-up of original just in case:

mv domoticz.db domoticz.bak.db

Import into fresh database:

sqlite3 domoticz.db < dump1.sql

Clean-up the temporary files:

rm dump*.sql

Comments are closed.