Example done from an upgrade from 12.5 to 15.4
App is a Rails app, the default container user has limited access and no direct sql/psql access
- build the image with current pg version & docker compose up
docker exec -it <NAME_OF_CONTAINER> pg_dump <NAME_OF_PRIMARY_DB> > db.out -U postgres- had issues doing pg_dumpall; wondering if the default postgres database interferred?
- backup the data from the volume. I store in a tmp folder in the repo.
- clear the folder your data is saved in or delete the volume
- update the postgres version in docker compose, run docker compose build & up
- service should start and create default database if configured to do so
- copy the db.out into the database container:
docker psand copy the ID of the containerdocker cp db.out <ID>:/db.out
- Load the db from the dump file
docker exec -it <NAME_OF_DATABASE_CONTAINER> /bin/bashlsto ensure the db.out file is presentpsql <DATABSE_NAME> < db.out -U postgres- substititute
postgresfor the name of the db connection user as-needed
- substititute