Add PD to Serenity backup automation scaffolding
This commit is contained in:
22
automation/bin/pd_backup_postgres.sh
Executable file
22
automation/bin/pd_backup_postgres.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
# shellcheck disable=SC1091
|
||||
source "$SCRIPT_DIR/pd_backup_lib.sh"
|
||||
|
||||
stamp="$(timestamp_utc)"
|
||||
dbs="${POSTGRES_DB_LIST:-}"
|
||||
|
||||
if [[ -z "$dbs" ]]; then
|
||||
echo "POSTGRES_DB_LIST is empty; nothing to dump." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for db in $dbs; do
|
||||
out="$PD_DB_DUMP_ROOT/${db}_${stamp}.sql.gz"
|
||||
echo "Dumping Postgres database '$db' to $out"
|
||||
docker_cmd exec "$POSTGRES_CONTAINER" pg_dump -U postgres "$db" | gzip -9 > "$out"
|
||||
done
|
||||
|
||||
echo "Postgres dumps complete: $PD_DB_DUMP_ROOT"
|
||||
Reference in New Issue
Block a user