tianon / docker-postgres-upgrade

a PoC for using "pg_upgrade" inside Docker -- learn from it, adapt it for your needs; don't expect it to work as-is!
https://hub.docker.com/r/tianon/postgres-upgrade/
MIT License
1.04k stars 114 forks source link

script to review when username is not postgres - permission issue #94

Closed shuther closed 4 months ago

shuther commented 4 months ago

I tried to migrate from Postgres v14 to v15 The default user was different; the db is expected to start with POSTGRES_USER. This is causing issues to test pgbench (at least)

This is causing a problem (I guess) when I run:

docker run --rm \
    -v "$MIGRATE_OLD_FOLDER":/var/lib/postgresql \
    "tianon/postgres-upgrade:$OLD-to-$NEW" \
    --link

The logs are:

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/15/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgresql/15/data -l logfile start

initdb: warning: enabling "trust" authentication for local connections
initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.

could not open version file "/var/lib/postgresql/14/data/PG_VERSION": No such file or directory
Failure, exiting

I confirm that the file exists:

sudo cat $MIGRATE_OLD_FOLDER/PG_VERSION
14

I guess there is a permission issue. the old folder is owned by 999:0 (with drwx------)

Is there a way to enforce the uid for the upgrade process?