planka icon indicating copy to clipboard operation
planka copied to clipboard

Help Needed: Upgrading postgres version from postgres:14-alpine to postgres:16-alpine

Open jaimedmp opened this issue 1 year ago • 4 comments

Is this a feature for the backend or frontend?

Backend

What would you like?

Hi, I need some help or suggestions.

Current Planka version: 1.24.1

In the Planka GitHub repository, the docker-compose.yml file specifies the image for PostgreSQL as:

image: postgres:16-alpine

However, on my premises, it's currently set to:

image: postgres:14-alpine

I would like to update my docker-compose.yml file to use postgres:16-alpine.

  • Should I proceed with this update?
  • Will Docker Compose handle the upgrade without any issues, or do I need to prepare or adjust anything beforehand?

Thank you for your guidance!

Why is this needed?

N/A

Other information

N/A

jaimedmp avatar Nov 19 '24 04:11 jaimedmp

Hi! We'll add this to the docs soon.

meltyshev avatar Nov 19 '24 14:11 meltyshev

Thank you for your response.

jaimedmp avatar Nov 20 '24 01:11 jaimedmp

So these are the steps i followed that worked successfully -

  1. Backup your database (x2 to be safe)
docker compose exec postgres pg_dump -U postgres -d planka -cC > upgrade_backup_pg14.sql
  1. Shutdown database, create a backup volume and do a volume backup (you may have to adjust names)
docker compose down
docker volume create planka_database_backup
docker run --rm -v docker-planka_db-data:/from -v planka_database_backup:/to alpine sh -c 'cd /from && cp -a . /to'
  1. Make sure step 2 is done and you have the sql and data volumes, then remove the old volume (why docker dont add a docker rename volume option..?)
docker volume rm docker-planka_db-data
  1. Edit the docker-compose.yml and network_mode: none to the postgres config and change image: postgres:14-alpine to image: postgres:16-alpine

  2. Pull the updated image, force recreate postgres database and apply your backup

docker compose pull
docker compose up --force-recreate -d postgres
cat upgrade_backup_pg14.sql | docker compose exec -T postgres psql -U postgres
  1. Edit docker-compose.yml and remove the network_mode: none, then rerun the recreate
docker compose up --force-recreate -d

Test!

PS thanks for an awesome open source project

nbx3 avatar Feb 14 '25 13:02 nbx3

Hi,

I am having an error when I try to run docker compose up --force-recreate -d postgres. I made sure that I follow the previous steps.

postgres-1 | postgres-1 | PostgreSQL Database directory appears to contain a database; Skipping initialization postgres-1 | postgres-1 | 2025-03-02 23:57:08.965 UTC [1] FATAL: database files are incompatible with server postgres-1 | 2025-03-02 23:57:08.965 UTC [1] DETAIL: The data directory was initialized by PostgreSQL version 14, which is not compatible with this version 16.8. postgres-1 exited with code 1

jaimedmp avatar Mar 03 '25 00:03 jaimedmp