This commit is contained in:
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
: "${BACKUP_DIR:?Set BACKUP_DIR to the destination directory}"
|
||||
: "${POSTGRES_DB:?Set POSTGRES_DB}"
|
||||
: "${POSTGRES_USER:?Set POSTGRES_USER}"
|
||||
: "${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD}"
|
||||
|
||||
timestamp=$(date -u '+%Y%m%dT%H%M%SZ')
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
output_path="$BACKUP_DIR/${POSTGRES_DB}-${timestamp}.dump"
|
||||
|
||||
docker compose -f compose.production.yaml exec -T \
|
||||
-e PGPASSWORD="$POSTGRES_PASSWORD" postgres \
|
||||
pg_dump -U "$POSTGRES_USER" -Fc "$POSTGRES_DB" > "$output_path"
|
||||
|
||||
printf '%s\n' "$output_path"
|
||||
Reference in New Issue
Block a user