Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker: upgrade from Postges 11/12 to a newer version #18085

Open
net47 opened this issue Jan 15, 2025 · 1 comment
Open

Docker: upgrade from Postges 11/12 to a newer version #18085

net47 opened this issue Jan 15, 2025 · 1 comment

Comments

@net47
Copy link

net47 commented Jan 15, 2025

Description

Since Postgres 11/12 is now deprecated, is there an official guide how to upgrade to a new Postgres version using Docker? Just changing the base image throws an error:

  db:
    image: docker.io/postgres:15-alpine
    container_name: synapse-db
    environment:
      - POSTGRES_DB=synapse
      - POSTGRES_USER=synapse
      - POSTGRES_PASSWORD=VerySecurePassword
      - POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C
    volumes:
      - db:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready"]
      interval: 5s
      timeout: 5s
      retries: 10
# docker logs synapse-db

PostgreSQL Database directory appears to contain a database; Skipping initialization

2025-01-15 07:09:06.003 UTC [1] FATAL:  database files are incompatible with server
2025-01-15 07:09:06.003 UTC [1] DETAIL:  The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 15.10.

Steps to reproduce

  • change the image tag from docker.io/postgres:12-alpine to docker.io/postgres:15-alpine

Homeserver

self-hosted homeserver

Synapse Version

{"server_version":"1.121.1"}

Installation Method

Docker (matrixdotorg/synapse)

Database

Postgres, single server, not ported but running Postgres from the beginning, no backup restored

Workers

Single process

Platform

Docker on Debian 12

Configuration

no unusual configuration, just using this homeserver.yaml:

...
database:
  name: psycopg2
  args:
    user: synapse
    password: VerySecurePassword
    dbname: synapse
    host: db
    cp_min: 5
    cp_max: 10
user_directory:
    enabled: true
    search_all_users: true
...

Relevant log output

PostgreSQL Database directory appears to contain a database; Skipping initialization

2025-01-15 07:09:06.003 UTC [1] FATAL:  database files are incompatible with server
2025-01-15 07:09:06.003 UTC [1] DETAIL:  The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 15.10.

Anything else that would be useful to know?

No response

@marrobHD
Copy link

Easiest would be dumping the database and importing it with a newer postgres version.
This guide gives good hints: https://thomasbandt.com/postgres-docker-major-version-upgrade

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants