# PostgreSQL Database Configuration Examples ## Complete Configuration with All Options ```xml Jellyfin-PostgreSQL NoLock Jellyfin-PostgreSQL Jellyfin.Database.Providers.Postgres Host=192.168.129.248;Port=5432;Database=jellyfin_testdata;Username=postgres;Password=YourPassword Host 192.168.129.248 Port 5432 Database jellyfin_testdata Username postgres Password YourPassword command-timeout 120 connection-timeout 30 max-pool-size 100 min-pool-size 0 disable-backups False /usr/bin/pg_dump /usr/bin/pg_restore custom true 6 1800 true ``` ## Quick Start Configurations ### Minimal Configuration (Local PostgreSQL) ```xml Jellyfin-PostgreSQL Host=localhost;Port=5432;Database=jellyfin;Username=jellyfin;Password=secret ``` ### Recommended Configuration (Local PostgreSQL with Backups) ```xml Jellyfin-PostgreSQL Host=localhost;Port=5432;Database=jellyfin;Username=jellyfin;Password=secret command-timeout 120 /usr/bin/pg_dump /usr/bin/pg_restore custom 6 ``` ### Remote PostgreSQL with Backups ```xml Jellyfin-PostgreSQL Host=192.168.1.100;Port=5432;Database=jellyfin;Username=jellyfin;Password=secret command-timeout 120 /usr/bin/pg_dump /usr/bin/pg_restore custom 6 3600 ``` ### Remote PostgreSQL WITHOUT Backups ```xml Jellyfin-PostgreSQL Host=192.168.1.100;Port=5432;Database=jellyfin;Username=jellyfin;Password=secret command-timeout 120 disable-backups True ``` ### High Performance Configuration ```xml Jellyfin-PostgreSQL Host=localhost;Port=5432;Database=jellyfin;Username=jellyfin;Password=secret command-timeout 180 max-pool-size 200 min-pool-size 10 /usr/bin/pg_dump /usr/bin/pg_restore directory 4 6 ``` ## Configuration Options Reference ### CustomProviderOptions → Options | Key | Type | Default | Description | |-----|------|---------|-------------| | `Host` | string | localhost | PostgreSQL server hostname or IP | | `Port` | int | 5432 | PostgreSQL server port | | `Database` | string | - | Database name | | `Username` | string | - | Database username | | `Password` | string | - | Database password | | `command-timeout` | int | 30 | Command timeout in seconds | | `connection-timeout` | int | 15 | Connection timeout in seconds | | `max-pool-size` | int | 100 | Maximum connection pool size | | `min-pool-size` | int | 0 | Minimum connection pool size | | `disable-backups` | bool | false | Disable backup/restore functionality | ### BackupOptions | Key | Type | Default | Description | |-----|------|---------|-------------| | `PgDumpPath` | string | pg_dump | Path to pg_dump binary (use full path if not in PATH) | | `PgRestorePath` | string | pg_restore | Path to pg_restore binary (use full path if not in PATH) | | `BackupFormat` | string | custom | Backup format: plain, custom, directory, tar | | `IncludeBlobs` | bool | true | Include large objects in backup | | `CompressionLevel` | int | 6 | Compression level (0-9, for custom/directory) | | `TimeoutSeconds` | int | 1800 | Backup/restore operation timeout | | `VerboseOutput` | bool | false | Log detailed backup/restore output | | `ParallelJobs` | int | 1 | Number of parallel jobs (directory format only) | | `AdditionalArguments` | string | - | Additional pg_dump/pg_restore arguments | ## Important Notes ### PostgreSQL Client Binaries The backup feature requires `pg_dump` and `pg_restore` command-line tools. These must be: 1. **In system PATH**, OR 2. **Specified with full paths** in BackupOptions **To install:** ```bash # Linux (Debian/Ubuntu) sudo apt-get install postgresql-client # Linux (Red Hat/CentOS) sudo yum install postgresql # Windows # Download from https://www.postgresql.org/download/windows/ # Select "Command Line Tools" during installation ``` **To verify:** ```bash # Check if in PATH pg_dump --version pg_restore --version # Find location which pg_dump # Linux/macOS Get-Command pg_dump # Windows PowerShell ``` ### Performance Indexes After initial setup, run the performance indexes SQL script: ```bash psql -U postgres -d your_database -f sql/add-performance-indexes.sql ``` This significantly improves query performance (3-15x faster). ### Backup Considerations - **Local databases:** Fast backups, full backup support - **Remote databases:** Slower (network transfer), but fully supported - **Disable backups:** If using external backup solutions or cloud-managed PostgreSQL - **Large databases:** Increase `TimeoutSeconds` and consider `directory` format with `ParallelJobs` ## Troubleshooting ### "pg_dump: command not found" or "pg_dump.exe not recognized" **Solution:** Install PostgreSQL client tools or specify full path: ```xml /usr/lib/postgresql/16/bin/pg_dump ``` ### "connection to server failed" **Solution:** Check: - Network connectivity: `telnet host port` - Firewall rules - PostgreSQL `pg_hba.conf` allows connections from your IP - Credentials are correct ### "Backup operation timed out" **Solution:** Increase timeout: ```xml 7200 ``` ### "Query timeout" **Solution:** Increase command timeout: ```xml command-timeout 180 ``` ## See Also - `docs/remote-postgresql-backup-support.md` - Detailed backup documentation - `docs/increase-database-timeout.md` - Query timeout information - `docs/COMPLETE-SESSION-SUMMARY.md` - All fixes and improvements - `sql/add-performance-indexes.sql` - Performance optimization indexes - `sql/monitor-query-performance.sql` - Query performance monitoring