Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Pegolon
Created March 15, 2011 18:38
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pegolon/871206 to your computer and use it in GitHub Desktop.
Save Pegolon/871206 to your computer and use it in GitHub Desktop.
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
cd "$DATABASE_LOCATION"
echo '.dump'|sqlite3 $DB_NAME|sqlite3 repaired_$DB_NAME
mv $DB_NAME corrupt_$DB_NAME
mv repaired_$DB_NAME $DB_NAME
@plagi
Copy link

plagi commented Mar 30, 2011

Thank you this helped!

@simon3270
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment