Migrate docker postgres databases with pg_dump¶
The secure way¶
Step by step tutorial to migrate database from postgres 10 to 12 using docker.
Start by setting env vars.
Backup all databases and db volumes
docker exec $DB_CONTAINER pg_dumpall --username=$DB_USER > backup.sql
docker-volume-backup -a -c $APP_CONTAINER
docker-volume-backup -a -c $DB_CONTAINER
Stop datatabase and kill volume (if volume name is the same).
Update the image tag and rename volume if necessary.
Deploy database container with version 12.
Restore the data.
This may take a while as all statements are executed.
Restart the application container.
The insecure way¶
Start by setting env vars.
Stop app container.
Dump all databases.
Update the image tag and rename volume if necessary.
Deploy database container with the new version.
Restore the data.
Start app container.
Test, cleanup and remove obsolete volume.
Backlinks
đź”— PostgreSQL Upgrade