calibre - Seperate Database from Library
I’m using calibre to manage my e-book library and wanted to store the files (.epub
, .pdf
, etc.) on my NAS. But per default calibre puts the sqlite3 database in the same directory, and it is not recommended putting the database on a network share.
Fortunately, there is an environment variable that we can set to store the database file in a different location, i.e. directly in my home directory, and the library data itself can then be on the NAS.
Separate database configuration
I am using calibre 5.37 on a Kubuntu 22.04 system, installed from the apt package sources.
If you run calibre from the command line, you can simply set the environment variable CALIBRE_OVERRIDE_DATABASE_PATH
in the shell rc file. In my case .zshrc
:
export CALIBRE_OVERRIDE_DATABASE_PATH=$HOME/.calibre/
To make it as easy as possible to open calibre with an icon in the graphical user interface, you can customize the desktop file for calibre. You can either use the system-wide file or create your own customized version.
System-wide file
Just change the exec line in this file:
/usr/share/applications/calibre-gui.desktop
...
Exec=env CALIBRE_OVERRIDE_DATABASE_PATH=$HOME/.calibre/metadata.db calibre %U
...
Custom version
Copy the content of the system-wide file and also edit the Exec line as before and change the name so that you know this is the custom version.
~/.local/share/applications/calibre-gui.desktop
...
Name=calibre (user)
Exec=env CALIBRE_OVERRIDE_DATABASE_PATH=$HOME/.calibre/metadata.db calibre %U
...
Calibre library
The only problem I had was setting the library path to the mounted NAS directory, so I just created a symlink:
- Rename or delete (if you do not have your e-books there at the moment) the current directory
~/calibre-library
. - Create a symlink:
ln -s /mnt/NAS/calibre-library ~/calibre-library