Mind Dump, Tech And Life Blog
written by Ivan Alenko
published under license Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)copy! share!
posted in category Systems Software / Postgres
posted at 04. Jun '20
last updated at 12. May '21

Howto Upgrade Postgres (in Docker)

This process has downtime. Using docker-compose in this scenario.

  1. Dump the database (pg_dumpall --user postgres > dump10.1-2020-06-04.sql, or user root)
  2. docker-compose down
  3. Back up physical files (only needed if everything goes to hell - tar -cvpzf postgresfiles10.1-2020-06-04.tar.gz /var/lib/path-to-db-files)
  4. UPGRADE POSTGRES VERSION IN DOCKER-COMPOSE.YML
  5. docker-compose up db (start only db container, not other stuff)
  6. Another terminal docker exec -it hash-of-db-container /bin/bash (find out hash with docker ps)
  7. cat data/dump10.1-2020-06-04.sql | psql --user postgres - load dump to newer version of postgres
  8. Stop it and run the whole app

Detailed info https://www.postgresql.org/docs/10/upgrading.html.

Add Comment