Skip to content

Instantly share code, notes, and snippets.

@thomasstxyz
Created March 13, 2022 16:24
Show Gist options
  • Save thomasstxyz/17bd309779eb4c17e794f7f46d6e1cab to your computer and use it in GitHub Desktop.
Save thomasstxyz/17bd309779eb4c17e794f7f46d6e1cab to your computer and use it in GitHub Desktop.
Upgrade docker image postgres from 13 to 14

Guide: Upgrade docker image postgres from 13 to 14

Pull new new images

sudo docker-compose pull

Dump database

sudo docker-compose exec [service_name_of_postgres] pg_dumpall -U [postgres_user] > /tmp/dump.sql

Shutdown old container

sudo docker-compose down

Remove old volume

sudo docker volume rm [volume_name_of_postgres_data]

Start new container

sudo docker-compose up -d

Copy dump file into new volume

sudo cp /tmp/dump.sql /var/lib/docker/volumes/[volume_name_of_postgres_data]/_data/

Exec into the new container

sudo docker-compose exec [service_name_of_postgres] bash

Restore dump

cd /var/lib/postgresql/data/
psql -U [postgres_user] < dump.sql

Get psql shell and set passworw

The password needs to be set because version 13 used md5 algorithm and version 14 uses newer SCRAM-SHA-256 algorithm.

psql -U gitea
\password

# Enter the password at the prompt!

exit

exit

DONE!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment