mirror of
https://github.com/prodrigestivill/docker-postgres-backup-local.git
synced 2026-05-31 08:37:58 +00:00
Add support for PGPASSFILE for clusters #30
This commit is contained in:
@@ -18,6 +18,7 @@ ENV POSTGRES_DB="**None**" \
|
||||
POSTGRES_USER_FILE="**None**" \
|
||||
POSTGRES_PASSWORD="**None**" \
|
||||
POSTGRES_PASSWORD_FILE="**None**" \
|
||||
POSTGRES_PASSFILE_STORE="**None**" \
|
||||
POSTGRES_EXTRA_OPTS="-Z9" \
|
||||
SCHEDULE="@daily" \
|
||||
BACKUP_DIR="/backups" \
|
||||
|
||||
@@ -18,6 +18,7 @@ ENV POSTGRES_DB="**None**" \
|
||||
POSTGRES_USER_FILE="**None**" \
|
||||
POSTGRES_PASSWORD="**None**" \
|
||||
POSTGRES_PASSWORD_FILE="**None**" \
|
||||
POSTGRES_PASSFILE_STORE="**None**" \
|
||||
POSTGRES_EXTRA_OPTS="-Z9" \
|
||||
SCHEDULE="@daily" \
|
||||
BACKUP_DIR="/backups" \
|
||||
|
||||
@@ -69,6 +69,7 @@ Most variables are the same as in the [official postgres image](https://hub.dock
|
||||
| POSTGRES_HOST | Postgres connection parameter; postgres host to connect to. Required. |
|
||||
| POSTGRES_PASSWORD | Postgres connection parameter; postgres password to connect with. Required. |
|
||||
| POSTGRES_PASSWORD_FILE | Alternative to POSTGRES_PASSWORD, for usage with docker secrets. |
|
||||
| POSTGRES_PASSFILE_STORE | Alternative to POSTGRES_PASSWORD in [passfile format](https://www.postgresql.org/docs/12/libpq-pgpass.html), for usage with postgres clusters. |
|
||||
| POSTGRES_PORT | Postgres connection parameter; postgres port to connect to. Defaults to `5432`. |
|
||||
| POSTGRES_USER | Postgres connection parameter; postgres user to connect with. Required. |
|
||||
| POSTGRES_USER_FILE | Alternative to POSTGRES_USER, for usage with docker secrets. |
|
||||
|
||||
@@ -22,8 +22,8 @@ if [ "${POSTGRES_USER}" = "**None**" -a "${POSTGRES_USER_FILE}" = "**None**" ];
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${POSTGRES_PASSWORD}" = "**None**" -a "${POSTGRES_PASSWORD_FILE}" = "**None**" ]; then
|
||||
echo "You need to set the POSTGRES_PASSWORD or POSTGRES_PASSWORD_FILE environment variable or link to a container named POSTGRES."
|
||||
if [ "${POSTGRES_PASSWORD}" = "**None**" -a "${POSTGRES_PASSWORD_FILE}" = "**None**" -a "${POSTGRES_PASSFILE_STORE}" = "**None**" ]; then
|
||||
echo "You need to set the POSTGRES_PASSWORD or POSTGRES_PASSWORD_FILE or POSTGRES_PASSFILE_STORE environment variable or link to a container named POSTGRES."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -44,12 +44,14 @@ else
|
||||
echo "Missing POSTGRES_USER_FILE file."
|
||||
exit 1
|
||||
fi
|
||||
if [ "${POSTGRES_PASSWORD_FILE}" = "**None**" ]; then
|
||||
if [ "${POSTGRES_PASSWORD_FILE}" = "**None**" -a "${POSTGRES_PASSFILE_STORE}" = "**None**" ]; then
|
||||
export PGPASSWORD="${POSTGRES_PASSWORD}"
|
||||
elif [ -r "${POSTGRES_PASSWORD_FILE}" ]; then
|
||||
export PGPASSWORD=$(cat "${POSTGRES_PASSWORD_FILE}")
|
||||
elif [ -r "${POSTGRES_PASSFILE_STORE}" ]; then
|
||||
export PGPASSFILE="${POSTGRES_PASSFILE_STORE}"
|
||||
else
|
||||
echo "Missing POSTGRES_PASSWORD_FILE file."
|
||||
echo "Missing POSTGRES_PASSWORD_FILE or POSTGRES_PASSFILE_STORE file."
|
||||
exit 1
|
||||
fi
|
||||
POSTGRES_HOST_OPTS="-h ${POSTGRES_HOST} -p ${POSTGRES_PORT} ${POSTGRES_EXTRA_OPTS}"
|
||||
|
||||
Reference in New Issue
Block a user