Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 07-04-2022, 02:28 PM   #1
ygreq
Enthusiast
ygreq began at the beginning.
 
Posts: 27
Karma: 10
Join Date: Mar 2010
Device: iphone
Solution for this. Metadata.db gets corrupted. Waste more than 3 days fixing it.

Hi folks!

I have been using Calibre since forever. And I always had this issue which is weird that it has not been solved till now.

I have a Calibre book library of about 60 000 books. And from time to time, the metadata.db gets corrupted. Usually this happens when I use the library to write something in it (like adding a new book or editing some book metadata or book title).

And whenever I try to do Library Maintenance -> Restore database, it takes like forever. Seriously it takes more than 3 days full 72 hours) or maybe more.

So considering that considering what I said about the probable reason why this database file gets corrupted is because of what I last did before actually corrupting itself, I was thinking that a backup copy of the metadata.db not older than a few minutes would definitely help in solving the issue a lot easier.

I would just:
-close Calibre
-delete the old corrupted metadata.db file,
-rename the backup file
-restart Calibre
-readd the book I was trying to add, or modify again the book details I was trying to modify. (All this would be based on "Modified" column sorting)

So any idea if this can be done? To have Calibre do a backup of metadata.db every 5 minutes? Or set the time in the Settings on how frequently you would want to do the backup.

So what do you say? Does it make sense?
Let me know!

PS: I was looking for 3rd party apps to backup files, but all the apps I found can backup a whole folder. So if you know of an app like that, it would be way around. At least until this hopefully gets solved. <3
ygreq is offline   Reply With Quote
Old 07-04-2022, 03:41 PM   #2
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 10,971
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I take a daily backup of metadata.db, though more as a protection against user error. I'd suggest SyncBackFree -- it's got good filtering options that let you grab only the files you want.

But I'd look into the root causes of the corruption. Are you running on a local drive, or an NAS? Are you running it in something like Dropbox or GDrive? What's your antivirus?

Last edited by ownedbycats; 07-04-2022 at 03:43 PM.
ownedbycats is offline   Reply With Quote
Advert
Old 07-04-2022, 05:30 PM   #3
ygreq
Enthusiast
ygreq began at the beginning.
 
Posts: 27
Karma: 10
Join Date: Mar 2010
Device: iphone
Hi, ownedbycats! Thank you for the recommendation. I checked the app, but it seems it also only backs folders and not specific files. I will look further. Maybe I am missing something.

Also I forgot to mention that I have multiple Calibre libraries, one for books, one for comicbooks and some others. I store them on external hard drives. I intend to run them in a NAS in the future.

The thing is that it does not happen often. And for sure I don't blame Calibre for corrupting the database file. It generally happens if there is some power failure or something else that happens while I use the app.

Now related to what I was saying earlier, an implementation within Calibre would backup the database file only while using that specific library. So that would be a lot nicer.
ygreq is offline   Reply With Quote
Old 07-04-2022, 05:59 PM   #4
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 10,971
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Don't plan on running them on an NAS.

Quote:
Originally Posted by ygreq View Post
Hi, ownedbycats! Thank you for the recommendation. I checked the app, but it seems it also only backs folders and not specific files. I will look further. Maybe I am missing something.
You need to use the filtering option. "Choose sub-directories and files."
Attached Thumbnails
Click image for larger version

Name:	2022-07-04 19_11_29-Profile Setup_ Backup - Calibre database - Simple.png
Views:	160
Size:	45.7 KB
ID:	194743  

Last edited by ownedbycats; 07-04-2022 at 06:12 PM.
ownedbycats is offline   Reply With Quote
Old 07-04-2022, 06:57 PM   #5
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,047
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Calibre CAN rebuild the DB fairly quickly if nothing else was corrupted .

Every folder contains a Metadata.opf. That is the metadata that was in the Library at the time each entry was last updated.


You will see an entry: Metadata backup status
That is how many entries are still in the queue (usually the queue empties fast, except when you do something that affect a large number of books).
That is what is used If you right click the Library icon:Library Maintenance: Restore database.

This ASSUMES the rest of the Library files are intact (This is why a NAS/networked drive is dangerous and not to be used. Delays can cause pieces to be out of place/lost. )

Each Library (DB) is ONLY associated with the folders in the same Tree branch. Corrupt 'books' and your 'Comics' library was not involved.

THIS does not apply to a Hardware / Malware caused fail.
theducks is offline   Reply With Quote
Advert
Old 07-04-2022, 07:03 PM   #6
PeterT
Grand Sorcerer
PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.
 
Posts: 13,511
Karma: 78910202
Join Date: Nov 2007
Location: Toronto
Device: Libra H2O, Libra Colour
When you mention external drives; how are they connected (USB 2, 3 or ....)

Sent from my Pixel 4a using Tapatalk
PeterT is offline   Reply With Quote
Old 07-04-2022, 07:08 PM   #7
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,722
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
perhaps a Library Closed plugin could copy the metadata.db file of the library just closed to a metadata.db.backup fiie within the library folder, doing a replace of it already exists.

I say 'perhaps' because I don't know if LC plugins can have an event that kicks in when the metadata.db file is actually closed. The existing LC plugins operate on the content of the database (Virtual Library and Custom Column definitions) before its closed.

Recovery would be manual: Close calibre and copy metadata.db.backup to metadata.db, then run the calibredb check_library command and fix errors, OR start calibre, run Library Maintenance->Check library and fix errors.

BR
BetterRed is offline   Reply With Quote
Old 07-06-2022, 06:42 PM   #8
ygreq
Enthusiast
ygreq began at the beginning.
 
Posts: 27
Karma: 10
Join Date: Mar 2010
Device: iphone
Quote:
Originally Posted by ownedbycats View Post
Don't plan on running them on an NAS.



You need to use the filtering option. "Choose sub-directories and files."
Ah! I see. I will check asap. Thank you so much!
ygreq is offline   Reply With Quote
Old 07-06-2022, 06:46 PM   #9
ygreq
Enthusiast
ygreq began at the beginning.
 
Posts: 27
Karma: 10
Join Date: Mar 2010
Device: iphone
Quote:
Originally Posted by theducks View Post
Calibre CAN rebuild the DB fairly quickly if nothing else was corrupted .

Every folder contains a Metadata.opf. That is the metadata that was in the Library at the time each entry was last updated.
.
Thank you . I know all of this. The problem is that once the medata.db file gets corrupted, it takes more than 3 days to recreate a new metadata.db file form the metadata.opf files for a 60 000 books library.

And this is the problem I was addressing.
ygreq is offline   Reply With Quote
Old 07-06-2022, 06:47 PM   #10
ygreq
Enthusiast
ygreq began at the beginning.
 
Posts: 27
Karma: 10
Join Date: Mar 2010
Device: iphone
Quote:
Originally Posted by PeterT View Post
When you mention external drives; how are they connected (USB 2, 3 or ....)

Sent from my Pixel 4a using Tapatalk
They are connected via USB 2 and 3. Some older ones on 2 and newer on 3.
ygreq is offline   Reply With Quote
Old 07-06-2022, 06:52 PM   #11
ygreq
Enthusiast
ygreq began at the beginning.
 
Posts: 27
Karma: 10
Join Date: Mar 2010
Device: iphone
Quote:
Originally Posted by BetterRed View Post
perhaps a Library Closed plugin could copy the metadata.db file of the library just closed to a metadata.db.backup fiie within the library folder, doing a replace of it already exists.

I say 'perhaps' because I don't know if LC plugins can have an event that kicks in when the metadata.db file is actually closed. The existing LC plugins operate on the content of the database (Virtual Library and Custom Column definitions) before its closed.

Recovery would be manual: Close calibre and copy metadata.db.backup to metadata.db, then run the calibredb check_library command and fix errors, OR start calibre, run Library Maintenance->Check library and fix errors.

BR
Interesting approach. But what if the fail happens while you are using calibre. For example the only fails I got was while using calibre. So I would still rather go with a metadata.db backup every n minute. And keep about 3 backups. And if shit happens, you just delete the old metadata.db file and rename the last backup. And see the folder structure of the entir elibrary and just re-add the last books you were trying to add or see which books were last modified to redo them.
ygreq is offline   Reply With Quote
Old 07-06-2022, 07:20 PM   #12
dunhill
Guru
dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.
 
dunhill's Avatar
 
Posts: 892
Karma: 810834
Join Date: Sep 2017
Location: Buenos Aires, Argentina
Device: moon+ reader, kindle paperwhite
Another application to try is the one I use, Free File Sync
dunhill is offline   Reply With Quote
Old 07-07-2022, 11:02 AM   #13
ygreq
Enthusiast
ygreq began at the beginning.
 
Posts: 27
Karma: 10
Join Date: Mar 2010
Device: iphone
I actually use FreeFileSync myself and loving it. And I actually use that to sync the whole calibre libraries. But no idea you could sync a single file. Can you do that?

I know RealTimeSync comes in the same package.
ygreq is offline   Reply With Quote
Old 07-07-2022, 11:14 AM   #14
ygreq
Enthusiast
ygreq began at the beginning.
 
Posts: 27
Karma: 10
Join Date: Mar 2010
Device: iphone
@ownedbycats Ok. I don't get it. There seems to be lots of options, but I cannot find the filter you talk about. Can I ask for some easy steps? Or where exactly do I find that option?

Thank you so much!!
ygreq is offline   Reply With Quote
Old 07-07-2022, 04:59 PM   #15
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 10,971
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Quote:
Originally Posted by ygreq View Post
@ownedbycats Ok. I don't get it. There seems to be lots of options, but I cannot find the filter you talk about. Can I ask for some easy steps? Or where exactly do I find that option?

Thank you so much!!
First, you create a new profile - Backup-type. I also suggest using the single-compressed file option as seen here:

Click image for larger version

Name:	2022-07-07 17_55_26-New Profile.png
Views:	276
Size:	12.1 KB
ID:	194779

Then it'll open up the options window. Put in your library folder in Source, and it'll enable the 'choose sub-directory and files' button.

Click image for larger version

Name:	2022-07-07 17_56_34-Profile Setup_ Backup - Calibre database - Simple.png
Views:	117
Size:	43.6 KB
ID:	194780

Also, adding '%DATE%.zip' to the end of your destination will have it date your backups.
ownedbycats is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
fixing directory/metadata variances McStubb Library Management 5 05-25-2016 07:29 PM
PRS-350 Fixing metadata is not working cormack12 Sony Reader 2 12-27-2010 10:43 AM
Metadata download corrupted Splashfart Calibre 3 12-22-2010 03:11 AM
Corrupted Metadata Marcy Calibre 31 07-27-2010 10:50 AM
metadata.db corrupted Philantrop Calibre 9 01-05-2009 09:34 PM


All times are GMT -4. The time now is 09:09 AM.


MobileRead.com is a privately owned, operated and funded community.