kartoza / docker-pg-backup

A cron job that will back up databases running in a docker postgres container
GNU General Public License v2.0
452 stars 103 forks source link

Cannot change Postgres user name #21

Closed kaspernj closed 4 years ago

kaspernj commented 4 years ago

I am using Docker compose and have it set up like this:

dbbackup:
  image: kartoza/pg-backup:11.0
  hostname: pg-backups
  depends_on:
    - postgres
  volumes:
    - /mybackupspath:/backups
  environment:
    - DUMPPREFIX=myprefix
    - POSTGRES_USER=dev
    - POSTGRES_PASS=mypassword
    - POSTGRES_PORT=5432
    - POSTGRES_HOST=postgres
    - POSTGRES_DBNAME=mydatabasename

However if I open a terminal inside the container and execute cat pgenv.sh I get this:

export PGUSER=docker
export PGPASSWORD=mypassword
export PGPORT=5432
export PGHOST=postgres
export PGDATABASE=mydatabasename
export DUMPPREFIX=myprefix
export ARCHIVE_FILENAME=

I expected export PGUSER=dev but got export PGUSER=docker.

I haven't been able to figure out why this happens unfortunately.

NyakudyaA commented 4 years ago

@kaspernj I will look at it, I remember I once experienced this issue and the fix is so simple. If you want to look please take a look at https://github.com/kartoza/docker-pg-backup/blob/master/start.sh

kaspernj commented 4 years ago

@NyakudyaA I already looked a that file quite a lot, but I couldn't spot any errors. Also if I run echo $PGUSER it says dev so it has registered the environment variable correctly.

kaspernj commented 4 years ago

Also setting PGUSER=dev in docker-compose.yml fixes the username to dev.

NyakudyaA commented 4 years ago

@kaspernj Can you pull again the 11.0 image