Last active

If you get an error like SQLite error code:11, 'database disk image is malformed' you can try to dump and reload the database with these commands

  • Download Gist
Repair a corrupt sqlite database
1 2 3 4
echo '.dump'|sqlite3 $DB_NAME|sqlite3 repaired_$DB_NAME
mv $DB_NAME corrupt_$DB_NAME
mv repaired_$DB_NAME $DB_NAME

Thank you this helped!

The repaired$DBNAME file is a text file, containing a set of SQL statements to describe the database contents. To convert it to an actual database file, I needed to replace step 4 with:
sqlite3 $DBNAME < repaired$DBNAME

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.