Add README

This commit is contained in:
Pierre HUBERT 2024-12-07 23:09:31 +01:00
parent 02d4e55323
commit 677b1d980b

View File

@ -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
docker run -u 1000 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=password -v $(pwd)/test-db:/db --rm -it pierre42100/postgresmig:16to17
```