Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / scripts/backup-tenant.sh |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | bdacd9d0b4d5998d25fc74bf4007f4c3ec538c7a |
| Branch | deploy-and-ops |
| Path or archive member | scripts/backup-tenant.sh |
| Original SHA-256 | 249408567b2865f47a4d9063d013fdcaf480a96030477e3af09f66b9a7fe4ab5 |
| Git blob SHA | 765e8d01e1ad0a0cf58ea09234555667b23f3859 |
| Reading-copy SHA-256 | 249408567b2865f47a4d9063d013fdcaf480a96030477e3af09f66b9a7fe4ab5 |
Recovered source transcript
Download complete source text ↓36 lines · 1.5 KB
#!/usr/bin/env bash
# Back up ONE tenant database to a PostgreSQL custom format archive. A single pg_dump of the whole tenant
# database captures the public schema, the segregated eeo schema, both goose version tables, and the
# pgvector data in one internally consistent snapshot. The tenant can stay online during a backup.
#
# Do NOT dump per schema with -n (a -n dump does not include dependencies and is not guaranteed to restore
# into a clean database). Pin the client to PostgreSQL 16 to match the server (set PGBIN to the PG16 bin
# dir if pg_dump on PATH is a different major version).
#
# Usage:
# scripts/backup-tenant.sh -dsn "host=H port=5432 user=missionmatch_migrator password=... dbname=tenant_acme sslmode=disable" [-out FILE]
set -euo pipefail
PGBIN="${PGBIN:-}"
dsn=""
out=""
while [ $# -gt 0 ]; do
case "$1" in
-dsn) dsn="$2"; shift 2 ;;
-out) out="$2"; shift 2 ;;
*) echo "backup-tenant: unknown argument $1" >&2; exit 2 ;;
esac
done
[ -n "$dsn" ] || { echo "backup-tenant: -dsn (migrator DSN to the tenant database) is required" >&2; exit 2; }
pgdump="${PGBIN:+$PGBIN/}pg_dump"
ver="$("$pgdump" --version | grep -oE '[0-9]+' | head -1)"
[ "$ver" = "16" ] || echo "backup-tenant: WARNING pg_dump major version is $ver, the server is 16; set PGBIN to the PG16 bin dir" >&2
ts="$(date +%Y%m%d%H%M%S)"
[ -n "$out" ] || out="tenant-backup-$ts.dump"
echo "backup-tenant: dumping (custom format) to $out"
"$pgdump" -Fc -d "$dsn" -f "$out"
echo "backup-tenant: DONE $out ($(du -h "$out" | cut -f1))"