Register Guidelines E-Books Search Today's Posts Mark Forums Read

05-13-2010, 04:36 PM   #16
ccayer
Member

Posts: 19
Karma: 64
Join Date: May 2010
Device: Dell Axim X50v, JetBook Lite
Quote:
 The next release of calibre contains code that will try pretty hard to recover from a corrupted database.
The ability to recover from a corrupted database sounds like a great feature. Even though it's something you hope you never need, it's nice to know that feature is there.

Quote:
 I copy metadata.db to metadata.db.1, etc.. I keep 6 copies for the last 6 backups, all the way to metadata.db.6 It's a very simple rename, of metadata.db.1->metadata.db.2, etc. before copying the current metadata.db to metadata.db.1. I have yet to see a corrupted metadata.db, but if I ever do, I've got all 6 copies backed up every day for months.
The backup of the metadata.db is even more 'insurance' against corruption. Is there a way to have Calibre run a batch file on exit? I can whip up a batch file, similar to the one described, and it would be convenient to have it run automatically when I close Calibre.

05-13-2010, 05:00 PM   #17
Starson17
Wizard

Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
 Originally Posted by ccayer The backup of the metadata.db is even more 'insurance' against corruption. Is there a way to have Calibre run a batch file on exit? I can whip up a batch file, similar to the one described, and it would be convenient to have it run automatically when I close Calibre.
I use Windows Task Scheduler, and it runs at night. Most backup programs will run a pre-backup batch file, and you can put it there,a nd your backup program will run it. However, I don't know of a way to get Calibre to run a batch file on exit. It might be a useful feature for some if you want to request it in the bug tracker.

05-13-2010, 05:45 PM   #18
chaley
"chaley", not "charley"

Posts: 7,697
Karma: 2046382
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
 Originally Posted by Starson17 However, I don't know of a way to get Calibre to run a batch file on exit.
Why not start calibre in a batch file? When it exits, you can do whatever you want.

Note that if you are on windows, there are some issues with using calibre in batch files. You need to use the START command. There was a thread around a month ago that went into detail. I always start calibre with the calibre-debug command and don't have problems, but your mileage might vary.

05-13-2010, 06:49 PM   #19
Starson17
Wizard

Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
 Originally Posted by chaley Why not start calibre in a batch file? When it exits, you can do whatever you want. Note that if you are on windows, there are some issues with using calibre in batch files. You need to use the START command. There was a thread around a month ago that went into detail. I always start calibre with the calibre-debug command and don't have problems, but your mileage might vary.
If you start calibre with a simple command line in the batch file (like you, I do that with "calibre-debug - g" when working on the source) it won't run the next line in the batch, for the reason you mentioned - Calibre has trouble with batch files.

If you put "start" in front, it runs calibre and the next line in the batch, but it runs the next line immediately, not after Calibre exits.

I believe this will work if you install powershell:
Code:
powershell -command - < batchfile.bat
but it's probably easier to use one of the other methods.

05-13-2010, 08:43 PM   #20
hnoto
Groupie

Posts: 194
Karma: 177180
Join Date: Jun 2009
Location: Mesa, AZ
Device: Sony PRS 505
Quote:
 Originally Posted by dwanthny I'm a big fan of using the save to disk feature to back up your books, I even wrote procedures here to do just that. The truth is that the simple way to back up your library according to the creator of Calibre is to copy your library folder to another location. By default the metadata.db file is in the root of the library folder.
I'm a pretty simple girl. So I'm glad to hear that my simple idea will work.

 05-13-2010, 09:10 PM #21 Debby Connoisseur     Posts: 75 Karma: 600 Join Date: Jul 2008 Location: Depends Upon the Season..... Device: Cybook, Sony & ipad Starson17, would you mind sharing how you do this in Task Scheduler? Thanks...
05-14-2010, 01:25 AM   #22
chaley
"chaley", not "charley"

Posts: 7,697
Karma: 2046382
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
 Originally Posted by Starson17 If you put "start" in front, it runs calibre and the next line in the batch, but it runs the next line immediately, not after Calibre exits.
Try it with 'start /wait'. That causes the original bat file to wait until the subprocess dies. This thread has a fair discussion of the technique along with experiment results.

05-14-2010, 01:28 AM   #23
chaley
"chaley", not "charley"

Posts: 7,697
Karma: 2046382
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
 Originally Posted by Debby Starson17, would you mind sharing how you do this in Task Scheduler?
I am not starson17 , but you might get some help in this thread.

05-14-2010, 10:13 AM   #24
Starson17
Wizard

Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
 Originally Posted by chaley Try it with 'start /wait'
Excellent point, I'd forgotten the /wait option.

05-14-2010, 11:48 AM   #25
Debby
Connoisseur

Posts: 75
Karma: 600
Join Date: Jul 2008
Location: Depends Upon the Season.....
Quote:
 Originally Posted by chaley I am not starson17 , but you might get some help in this thread.
Thank you! If someone has something a little more detailed that would help. I can generally follow along if I have examples. For example, with no experience I was able to use the plugin for removing the "unspeakable".

I actually understand how to make the batch file (major step for a non-techie ).
But I am not certain of the syntax for copying the library. I will google using task manager and see if I find examples.

I am looking for way to ensure the library stays backed up since I have had to restore it twice. I am beginning to suspect the issue is the interaction with the reader - since both times this happened I plugged in the Sony 505 to upload books. At least now I understand how to save all the metabooks (with covers)!

05-14-2010, 12:32 PM   #26
Starson17
Wizard

Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
 Originally Posted by Debby But I am not certain of the syntax for copying the library. ... I am looking for way to ensure the library stays backed up since I have had to restore it twice.
There are many here who will be happy to help you structure what you want. The problem is figuring out what that is - i.e., what you want and what will work for you given the size of your library, when you want the library backed up, etc.

A basic copied Library type of backup has two parts - the books and the metadata.db file. Copying all of the books, each time I exited Calibre, would be impossible for me. It would take far too long, and I seldom exit it.

I think your first question to answer is: "When do you want your library backed up?" If your computer runs 24/7, it's easy - do it at night. If not, perhaps you just want to manually run the batch file, not automatically. Or maybe you prefer when you turn on/off the computer?

You could use a system that copies the ebooks manually (you manually choose to run a backup by starting a batch file), but always backs up metadata.db when you exit. You could choose to run the backup automatically at night, and only leave the computer on at night when you want a backup -telling the Scheduled Task to not run when the computer is off.

What do you think would work for you?

 05-14-2010, 01:04 PM #27 itimpi Wizard   Posts: 4,253 Karma: 901265 Join Date: Nov 2008 Device: Sony PRS-950, iphone/ipad (Marvin/iBooks/QuickReader) If you are running Windows then a very simple form of backup is to run a DOS command of the form: XCOPY /D /S /Y SourceFolder TargetFolder This will do a copy (including sub-folders), and the /D option tells it to only copy files whose date has changed. More sophisticated backup solutions will do differential backups and give you the option to return to a nominated point in time. The backup utility that comes as part of Windows will do for most people.
05-14-2010, 01:22 PM   #29
DoctorOhh
US Navy, Retired

Posts: 9,047
Karma: 12768879
Join Date: Feb 2009
Location: North Carolina
Device: Nexus 7
Quote:
Originally Posted by Debby
Quote:
 Originally Posted by itimpi If you are running Windows then a very simple form of backup is to run a DOS command of the form: XCOPY /D /S /Y SourceFolder TargetFolder This will do a copy (including sub-folders), and the /D option tells it to only copy files whose date has changed.
1. In a perfect world (sigh) a back up would occur of the NEW books I added that day (with covers) along with a daily metadata.
itimpi's basic batch file backup can easily be setup to run each night. This would back up the NEW books you added that day (with covers) along with a daily metadata.

05-14-2010, 02:45 PM   #30
Starson17
Wizard

Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
 Originally Posted by Debby 1. In a perfect world (sigh) a back up would occur of the NEW books I added that day (with covers) along with a daily metadata.
This is basically what I do. I can suggest some options.

My preference is to run PureSync, a folder synchronization program via a batch file. It operates in one-way mirror mode, compares my backup copy of the Library to my master copy (located on another drive in a networked computer), copies over any new books, deletes any old books that were deleted from the master, and copies over and replaces the metadata.db file (provided it has changed). There are lots of folder synchronization programs around.

Another alternative is to run XCOPY. It can be set to copy only files that have not been backed up and then it sets the archive bit, but that method doesn't delete old books deleted from the master, nor does it work if another backup program is being used.

You can always just copy the entire Library folder every now and then.

As to the multiple metadata.db files, I use something simple like this:

c:
cd \path\to\Calibre\Library

You can put it in a batch file, run it nightly with a Windows scheduled task, or before your backup.