This document will go over the key points of migrating and setting up Postgres support in Readarr.
This guide was been created by the amazing Roxedus.
Postgres databases are NOT backed up by Readarr, any backups must be implemented and maintained by the user
First, we need a Postgres instance. This guide is written for usage of the
postgres:14 Docker image.
Do not even think about using the
docker create --name=postgres14 \ -e POSTGRES_PASSWORD=qstick \ -e POSTGRES_USER=qstick \ -e POSTGRES_DB=readarr-main \ -p 5432:5432/tcp \ -v /path/to/appdata/postgres14:/var/lib/postgresql/data \ postgres:14
Readarr needs two databases, the default names of these are:
readarr-mainThis is used to store all configuration and history
readarr-logThis is used to store events that produce a logentry
readarr-cacheThis is used to store GoodReads cache
Readarr will not create the databases for you. Make sure you create them ahead of time
You can give the databases any name you want but make sure
config.xml file has the correct names. For further information see schema creation.
We need to tell Readarr to use Postgres. The
config.xml should already be populated with the entries we need:
<PostgresUser>qstick</PostgresUser> <PostgresPassword>qstick</PostgresPassword> <PostgresPort>5432</PostgresPort> <PostgresHost>postgres14</PostgresHost>
If you want to specify a database name then should also include the following configuration:
<PostgresMainDb>MainDbName</PostgresMainDb> <PostgresLogDb>LogDbName</PostgresLogDb> <PostgresCacheDb>CacheDbName</PostgresCacheDb>
Only after creating both databases you can start the Readarr migration from SQLite to Postgres.
If you do not want to migrate a existing SQLite database to Postgres then you are already finished with this guide!
To migrate data we can use PGLoader. It does, however, have some gotchas:
--with "quote identifiers"to make them sensitive.
Do not drop any tables in the Postgres instance
Before starting a migration please ensure that you have run Readarr against the created Postgres databases at least once successfully. Begin the migration by doing the following:
DELETE FROM "QualityProfiles";
DELETE FROM "QualityDefinitions";
DELETE FROM "DelayProfiles";
DELETE FROM "MetadataProfiles";
Start the migration by using either of these options:
pgloader --with "quote identifiers" --with "data only" readarr.db 'postgresql://qstick:qstick@localhost/readarr-main'
docker run -v /absolute/path/to/readarr.db:/readarr.db --network=host ghcr.io/roxedus/pgloader --with "quote identifiers" --with "data only" /readarr.db "postgresql://qstick:qstick@localhost/readarr-main"
With these handled, it is pretty straightforward after telling it to not mess with the scheme using
--with "data only"