17 lines
487 B
Bash
Executable File
17 lines
487 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
namespace=${NAMESPACE:-gramps}
|
|
pod=${POSTGRES_POD:-postgresql-0}
|
|
destination=${1:-"/tmp/gramps-postgresql-$(date +%Y%m%d-%H%M%S).sql.gz"}
|
|
umask 077
|
|
|
|
kubectl --namespace "${namespace}" exec "${pod}" -- bash -ec \
|
|
'PGPASSWORD="$(cat "${POSTGRES_PASSWORD_FILE}")" pg_dumpall --username=postgres' \
|
|
| gzip -9 > "${destination}"
|
|
gzip --test "${destination}"
|
|
test -s "${destination}"
|
|
echo "PostgreSQL backup written to ${destination} (mode 0600)."
|
|
|