View Single Post
Old 05-21-2010, 11:22 PM   #6
toddos
Guru
toddos ought to be getting tired of karma fortunes by now.toddos ought to be getting tired of karma fortunes by now.toddos ought to be getting tired of karma fortunes by now.toddos ought to be getting tired of karma fortunes by now.toddos ought to be getting tired of karma fortunes by now.toddos ought to be getting tired of karma fortunes by now.toddos ought to be getting tired of karma fortunes by now.toddos ought to be getting tired of karma fortunes by now.toddos ought to be getting tired of karma fortunes by now.toddos ought to be getting tired of karma fortunes by now.toddos ought to be getting tired of karma fortunes by now.
 
toddos's Avatar
 
Posts: 695
Karma: 822675
Join Date: May 2010
Device: Kobo Aura, Nokia Lumia 920 (Freda)
I just got this all set up and working. Warning! Before you do anything, make a backup of all of the data in Calibre's library location as well as the metadata.db database. I only backed up the database and I lost ~12 books in the process. I was able to recover 11 of them from non-Calibre sources, but I should've backed up first. Anyway, here's what I did:
  1. Stop all running instances of Calibre, both on the WHS and whatever machine is going to be your new client.
  2. On the WHS, move your calibre metadata.db database to a share that is writable by your client machine. I put mine in \\servername\software\Calibre\metadata.db, but you can put yours wherever you like. In my case, I keep my ebooks in \\servername\ebooks\calibre and I have my ebooks share set for duplication, while the software share is not set for duplication. I'm not sure if duplication plays nice with the database file and Calibre (see note below).
  3. On both the WHS and the client machine, edit your environment variables to add CALIBRE_OVERRIDE_DATABASE_PATH pointing to wherever you put the database. I put this in the system-level environment variables for WHS, though I probably didn't need to (see below for why).
  4. On the client machine, open Calibre, go into Preferences, and set the "Location of ebooks" value on the General tab to the share where your ebooks live. As I mentioned before, this was \\servername\ebooks\calibre for me. If you haven't done this on the WHS already, close Calibre on the client and update the server's settings as well. This is where something (I don't know what) went wrong and I lost a few books from my library (database entries were still there with metadata, but the files themselves were nowhere to be found). I think this might have been caused by having my ebook location set to a different value than what the database expected (?) when I started the client with the redirected database location, but I don't know why it only deleted some of my books. Anyway, if this happens to you, you can copy the files from your backup (you did backup above, right?) back into the correct location and everything should just work.

At this point, you now have Calibre setup on your client machine but with its database and files stored on the WHS. Next, we want to setup the calibre-server in order to provide access to Stanza, Trook, or just web browsing.
  1. With Calibre closed on your client machine, open Calibre on the server.
  2. Setup the port and other settings for the Content Server if needed and close Calibre.
  3. Install the Windows Server 2003 Resource Kit and install it on your WHS.
  4. Follow the instructions here to create a service for Calibre. I named my service simply "Calibre".
  5. Before starting your service, you'll need to set the logon credentials. Local System won't work because Local System can't run a networked service. I tried Network Service instead but it didn't seem able to load the database (not sure if it's a permission issue or an environment variable issue, but this is why I set the environment variable globally above). I did get it to work by running it as administrator, but that's not a viable long-term option. Worst case, you may have to create a new user with limited permissions to run the service.
  6. Start the service and then navigate to "http://servername:8888" (or whatever port you used) and see the magic happen.

Note about putting metadata.db on WHS shares: The DE migrator service can't move files that are locked by a process. Normally this isn't an issue because the service will keep trying over the next ~24 hours and at some point in there most processes will release whatever files the have locked. Calibre's GUI does not do this -- it locks the database as soon as it starts and holds onto it until it closes. If you're running the Calibre GUI 24/7 on your WHS like I was, within a day or so you'll start getting warnings on the WHS console about not being able to migrate files. In theory, since calibre-server only takes a read-only lock on the file the DE migrator should play nicely. However I'm not sure how nicely it will play with duplication so for now I've put my database on a non-duplicated share.
toddos is offline   Reply With Quote