How to Sync Your Calibre Library Between Computers on Ubuntu Linux with Dropbox

It’s easier than it sounds, I promise. I’ve tried to keep this simple & step-by-step for non-techies. And everything I use here is free.

Calibre and Ebooks…

If you like ebooks, you’re probably already familiar with the multi-platform ebook management software Calibre. It’s been called "the iTunes for ebooks" and can catalogue, tag, convert and sync ebooks to various readers such as Nook and Kindle.

Calibre stores all the books you add to it in a folder, which is sub-sorted into other folders based on author, and then based on title + a number- i.e., Calibre Library/Charles Dickens/A Tale of Two Cities (58). All of Calibre’s "important" data is located in the Calibre Library folder and its subfolders- which makes syncing Calibre between computers a breeze if you know what you’re doing.

If you want to sync between Ubuntu Linux and Windows or between two Windows installations, see the paragraph on Windows towards the end, under the heading "Syncing Between Windows and Linux/Windows". Be sure to read the rest of the tutorial first, though!

Syncing Your Calibre Library On Ubuntu Linux : The Setup

1. First of all, you need to sign up for Dropbox. It’s free, private and keeps your files synced between computers. The storage space starts at 2GB and can be increased by links and contests- or by buying more space. Install the Dropbox Linux Sync Daemon. Restart the computer if required. After it runs the first time, you should now have a folder titled Dropbox in your home folder and (most likely) an icon in the system tray showing you Dropbox’s status (syncing, done syncing, paused).

2. Download Calibre Ebook Software and install it. It’s possible to do this via the command-line in Ubuntu Linux, should you so choose; to install via the command-line, enter this code in the gnome-terminal:
sudo apt-get update
sudo apt-get install calibre

lafattaturchina helpfully pointed out in the comments that "in Calibre 0.9.12, you can choose where to place the library by going in Preferences > Start Wizard". lafattaturchina has successfully used this method with the somewhat-similar-to-Dropbox Ubuntu One service, and it’s working thus far. If you can get this method to work, I recommend using it instead of the steps 3-6 below; then to sync with another computer, you could use steps 7-8 below the heading Adding a Second (or Third) Computer, BUT using the Start Wizard to select the downloaded library folder in your Dropbox folder when you’re setting up Calibre on the second comp. I HAVEN’T TRIED THIS, but it seems like it should work. Please comment below if you’ve tried it successfully.

3. Run Calibre for the first time and add some books to it. (If you don’t have any ebooks, Project Gutenberg has loads of free ones, including most of the classics.) This should create a folder full of them in your home folder called Calibre Library. Close Calibre.

4. MOVE the entire Calibre Library folder into your newly-formed Dropbox folder. It should start uploading the books/data to back them up. (DON’T start Calibre again yet, or it will just try to make another folder there to replace the moved one.)

5. Now we’re going to create a symbolic link to trick Calibre into thinking that its library is still in the home folder. It will still access/update your books just like before, but Dropbox will sync them and any updates to them (i.e., converted formats or new tags/author info). Open the gnome-terminal and enter the following short code to make sure it’s looking at the home folder:
cd ~
Now enter the following code to make a symbolic link pointing to your Calibre library; since the link will have the same name as the old folder, Calibre will treat the folder it points to as if it’s the original Calibre Library:
ln -s Dropbox/Calibre\ Library/ Calibre\ Library
The ln stands for "link" and the -s means that it’s symbolic. When making symbolic links, you enter the "real" location first, and then the "fake" location you want to point to the real one.

6. Open Calibre and add some more books (to make sure it works). The books and any edits to them should be added to the Calibre Library folder in your Dropbox folder and automatically updated. If you just want to back up your Calibre Library, rather than syncing it, then you’re done here.

Adding a Second (or Third) Computer

7. Now you’ll want to configure your other computer(s) (which I’ll call "comp #2" from now on) to receive the updated Calibre Library from Dropbox. Turn on your other computer and install Dropbox, then download to comp #2 whatever’s in your Dropbox folder- including the Calibre Library folder. Download it all and then pause Dropbox’s syncing. (You don’t *have* to do this, but it’s just easier to tweak things when Drobox isn’t stalking your file changes…)

8. Download and install Calibre onto comp #2. Run Calibre one time, to make the Calibre Library folder inside your home folder, and then close Calibre. NOW DELETE THE Calibre Library FOLDER YOU JUST MADE.

8. Open the gnome-terminal and again make sure it’s looking at the home folder (it usually opens there by default, but if it’s already open or customized… It never hurts to make sure.)
cd ~
and now make a symbolic link from where the folder you just deleted used to be to the Calibre folder inside your Dropbox folder:
ln -s Dropbox/Calibre\ Library/ Calibre\ Library

9. Open Calibre. It should show all the books you added on your other computer, along with any custom things you did (such as, say, tagging anything by Mark Twain as "over-rated".) You can now add/remove/change books on either computer, and it will show up on the other one(s). You can repeat steps 7-9 for as many computers as you want to sync.

ONE POINT: You SHOULD NOT have two Calibres running on two different computers at the same time. This will lead to file conflicts as Dropbox tries to figure out which version the files changed should be kept. It won’t permanently break anything or ruin your computer, but it can be annoying- especially if you just finished tagging a lot of books and it over-writes all your tags. Dropbox will usually try to save the alternate versions of files in their respective folders as ItsOldFilename.conflict or something, but it’s easier just to avoid this.

This method is confirmed to work and I use it myself- it’s not one of those "you have to download 28 dependencies you’ve never heard of and it might crash your gui and it won’t work half the time!" sort of linux tutorials you sometimes see online. I’m currently using this tutorial’s method to keep my Calibre library synced between two Ubuntu 11.04-running laptops.

Syncing Between Windows and Linux/Windows

I run Calibre primarily on my favorite OS- a somewhat recent version of Ubuntu Linux. This tutorial is for Ubuntu Linux, but it could be tweaked for other linux flavors. There’s also a way to make this work between a Linux install and Windows, although you have to use the portable version of Calibre on the Windows comp. I’ve never tried it, but you could do it this way: install Dropbox on Windows FIRST, and then install the portable version of Calibre INSIDE the Dropbox folder. Add whatever books you want to Calibre, close it and then sync it to Linux. Then point the symbolic link to in your home folder to /home/YourUsernameHere/Dropbox/CalibrePortable-or-whatever-the-portable-versions-folder-is-called/Calibre\ Library or wherever the library got dumped (you might have to browse for it.) Between two Windows computers, it would be much easier: just skip the whole symbolic links deal and run the portable Calibre from within the Dropbox folders every time.

If you have any questions/comments/concerns, feel free to comment. I’ll try to reply when I can.

Helpful Links:

Linux Cheatsheet 1

These are some useful tricks I’ve found when using Ubuntu Linux- stuff I’ve found after hours of searching, through accidental trial and error or (on occasion) hidden in an FAQ no one reads. I’m posting this here just as much for my own reference as yours (I’ve forgotten some of these things before, and need to remember them.)

How to Get To Directories with Spaces in Their Names Via The Gnome Terminal In Ubuntu Linux

I found this out by accident, then forgot it, then found it online (finally!) after months of searching. Most geeks use underscores in the directory / file names instead of spaces, but sometimes this isn’t feasible. *SO* to indicate a space in a file name or directory name in Linux’s terminal, you type
\ (a backslash followed by a single space)

So, to get to
/home/me/Desktop/Useful Stuff
in my terminal, I would type
cd /home/me/Desktop/Useful\ Stuff/

How to Change the Location of Your Hard Drive After Linux Forgets / Changes It

I have a hard drive named SILVER. I love SILVER. Linux sometimes doesn’t. After I upgraded my OS (and a few other times) Linux forgets that it knows SILVER and renames his location SILVER_, which messes up all of my shortcuts- and my MUSIC, since I keep my music on SILVER. You’ll run into this eventually too, if you use Linux, so this is how I fixed it (be careful when doing this! It worked for me, but maybe not for you!):

Back up any crucial files (just in case!) and detach your hard drive. Open the Gnome Terminal (you can get to this by opening the RUN dialogue via pressing ALT + F2 and entering Gnome-Terminal. Run this command:
sudo nautilus
Enter your password when prompted. This will open up Nautilus (the file-management/windows thingy program) in Linux, BUT WITH SUPER-USER RIGHTS, meaning that you can mess with all sorts of things you normally can’t. BE CAREFUL WHEN DOING THIS- you can ruin your computer without it trying to stop you in this mode.

Go to /media in the Nautilus address bar

Find the *original* name/address of your hard drive there- I’ll call it ITSOLDNAME here.  Click it to make sure- it should say something like it can’t be accessed (because the computer now thinks it’s at ITSOLDNAME_ or something.) Click to select the original name and delete it. Refresh the window by clicking F5 and then plug in your hard drive again. It *should* go back to having its old name and location now, accessible via /media/ITSOLDNAME/

CLOSE NAUTILUS COMPLETELY NOW. It’s dangerous to leave it open in this mode, since it has total authority over messing with your files- one accidental click is all it takes to do something awful…