PostgreSQL Backup
PostgreSQL backup creates a complete SQL dump of all databases, roles, and configurations using pg_dumpall.
Backup Process:
The pgsql-backup.sh script performs the
following operations:
(Click the file name above to download the script.)
- Retrieves PostgreSQL credentials from Kubernetes secrets
- Locates the PostgreSQL pod and namespace automatically
- Tests connectivity to ensure the database is accessible
- Executes
pg_dumpallto create a complete cluster dump - Streams the output through gzip for compression
- Saves to
postgres-backup-<timestamp>.sql.gz
Running the Backup:
./pgsql-backup.sh
Expected Output:
========================================
PostgreSQL Backup Script
========================================
[i] Retrieving PostgreSQL password...
[✓] Retrieved
[i] Finding PostgreSQL pod...
[✓] Found: gv-postgresql-0 (namespace: default)
[i] Testing PostgreSQL connection...
[✓] Connected
[i] Creating full SQL dump (entire cluster)...
[✓] Archive created: 140K
========================================
Backup Complete
========================================
File: ./postgres-backup-20251103-130603.sql.gz
Size: 140K
What Gets Backed Up:
-
All databases (auth, agent, audit, bunzi, keycloak, shared, regex, db01, db02, ops, trustee, classification_tags)
-
All roles and permissions
-
Database schemas and table structures
-
All data with referential integrity preserved
-
Sequences, indexes, and constraints
Backup File Location: The backup file is created in the current directory with a timestamp in the filename.