From 677b1d980ba3445a013fa83c4e3306bcea508da0 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 7 Dec 2024 23:09:31 +0100 Subject: [PATCH] Add README --- README.md | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e6a72ac..c12163e 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,22 @@ # Docker migration helper +This repo contains a `Dockerfile` that can helps you in performing your Docker images migration. -## Test -Create an outdated database +This repository will: + +* Perform a temporary copy the old database +* Initialize a new empty database with the default user / password couple provided as environment variables (`POSTGRES_USER` and `POSTGRES_PASSWORD`) +* Run `pg_upgrade` from the copy of the old database to the new database +* Replace the old database with the new one +* Move the copy of the old database as sub-directory of the new database (in `old_db` directory, to allow rollback in case of failure) + +## Perform the migration +Create an outdated database: ```bash mkdir test-db docker run --rm --name testdb -u 1000 -e POSTGRES_PASSWORD=password -v $(pwd)/test-db:/var/lib/postgresql/data -it postgres:16 ``` -Perform the migration: +Perform the migration (you need to replace `POSTGRES_USER` and `POSTGRES_PASSWORD` with the credentials of the root user of the database): ```bash -./build.sh && docker run -u 1000 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=password -v $(pwd)/test-db:/db --rm -it pierre42100/postgresmig:16to17 -``` \ No newline at end of file +docker run -u 1000 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=password -v $(pwd)/test-db:/db --rm -it pierre42100/postgresmig:16to17 +```