Skip to content

Instantly share code, notes, and snippets.

@dionys
Created May 11, 2013 11:38
Show Gist options
  • Save dionys/5559726 to your computer and use it in GitHub Desktop.
Save dionys/5559726 to your computer and use it in GitHub Desktop.
Firefox places.sqlite restore if its corrupted.
UPDATE moz_historyvisits
SET from_visit = 0 WHERE id IN (
SELECT t1.id
FROM moz_historyvisits t1
LEFT JOIN moz_historyvisits t2 ON t1.from_visit = h2.id
WHERE t2.id IS NULL AND t1.from_visit <> 0);
DELETE FROM moz_inputhistory
WHERE place_id IN (
SELECT t1.place_id
FROM moz_inputhistory t1
LEFT JOIN moz_places t2 ON t1.place_id = t2.id
WHERE t2.id IS NULL);
DELETE FROM moz_annos
WHERE id IN (
SELECT t1.id
FROM moz_annos t1
LEFT JOIN moz_places t2 ON t1.place_id = t2.id
WHERE t1.place_id IS NOT NULL AND t2.id IS NULL);
PRAGMA user_version = 21; -- Needs actual version. Its 21 for Firefox 20.0.1
#!/bin/sh
sqlite3 places.sqlite ".dump" > places.sqlite.dump
mv places.sqlite places.sqlite.bak
sqlite3 -init places.sqlite.dump places.sqlite
rm places.sqlite.dump
sqlite3 places.sqlite < places-integrity.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment