View Single Post
Old 08-22-2014, 06:45 PM   #12
Gary_M_Mugford
Groupie
Gary_M_Mugford has a complete set of Star Wars action figures.Gary_M_Mugford has a complete set of Star Wars action figures.Gary_M_Mugford has a complete set of Star Wars action figures.
 
Gary_M_Mugford's Avatar
 
Posts: 180
Karma: 299
Join Date: Jul 2010
Location: Brampton ON
Device: Kobo, Kindle3
Quote:
Originally Posted by chaley View Post
I wonder if I shouldn't change calibre to do both the scan and the load from metadata_db_prefs_backup.json. It isn't clear what to do with the results. My feeling is:
a) a column definition (a lookup key) found in metadata_db_prefs_backup.json should win over the same definition found in a metadata.opf, and
b) a column definition found in the scan that is not in metadata_db_prefs_backup.json should be added to the db.

This scheme could re-add old custom columns to the db, but that is easily fixed once the recovery finished. It would also deal with the problem you must have had, where the metadata_db_prefs_backup.json file was reinitialized somehow before the recovery was run.
Chaley, old friend,

Might I suggest that the start the rebuild with a question. "Do you want to choose when conflicts occur?" [N]

With a small library, the length of time of the scan would be short enough to afford the user the ability to sit and monitor the process. With bigger libraries, letting the computer decide, using the basis you have outlined here, would probably be appropriate. Instructions would need to make it crystal clear that rebuilding is not an instantaneous process. Been there, done that, got the eyestrain to show for it. But then again, my library is a BIT larger than normal.

One of the things I do is regularly run (and especially after some heavy editing/changing) a windows batch file. The concept should easily translate into linux or OSX.

Spoiler:
G:
cd \GaryELibQ

if exist metadata.db.7 del metadata.db.7
if exist metadata.db.6 ren metadata.db.6 metadata.db.7
if exist metadata.db.5 ren metadata.db.5 metadata.db.6
if exist metadata.db.4 ren metadata.db.4 metadata.db.5
if exist metadata.db.3 ren metadata.db.3 metadata.db.4
if exist metadata.db.2 ren metadata.db.2 metadata.db.3
if exist metadata.db.1 ren metadata.db.1 metadata.db.2
if exist metadata.db copy metadata.db metadata.db.1
if exist metadata.db copy metadata.db N:\_Backup_CalibreNonBookData

if exist metadata_db_prefs_backup.json.7 del metadata_db_prefs_backup.json.7
if exist metadata_db_prefs_backup.json.6 ren metadata_db_prefs_backup.json.6 metadata_db_prefs_backup.json.7
if exist metadata_db_prefs_backup.json.5 ren metadata_db_prefs_backup.json.5 metadata_db_prefs_backup.json.6
if exist metadata_db_prefs_backup.json.4 ren metadata_db_prefs_backup.json.4 metadata_db_prefs_backup.json.5
if exist metadata_db_prefs_backup.json.3 ren metadata_db_prefs_backup.json.3 metadata_db_prefs_backup.json.4
if exist metadata_db_prefs_backup.json.2 ren metadata_db_prefs_backup.json.2 metadata_db_prefs_backup.json.3
if exist metadata_db_prefs_backup.json.1 ren metadata_db_prefs_backup.json.1 metadata_db_prefs_backup.json.2
if exist metadata_db_prefs_backup.json copy metadata_db_prefs_backup.json metadata_db_prefs_backup.json.1
if exist metadata_db_prefs_backup.json copy metadata_db_prefs_backup.json N:\_Backup_CalibreNonBookData

if exist metadata_pre_restore.db.7 del metadata_pre_restore.db.7
if exist metadata_pre_restore.db.6 ren metadata_pre_restore.db.6 metadata_pre_restore.db.7
if exist metadata_pre_restore.db.5 ren metadata_pre_restore.db.5 metadata_pre_restore.db.6
if exist metadata_pre_restore.db.4 ren metadata_pre_restore.db.4 metadata_pre_restore.db.5
if exist metadata_pre_restore.db.3 ren metadata_pre_restore.db.3 metadata_pre_restore.db.4
if exist metadata_pre_restore.db.2 ren metadata_pre_restore.db.2 metadata_pre_restore.db.3
if exist metadata_pre_restore.db.1 ren metadata_pre_restore.db.1 metadata_pre_restore.db.2
if exist metadata_pre_restore.db copy metadata_pre_restore.db metadata_pre_restore.db.1
if exist metadata_pre_restore.db copy metadata_pre_restore.db N:\_Backup_CalibreNonBookData

N:
cd \_Backup_CalibreNonBookData
if exist CData.7 del CData.7
if exist CData.6 ren CData.6 CData.7
if exist CData.5 ren CData.5 CData.6
if exist CData.4 ren CData.4 CData.5
if exist CData.3 ren CData.3 CData.4
if exist CData.2 ren CData.2 CData.3
if exist CData.1 ren CData.1 CData.2
if exist CData copy CData CData.1
copy C:\Users\Gary\AppData\Roaming\calibre\*.* CData


The batch file might lead to a large set of backup files as the metadata.db files can reach the hundreds of megabytes. But the json file and the pre_restore database are much, much smaller, just kilobytes for the settings.json file. Also, admittedly, seven backups are a little much. You can set up, so that one of the backup sets, goes off-disk to another storage location, as I have done here. You might decide not to do that. Or you might decide to avail yourself of Dropbox or something similar.

Of course, the usual caveat. Don't run this batch file while Calibre is running. AND, make backups of your precious Calibre BOOK files to boot. Backups are never complete until you have a backup on another piece of hardware AND a copy in the clouds. So, when your computer has a metal (sic) breakdown, you can be sure the library will still be there. The device won't always have all books, although frequently it WILL pass for the first half of the backup process, the saving of the library itself to a off-computer piece of hardware.

PS: and if you are wondering how I got acquainted with rebuild when I have such a fine and all-encompassing backup process? One is the result of the other. [G]

Last edited by Gary_M_Mugford; 08-22-2014 at 06:48 PM. Reason: Explaining why I developed the backup batch file
Gary_M_Mugford is offline   Reply With Quote