andyatkinson/rideshare

.pgpass isn't working for replication_user when running pg_basebackup

Closed this issue · 1 comments

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 using pg_hba.conf
  • Launching docker container as postgres user
  • Tried copying .pgpass to home directory of postgres user, which is echo $HOME, or /var/lib/postgresql/
  • Docker container also has root user, tried using that
  • postgres user can't chmod 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.

Fixed in 5cf4007