01-05-2009, 07:42 PM | #1 |
Addict
Posts: 296
Karma: 32153
Join Date: Dec 2008
Device: Kindles (e-ink)
|
metadata.db corrupted
I have shredded my metadata.db and it's gone.
I have, however, an sqlite3 dump of the whole database from before the problem occurred. Thus, I can recreate metadata.db (using sqlite3 metadata.db < dumpfile) which I can verify by connecting to the db and selecting data from it which works fine. Neither calibredb nor the GUI see any of my books, though. Instead both claim to update the database and delete all the content while doing so: Code:
$ calibredb list Upgrading database to version 2... Upgrading database to version 3... Upgrading database to version 4... idtitleauthors |
01-05-2009, 07:54 PM | #2 |
creator of calibre
Posts: 44,356
Karma: 23708270
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
What happens if you run it with
Code:
calibre --with-library /path/to/folder/containing/recovered/metadata.db |
Advert | |
|
01-05-2009, 08:08 PM | #3 |
Addict
Posts: 296
Karma: 32153
Join Date: Dec 2008
Device: Kindles (e-ink)
|
If I recover the db to database_path (which is on NFS if it matters) and run calibre with --with-library, it starts empty and empties the recovered db again.
If I recover the db to an alternative path, calibre starts empty as well but, interestingly, the database doesn't get wiped. |
01-05-2009, 08:15 PM | #4 |
creator of calibre
Posts: 44,356
Karma: 23708270
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Edit global.py
Change library_path to point to some folder on your local drive. delete database_path set migrated to True Now copy your recovered metadata.db to the folder you specified earlier as well as all the actual ebook folders/files Now run calibre Note that library_path sets the location of the calibre library, not database_path, which is on there for legacy reasons |
01-05-2009, 08:29 PM | #5 |
Addict
Posts: 296
Karma: 32153
Join Date: Dec 2008
Device: Kindles (e-ink)
|
library_path now points to a local dir with the recovered metadata.db inside.
migrated = True (which was already the case, though) I've removed database_path from global.py. I've copied the recovered (and verified as containing my data) to library_path and the NFS dir in which my actual ebooks (as stored there by calibre) reside. Then I started calibre: Code:
$ calibre link hasn't been detected! link hasn't been detected! Upgrading database to version 2... Upgrading database to version 3... Upgrading database to version 4... No books are shown in calibre. library_path/metadata.db is wiped empty after quitting calibre. The other metadata.db in the ebook storage area (how do you call that?) is still fine. The very same setup (with everything on NFS) has worked fine till the original metadata.db got killed (manually by myself by accident). Last edited by Philantrop; 01-05-2009 at 08:31 PM. Reason: Further information. |
Advert | |
|
01-05-2009, 08:43 PM | #6 |
creator of calibre
Posts: 44,356
Karma: 23708270
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
What happens with
Code:
calibre-debug -c "from calibre.library.database2 import LibraryDatabase2; db = LibraryDatabase2('/path/to/folder/containing/recovered/metadata.db');" |
01-05-2009, 08:48 PM | #7 | |
Addict
Posts: 296
Karma: 32153
Join Date: Dec 2008
Device: Kindles (e-ink)
|
Quote:
And the recovered metadata.db is emptied again. |
|
01-05-2009, 09:07 PM | #8 |
creator of calibre
Posts: 44,356
Karma: 23708270
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
that means your recovered metadata.db is also corrupted. What size is the db file? One thing to try is the following
Run sqlite3 metadata.db At the sqlite prompt pragma user_version=4; quit and then try the previous command again |
01-05-2009, 09:21 PM | #9 |
Addict
Posts: 296
Karma: 32153
Join Date: Dec 2008
Device: Kindles (e-ink)
|
First of all, Kovid, thank you very, very much. Your quick and effective help is greatly appreciated.
In the end, "pragma user_version=4;" did the job. Calibre is now working for me again, I have two independent file backups of metadata.db which is now stored in git as well - just to be sure. Looks like sqlite3's ".dump" does not dump everything Calibre needs? Is there another way to create a "calibre-compatible" dump? |
01-05-2009, 09:34 PM | #10 |
creator of calibre
Posts: 44,356
Karma: 23708270
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Glad it worked
Basically, the only thing it doesn't dump is user_version (possibly because that's not really a part of the database). At some point I have to create a backup/restore infrastructure for calibre, if only the day had 240 hours |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Corrupted Metadata | Marcy | Calibre | 31 | 07-27-2010 10:50 AM |
Corrupted File? | StealthyScribe | Kobo Reader | 8 | 07-21-2010 10:09 PM |
corrupted dbase | hnoto | Related Tools | 43 | 05-17-2010 11:27 AM |
Corrupted DB on Reader | djwoodard | Kobo Reader | 7 | 05-10-2010 01:13 AM |
Library corrupted | rozie123 | Sony Reader | 1 | 05-26-2009 07:02 AM |