Closed
Description
Summary
Current PGSQL backup assumes a database with the same name as the $DB_USER
exists. In my case, it does not exist, and there is a fatal error thrown in the log.
Steps to reproduce
Create a PGSQL container with $POSTGRES_USER
set to dummyuser
and $POSTGRES_DB
set to dummydb
, and take a backup with $DB_USER
set to dummyuser
and $DB_NAME
set to dummydb
.
What is the expected correct behavior?
User should be able to specify an "auth DB".
Relevant logs and/or screenshots
2023-10-30.12:24:49 [NOTICE] /etc/services.available/10-db-backup/run ** [db-backup] Dumping all PostgreSQL databases: 'xxx' and compressing with 'zstd:9' with '16' threads
++ psql -h xxx-postgresql -U scheduler -p 5432 -d xxx -c 'COPY (SELECT datname FROM pg_database WHERE datistemplate = false) TO STDOUT;'
psql: error: connection to server at "xxx-postgresql" (10.152.183.104), port 5432 failed: FATAL: database "xxx" does not exist
+ tmp_db_names=
++ echo ++ xxx
xargs
+ for r_db_name in $(echo $db_names | xargs)
++ echo ''
++ xargs
++ sed 's|xxx||g'
+ tmp_db_names=
+ sleep 5
+ + pg_dumpall -h xxx-postgresql -U xxx -p 5432
zstd -q -q --rm -9 -T16
+ exit_code=0
+ check_exit_code backup pgsql_all_xxx-postgresql_20231030-122449.sql.zst
+ print_debug 'DB Backup Exit Code is 0'
+ output_off
+ '[' true = true ']'
+ set +x
Environment
- Image version / tag: 3.11.1
- Host OS: Ubuntu Jammy
Any logs | docker-compose.yml
Possible fixes
Similar to how it works in Mongo, introduce a variable $DB_AUTH
in PGSQL as well. If it is set, take it as the $authdb
.