My Entire Ebook Library Online

Oh… you didn’t think that title meant I was providing my entire ebook library to the public, did you? Sorry. Thar be no pirates here, maties. This is more of a tutorial on how I make my ebook library available to me. Onward, hoe!

I love using Calibre to maintain my ebook collection. If you have not heard of it and would like more control over your ebooks, then you should take a look. Calibre also has a built in server that you can access via a web browser. This allows you to browse your ebook collection and download them if you like. This is a really neat feature, except that the software has to be running in order to access it.

What I really want is to be able to publish this library and be able to access it from anywhere without any dependence on my computer and the Calibre software running.

This is my solution.

Is This Article For Me?

This how-to is NOT going to attempt to make this process user friendly. There is no program here that you can run to put your library online. In order to be successful with this method, you should have some familiarity with *nix shells (Bash, cygwin, etc), rsync, ant build files and you should have domain hosting.

Now, to be fair, you could publish to a local server and host it yourself. If you are doing that then you should have no problems understanding this workflow.

Calibre2Opds Setup

Other than Calibre, you’ll need the Calibre2Opds program. This is a Java program, but we’re not really concerned about that other than making sure you have Java installed (also needed for Ant). I am not going to teach you how to use Calibre2Opds. For that, please go to their website and read the documentation.

Create a custom profile that uses the Publish mode. This will allow you to generate the catalog (website) in a location outside of your Calibre library. Change the value of Books URL to /books/. By default the generated website references books that are one directory up (outside of the website). I wanted them within the website. This makes the generated webpages reference a books directory at the root of the website.

Calibre2Opds Main Options

Screenshot of Calibre2Opds Main Options

Check Destination folder is catalog only. This prevents the software from copying your entire Calibre books library to the generated website when it runs.

On the Advanced Options tab, check the Include cover images within the catalog option so that the generated website will have cover images, which is kind of nice.

That’s really it for the Calibre2Opds software. Well, the GUI portion. Make sure you save the profile as you’ll be referencing it from the ant build file.

Ant Build File

Create a directory for you build file and configuration. Within this directory create a file named build.properties. This contains configuration that is specific to your environment. View the comments within the file sample below for explanations.

Now the entire ant build.xml script is listed below, so you can download it and modify to your hearts desire. The basic gist of what we are accomplishing here is this.

  1. Run Calibre2Opds in a scripted/batch mode to create our website
  2. Create a .htaccess file to add a couple of mime types and also to secure online book library
  3. Use rsync to mirror the website files up to the web host
  4. Use rsync to mirror the Calibre library (the ebooks) up to the web host

The first time you run this, it will take some time depending on the size of your library. Subsequent runs, however, will be much quicker since it only needs to calculate changes to your library. And since we’re using rsync to copy the files to the web server, subsequent runs do not have to transfer every single file… thus quicker.

Notice that I don’t store my login credentials anywhere. I consider that bad practice, as do most people. The build file references an sshuser variable, which you can simply pass to ant on the command-line when you run the build. You may also want to setup a private ssh key so that you don’t have to enter a password to login to your remote site.

Easy Updates

Now, whenever I add new books to my Calibre library, I have but one simple command to run from a Cygwin Bash shell:

If you don’t run the clean action, then it only needs to perform an update to the generated catalog, which means it runs faster than when you first run it. After a few minutes, my online book library is updated and I can access the new books along with my entire library… on my terms.

Accessing My Library

Now if you want to browse your ebook library from a web browser, just navigate to your new website! If you have ebook reader software that can utilize an OPDS catalog (I use Marvin), then just register it with the software (i.e. http://your.book-domain.com/index.xml) and you should be able to grab your ebooks on the fly. I’m extremely happy with the results and even more happy that I didn’t have to write software to accomplish it.