The database for my hot tub was returning IO errors and when I tried to use the VACUUM command, it returned an error:
Result: database disk image is malformed
Let’s fix this!
This is caused by some write corruption of the database. Easiest fix is to export all the data, recreate a new database and then copy over the old database. We can do this in two lines on the command:
- cd into the location of the database
- Backup your database
- Run this series of commands
sqlite3 databasename.db '.dump' | sqlite3 databasename.db.new
mv databasename.db.new databasename.db
That’s it!