.pgpass isn't working for replication_user when running pg_basebackup
Closed this issue · 1 comments
andyatkinson commented
Expected
- Copy .pgpass to db02 replica instance
- Connect to db02 as postgres user:
docker exec --user postgres -it db02 /bin/bash
- Run pg_basebackup from there, specifying
--username replication_user
- Do not supply password. Password for replication_user is read from ~/.pgpass
Actual
- Password is not read, and a prompt is made for it
Workaround
- Copy generated password to instance, and then supply password value using
PGPASSWORD
environment variable
Details
replication_user
is configured on primary usingpg_hba.conf
- Launching docker container as
postgres
user - Tried copying
.pgpass
to home directory ofpostgres
user, which isecho $HOME
, or/var/lib/postgresql/
- Docker container also has
root
user, tried using that postgres
user can'tchmod
the file, permission denied- Once replication starts,
postgresql.log
will show errors that password is not supplied, even if pg_basebackup is initially successful in grabbing a base backup. It's critical to monitor logs as well and make sure the password is being set correctly.
andyatkinson commented
Fixed in 5cf4007