docker
2019/10/19
PostgresDB
Migrate from version 11 to 12
- stop main container so only db container runs
- dump db:
docker exec -ti <db_container> pg_dumpall -U <user> > dump.sql
- copy volumes:
cp /var/lib/docker/volumes/<volume_name> .
- stop db container
- modify version in docker_compose.yml
rm -rf /var/lib/docker/volumes/<volume_name>/_data/*
docker_compose up <db_container>
cp dump.sql /var/lib/docker/volumes/<volume_name>/_data/
docker exec -ti <db_container> bash
cd /var/lib/postgres/data
psql -U <user> < dump.sql
- stop <db_container> and restart the whole stack