Backing up Kindle books

One of my favourite websites is Bandcamp. I love buying music there, because it has no faff, it's very simple and focuses on the music. And principally, because it lets me download the music I buy in DRM-free files, in a very easy way: you simply download a ZIP file with the MP3 songs inside. That's it. Much better than other alternatives that are "DRM-free", but force the user to dive into their hidden music folders to actually find the files.

So, I wish that e-books bought from the Kindle store were that easy to deal with. Alas, they're not.

They're mostly encrypted, which means that even though you can access the file (e.g. by connecting the Kindle to your computer), you can't open the file and read it using another reader (e.g. an alternative, non Amazon, desktop reader software). The other big problem is that they also started using an even more proprietary format that deviates from the original mobi for e-books. So it's just laying hurdles after hurdles in the face of people who would like to have the certainty that if Amazon goes bust, we can still access the content we paid for.

And you might be laughing incredulously at the idea of Amazon going bust, but as we say in Spanish, "torres más altas han caído" (bigger towers have fallen). There!

This has taken me a while to figure out, and I still haven't reached the "perfect" solution, but it is getting something, which is already more than I had before.

What the ideal goal would be is that you could end up saving a file which is as close as possible to what the publisher uploaded to the Kindle store. With the higher quality pictures, etc.

What I managed to achieve was to download versions that are sent to Kindle Paperwhite devices. I reckon that Amazon performs optimisations on the publisher's version, and the result is a file with smaller sized images and probably a simpler layout so that they are more palatable for these devices.

I suppose you could say I was aiming to download the luxury glossy hardback, and ended up downloading the paperback printed in the cheapest paper, but hey. Better than nothing!

This is how I did this after much researching and trying. Below I will list whatever else I did which did not work for reasons.

How to backup Kindle books to your computer, DRM-free

You will need:

  • A copy of Calibre ebook reader
  • A copy of the DeDRM tools; unzip the file somewhere.
  • Your Kindle reader serial number: go to your Amazon account (on the top right corner), then find the Digital Content And Devices section, then go to Content and devices. It initially focuses on "content", but you want "devices", so find the Devices tab under the bigger Amazon header, this will list your device(s). Click on the device, and it will show your device's serial number.

Now, open Calibre.

We are going to install the DeDRM plug-in: go to Preferences, then Change Calibre behaviour. Scroll down to the Advanced section, click Plugins, then the Load plug-in from file button, and find the unzipped folder, then select the file, and click "Open".

This plugin lets you decrypt content which has been encrypted, and for that you need a key, which is the Kindle's serial number that you found before. To tell Calibre about this number, go to Preferences, then Plugins, File type, find DeDRM and select that entry, then click the Customise plugin button, and a window with several buttons will open. Click on eInk Kindle ebooks, and add your Kindle's serial number on the new window that opens. Press Close, press _OK_, press Apply, and Close the preferences dialog.

I am not sure, but I think you need to restart Calibre for the changes to be applied.

You can also take a deep breath now.

Now back to Amazon, select the Content tab. Find the "..." button (i.e. the three dots button) on the row of the book you want to download, under the Actions column, and click it. Click the Download & transfer via USB option on the pop up that opens. It will ask you for which device is this—I assume this is so it can give you a version that is optimised for that device. Select your Kindle, then click on Download.

NOTE: if you have more than one Kindle device, you need to be careful to always select the Kindle with the serial number you entered in Calibre, or add all the serial numbers to Calibre. Otherwise you won't be able to open the downloaded files as the keys won't match!

You will download a file with extension AZW3.

Drag it into the Calibre main window (make sure no Preferences dialog or anything are still open before you do this!). This imports the file into the Calibre library. Since we have added the serial number, Calibre should be able to open the file and show you the contents.

But what we want is to save a copy that DOES NOT have any encryption, just in case the Amazoncalypse happens. To do that, right click the book you just imported into your library, and select Convert... Convert individually. A dialog will open offering you various configuration options; you can select lots of things which I did not bother with. I just made sure the output is MOBI which is standard e-book, and pressed OK.

This generates a MOBI file in the same folder as the AZW3 file in the Calibre library (so not in your downloads folder). To find this file and save it in your backup system (e.g. a hard drive), go to the Calibre library menu, select Switch/Create library, and it will show you where the current library is. In my case, it's in the very unsurprising /Users/sole/Calibre Library.

Open that folder using your file explorer or finder or whatever, and find the folder with the name of the author of the book. There will be another folder inside, for the book. There you will find the AZW3 file and... the MOBI file!

You can copy this mobi file to your archival hard drive and feel all comforted in the knowledge that you'll still be able to be able to read this content if your Kindle device breaks, or if Amazon goes POOOF, etc.

You can also import multiple books at once (although you still have to download them one by one), and convert multiple in "Bulk" with the corresponding option.

What I tried and did not work

Removing the DRM from AZW3 files in the Kindle device

Mounting the Kindle device via USB and pulling the files into the computer, then importing them onto Calibre and trying to convert them to Mobi did not work.

I looked at the debug log and while it seemed to find some keys, it failed at some point in the decrypting phase.


Removing the DRM from KFX books from the Kindle Reader for Mac

The KFX format is like The Cool Kid In The Block, as it contains the bigger size pictures, richer typography, etc. It is also terribly proprietary it seems, and Calibre cannot open it by default.

Fortunately, there's another plugin that someone had kindly provided, the KFX conversion input plugin. You download and install it the same way as the DeDRM plugin, and in theory it would detect when a KFX file is imported into Calibre, and convert it into something that Calibre can handle.

You get the KFX files if using the Kindle reader for Mac (or for Windows), although you have to either download an old copy of the reader or inutilise a file that enables some sort of advanced KFX format usage, by setting its permission to chmod -x. This forces the Kindle for Mac to use an older version of KFX whose format has been successfully reverse engineered (I think).

You have to find the folder where the Kindle reader downloads the files. In my case it's in /Users/sole/Library/Containers/ Support/Kindle/My Kindle Content/ - so it requires "a bit" of navigation. There, there is a cryptic named folder per book (apparently the "cryptic" folder name is the ASIN which I think is like the Amazon ID for the book).

In theory the process should be the same as before: grab the encrypted file, import into Calibre, then convert to something else.

I am not 100% sure of which key does it use to decrypt files. I think it uses the same operating system user name and something else it pulls from your Kindle reader for Mac (or for Windows) copy.

I also looked at the debug logs, and I saw it successfully finding keys and decrypting some things, but it failed at some point.

I had a big headache at that point, so I let it be. I might again try some time in the future, but for now I am happy that I understood the workflow of how this DRM removal is achieved.

And if this post was useful for you, why not buy some of my music from Bandcamp? 😃