The database of our discourse instance is not a local container, instead we use a central database cluster. Recently the central postgresql was updated to version 18.3. I noticed that the discourse backup now fails:
[2026-05-19 03:37:37] [STARTED]
[2026-05-19 03:37:37] 'system' has started the backup!
[2026-05-19 03:37:37] Marking backup as running...
[2026-05-19 03:37:37] Making sure '/var/www/discourse/tmp/backups/default/2026-05-19-033737' exists...
[2026-05-19 03:37:37] Making sure '/var/www/discourse/public/backups/default' exists...
[2026-05-19 03:37:37] Updating metadata...
[2026-05-19 03:37:37] Dumping the public schema of the database...
[2026-05-19 03:37:37] pg_dump: error: aborting because of server version mismatch
[2026-05-19 03:37:37] pg_dump: detail: server version: 18.3 (Ubuntu 18.3-1.pgdg24.04+1); pg_dump version: 15.15 (Debian 15.15-1.pgdg12+1)
[2026-05-19 03:37:37] EXCEPTION: pg_dump failed
[2026-05-19 03:37:37] /var/www/discourse/lib/backup_restore/creator.rb:173:in 'BackupRestore::Creator#dump_public_schema'
/var/www/discourse/lib/backup_restore/creator.rb:36:in 'BackupRestore::Creator#run'
/var/www/discourse/lib/backup_restore.rb:13:in 'BackupRestore.backup!'
/var/www/discourse/app/jobs/regular/create_backup.rb:10:in 'Jobs::CreateBackup#execute'
This looks like a PostgreSQL client/server version mismatch.
The backup is being run from the Discourse container, where pg_dump is version 15.15, but the external PostgreSQL server is 18.3:
server version: 18.3; pg_dump version: 15.15
I’d be cautious about modifying the Discourse container unless the Discourse team recommends that. My first instinct would be to keep the external database cluster aligned with the PostgreSQL version Discourse currently expects/supports.
OK, understood. In this case I had no choice as we needed 18 for another project which uses the same database cluster. Hmm, sounds like we would need a separate database server with 15 exclusively for discourse.
I made a quick test with an external postgres 18 and a dummy discourse installation before, it showed no issues. But, to be honest, this was only “quick and dirty”, not a “deep” test. Anyway, it runs since 2 weeks, so I assume its fine. The Discourse-internal backup is the only issue so far. On the other hand, the database server itself (running on LXC) is also backuped separately.
The policy in the past has been to upgrade every other version. However, it has been 1.5 years since PostgreSQL 17 was released and the official Docker image still uses 15, so I’m not sure this is still the case.
You can add code to your app.yml to update postgres to the matching version. I’ve done it before, but can’t find my notes. The easiest thing to do is go into the container, issue the apt commands to get the right postgres clients installed and then try the backup. Once that works, you add those commands to exec commands in your app.yml so that it’ll work after the next rebuild.
If you need someone to walk you though it, you can email me or post in Marketplace.
Nice! I’d probably try to install specifically the pg18 client stuff so that it doesn’t switch to 19 at some point. Also, you’ll want to add these commands to your app.yml, unless you want to do this by hand at every upgrade.