![]() |
#1 |
hopeless n00b
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,110
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
|
Restored metadata.db and original metadata.db different sizes?
Did something stupid with my library and instead of restoring metadata.db from my primary backup, I accidentally overwrote it with the bad metadata.db. I did a database restore (from opf, which thankfully hadn't updated yet).
The restored metadata.db is just 4MB while the original metadata.db was 20MB. A quick spot check seems to show the books and metadata are correct albeit by no means was the verification exhaustive. What could cause the disparity in file size and what information might be missing from the restored database? |
![]() |
![]() |
![]() |
#2 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,706
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Relational databases accumulate dross over time, mainly due to deletions and replacements, so they need to be optimised occasionally - aka as 'vacuuming' Ψ²
By rebuilding it you have eliminated the dross. FYI - the Check database function does a 'vacuum' as its first step. BR |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,020
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
not the 4 times bigger part. ![]() Everything (in the defining tables) would have to have been redefined, many times to get that huge. I DO recommend 'quarterly' housekeeping (Calibre Maintenance) on any Library with frequent Metadata defining changes. FWIW in a RDB you define an Author: J.D. Robb. You assign that defined author INDEX (not visible to a normal user) to a book entry. , The same is true for all column types except Comments. That is a BLOB. |
|
![]() |
![]() |
![]() |
#4 |
hopeless n00b
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,110
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
|
I run calibredb check_library everytime I backup so the original metadata.db has already been vacuumed (from 27MB to 20MB, iirc).
I actually created a copy of the library and put the bad metadata.db. There were just some tags changed between bad and original, the metadata.db sizes are really close. Vacuuming that gave me just ~100KB reduction. I really think something else was lost with the restore. Last edited by ilovejedd; 02-03-2018 at 07:36 PM. |
![]() |
![]() |
![]() |
#5 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,062
Karma: 91577715
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
|
Some plugins store library-specific data in the database.
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,706
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
@theducks - I overlooked the dimensions of the issue. But I have done a 'vacuum' on a database that reduced its size by 90%, admittedly that was a high volume TP application for an investment bank using Oracle on a Vaxen cluster. My predecessor was too scared to do any housekeeping of that sort, so it had been churning away 365*24*7 for several years :lol:
I have a vague recollection of a plugin that shovelled the entire text of books into a comments like custom column so it could do fast searches. It may not have been a 'known' plugin (i.e. with an entry in the Index) but one that someone asked me to test. If you remove a plugin, then it won't remove its library specific data from metadata.db (or its global data from the config plugins directory). The Job Spy plugin has a tool to remove data left behind in library databases by defunct plugins. BR |
![]() |
![]() |
![]() |
#7 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,318
Karma: 27111242
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
There are many thing in the db that a restore will not restore. Plugin data, book specific conversion settings, etc.
A restore is basically designed to restore only your book metadata, as that is the most precious thing. A restore should really be a last resort thing to do if you dont have backups. And you can often recover a bad sqlite db by dumping it to sql and using the sql to re-create it, you might need to manually edit the sql a little to fix errors. |
![]() |
![]() |
![]() |
#8 | |
hopeless n00b
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,110
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
|
Quote:
Yep, the metadata is the important part. The database wasn't actually bad or corrupted at all. I just did something stupid and accidentally changed tags that I didn't mean to change and restoring the old tags was priority. Anyway, I actually do have copies of the library in several flash drives that I forgot in the office. I just didn't want to wait until Monday to test out some things so I tried out the Restore database function and I'm happy to report it worked wonderfully. I'll nuke this library and restore from backup but in the meantime, I was able to test a bunch of regex stuff for search and replace, and MCS as well as templates for save to disk. ![]() |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Calibre fills automatically title and author metadata in books without any metadata? | thosedays | Library Management | 5 | 10-28-2016 03:33 PM |
Coping with huge discrepancies between original and restored database | Beanxx | Library Management | 5 | 07-27-2015 04:23 PM |
Regarding using metadata objects in identify method of metadata download plugin api | aprekates | Development | 1 | 07-06-2014 03:35 AM |
Save the Metadata to the Libary files/change filename to the Metadata | RyuujiTakasu | Calibre | 10 | 03-19-2014 02:01 PM |
Can the K2 original firmware be restored? | hmemcpy | Kindle Developer's Corner | 0 | 05-06-2009 12:57 AM |