Opened 10 years ago

Closed 10 years ago

#366 closed defect (fixed)

Automated backup will back up a corrupted DB

Reported by: dstillman Owned by: dstillman
Priority: major Milestone: 1.0 Beta 3
Component: data layer Version: 1.0
Keywords: Cc:

Description (last modified by dstillman)

Slight flaw in the current backup strategy: if you corrupt your SQLite DB while Firefox is open, Zotero will happily copy the corrupted file to the backup file, leaving you with two worthless files.

Unfortunately the mozStorage caching prevents us (as far as I can tell) from actually determining if the DB on disk is corrupt or not after we've first opened a working one, even if the connection is manually unset. And there doesn't seem to be a way to do a .dump from mozStorage, which would solve all our problems.

If we were OK with requiring storage space for three copies of the DB, we could back up pre-connect at startup to a temporary file, try to open the main DB, if successful replace the last shutdown backup with the new one, and otherwise delete the new startup backup and try to restore from the shutdown. Then at shutdown move the startup backup down one and make a copy of the DB, which may or may not be corrupt, but at least we then have protection for corruption both when Firefox is running and when it's not.

Change History (2)

comment:1 Changed 10 years ago by dstillman

  • Description modified (diff)

comment:2 Changed 10 years ago by dstillman

  • Resolution set to fixed
  • Status changed from new to closed

(In [815]) Fixes #366, Automated backup will back up a corrupted DB

We already copy to an interim temp file on shutdown--just try to open it before overwriting old backup file

Still wish there was a way to detect corruption while Zotero was still open and pretending to write to the DB, but I don't know of one (other than making a copy of the DB and trying to open it, but as far as I can tell we can't release the file handle on it to then delete it or check again later)...will keep working on it.

Note: See TracTickets for help on using tickets.