2528 shaares
85 private links
85 private links
Shows a step-by-step procedure to upgrad PG behind a docker container.
Can be adapted for other version differences.
Needed a few tweaks on my side, especially if using a different username/password/role, discussed here.
Successfully migrated my nextcloud database on-premises using the following:
export USNAME=<my-db-username>
export PAWOO=<my-db-password>
mkdir -p pg16
docker run --rm -v $(pwd)/nextcloud_db/_data:/var/lib/postgresql/12/data -v $(pwd)/pg16:/var/lib/postgresql/16/data -e POSTGRES_USER=$USNAME -e POSTGRES_PASSWORD=$PAWOO -e PGUSER=$USNAME -e POSTGRES_INITDB_ARGS="-U $USNAME" tianon/postgres-upgrade:12-to-16
Which then leaves me to move the resulting pg16 dir either into the other volume, overwriting existing data or just switching it around.
Take care that the pg16 directory that you are writing into exists but is completely empty otherwise there will be errors.