This plugin adds postgres SQL support to Jellyfin Server.
Important
Pleae note that there are several additional steps required to make this work and it is to be considered HIGHLY experimental.
You can use your existing Jellyfin compose file and change the image accordingly to: ghcr.io/jpvenson/jellyfin.pgsql:10.11.8-1.
You need to add the connection parameters as enviornment variables in your compose file:
services:
jellyfin:
image: ghcr.io/jpvenson/jellyfin.pgsql:10.11.8-1
volumes:
- /path/to/config:/config
- /path/to/cache:/cache
- /path/to/media:/media
environment:
- POSTGRES_HOST=
- POSTGRES_PORT=
- POSTGRES_DB=jellyfin
- POSTGRES_USER=jellyfin
- POSTGRES_PASSWORD=jellyfin
# Optional settings bellow, uncomment if you want to connect using SSL
# - POSTGRES_SSLMODE=Require
# - POSTGRES_TRUSTSERVERCERTIFICATE=trueCheckout the Jellyfin submodule.
Use dotnet build to build the plugin.
Place the plugin in the plugins folder of the Jellyfin app.
Update the database.xml file to switch to the plugin as its database provider:
<?xml version="1.0" encoding="utf-8"?>
<DatabaseConfigurationOptions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<DatabaseType>PLUGIN_PROVIDER</DatabaseType>
<CustomProviderOptions>
<PluginAssembly>../../../Jellyfin.Plugin.Pgsql/bin/debug/net9.0/Jellyfin.Plugin.Pgsql.dll</PluginAssembly>
<PluginName>PostgreSQL</PluginName>
<ConnectionString>CONNECTION_STRING_TO_LOCAL_PGSQL_SERVER</ConnectionString>
</CustomProviderOptions>
<LockingBehavior>NoLock</LockingBehavior>
</DatabaseConfigurationOptions>
Launch your Jellyfin server.
Run dotnet ef migrations add {MIGRATION_NAME} --project "/workspaces/Jellyfin.Pgsql/Jellyfin.Plugin.Pgsql" -- --migration-provider Jellyfin-PgSql
To create a new release, first sync all Jellyfin server changes then create a new migration as seen above. After that create a new efbundle:
dotnet ef migrations bundle -o docker/jellyfin.PgsqlMigrator.dll -r linux-x64 --self-contained --project "/workspaces/Jellyfin.Pgsql/Jellyfin.Plugin.Pgsql" -- --migration-provider Jellyfin-PgSql
Then build the container.
To migrate your existing Jellyfin instance to a custom database (not using the docker image) follow the steps IN THIS ORDER.
- Download the Jellyfin PGSQL container and configure it to point to an existing empty database and empty config directory. DO NOT USE YOUR EXISTING DATA OR SQLITE LIBRARY CONFIGURE A FULLY CLEAR INSTANCE.
- Run Jellyfin once with it configured to your empty database, this will seed the database and its migration history.
- Stop your Jellyfin instance after it has been started once (no need to fully configure it via the setup wizard). If you did not get the setup wizard then you did something wrong!
- Install the pgloader tool
apt install pgloaderor see https://pgloader.readthedocs.io/en/latest/install.html. - Download the jellyfindb.load file
- Adapt the
jellyfindb.loadfile accordingly to point towards your old jellyfin.db and your postgres instance. See https://pgloader.readthedocs.io/en/latest/ref/sqlite.html - Use the load file in
jellyfindb.loadto transfer your sqlite db into the postgres db likepgloader /jellyfin-pgsql/jellyfindb.load. - Move your old Data back to the Jellyfin directories
- Start Jellyfin
If you get an error regarding a missing __EFMigrationsHistory you did not start Jellyfin with a clear state.