Performing a backup
Configure automated PostgreSQL backups for IBM Bob databases and verify that backup jobs are running correctly.
Use this procedure to configure automated PostgreSQL backups for IBM Bob databases. After backups are configured, the operator automatically creates and manages scheduled backup jobs.
Before you begin
Before configuring backups, verify the following prerequisites:
- A supported storage class is available in the cluster.
- Database credential secrets exist.
- Sufficient storage capacity is allocated.
- PostgreSQL clusters are running and healthy.
Configure and enable backups
Create a backup ConfigMap that defines the backup schedule, retention policy, storage configuration, and target database clusters.
The operator automatically discovers any ConfigMap labeled with:
bob.ibm.com/backup-config: "true"Create the configuration file:
apiVersion: v1
kind: ConfigMap
metadata:
name: bob-postgres-backup-config
namespace: <bob-instance-namespace>
labels:
bob.ibm.com/backup-config: "true" # Required
app.kubernetes.io/name: bob
app.kubernetes.io/component: postgres-backup
data:
config.yaml: |
# Backup schedule in cron format (UTC timezone)
schedule: "0 2 * * *"
# Storage class for backup PVCs
backupStorageClass: "nfs-storage"
# Number of backups to retain per cluster (default: 7)
retention: 7
# Size of backup PVC per cluster (default: 10Gi)
pvcSize: "10Gi"
# Optional: PostgreSQL image override
# If not specified, image is auto-detected from running clusters
# postgresImage: "icr.io/cpopen/ibm-postgresql:16.4"
# Clusters to back up
# If omitted, defaults to bob-db and bob-keycloak-db
clusters:
- name: bob-db
database: bob
secretName: bob-db-app
- name: bob-keycloak-db
database: app # Note: Keycloak database is named "app"
secretName: bob-keycloak-db-appApply the ConfigMap:
oc apply -f backup-config.yamlEnable backup management in the Bob custom resource:
apiVersion: bob.ibm.com/v1beta1
kind: Bob
metadata:
name: bob-instance
namespace: <bob-instance-namespace>
spec:
postgresBackup:
enabled: true
suspend: falseThis setting instructs the operator to create and manage backup resources automatically.
Apply the updated custom resource:
oc apply -f bob-cr.yamlVerify that the operator successfully created the scheduled backup infrastructure.
Check CronJobs:
oc get cronjobs -n <bob-instance-namespace> -l app.kubernetes.io/component=postgres-backupExpected output:
NAME SCHEDULE SUSPEND ACTIVE LAST SCHEDULE AGE
bob-db-backup-cronjob 0 2 * * * False 0 <none> 1m
bob-keycloak-db-backup-cronjob 0 2 * * * False 0 <none> 1mCheck PVCs:
oc get pvc -n <bob-instance-namespace> -l app.kubernetes.io/component=postgres-backupCheck the backup script ConfigMap:
oc get configmap postgres-backup-script -n <bob-instance-namespace>Check Bob CR events:
oc describe bob bob-instance -n <bob-instance-namespace>IBM recommends running a manual backup after initial configuration. A test backup validates connectivity, permissions, storage configuration, and backup execution before relying on scheduled backups.
Create a one-time backup job from the generated CronJob:
# Manually create a job from the CronJob
oc create job --from=cronjob/bob-db-backup-cronjob manual-backup-$(date +%s) -n <bob-instance-namespace>
# Monitor the job
oc get jobs -n <bob-instance-namespace> -l app.kubernetes.io/component=postgres-backup
# View job logs
oc logs -n <bob-instance-namespace> job/manual-backup-<timestamp>After the backup finishes, validate that the backup files were created successfully.
Verify the following:
- The job completed successfully.
- The backup file exists.
- The metadata file exists.
- The backup size appears reasonable.
- No errors appear in the job logs.
# Check job status
oc get jobs -n <bob-instance-namespace> -l app.kubernetes.io/component=postgres-backup
# View backup logs
oc logs -n <bob-instance-namespace> -l app.kubernetes.io/component=postgres-backup --tail=50
# Access backup files
oc run backup-check -n <bob-instance-namespace> --image=busybox --rm -it --restart=Never \
--overrides='{
"spec": {
"containers": [{
"name": "backup-check",
"image": "busybox",
"command": ["sh"],
"stdin": true,
"tty": true,
"volumeMounts": [{
"name": "backup",
"mountPath": "/backups"
}]
}],
"volumes": [{
"name": "backup",
"persistentVolumeClaim": {
"claimName": "bob-db-backup-pvc"
}
}]
}
}'
# Inside the pod:
ls -lh /backups/bob-db/
cat /backups/bob-db/backup_bob_*.sql.gz.metaA successful backup produces output similar to the following:
==========================================
PostgreSQL Backup Script
==========================================
Cluster: bob-db
Database: bob
Timestamp: 20260902_020000
Backup file: /backups/bob-db/backup_bob_20260902_020000.sql.gz
Retention: 7 backups
==========================================
Starting pg_dump...
✓ Backup completed successfully
Size: 1.2G
✓ Metadata file created
Cleaning up old backups...
Current backup count: 7
✓ Cleanup completed
==========================================
✓ Backup process completed successfully
==========================================Configuration parameters
| Parameter | Required | Default | Description |
|---|---|---|---|
schedule | Yes | — | Cron schedule expression (UTC timezone). |
backupStorageClass | Yes | — | Storage class for backup PVCs. |
retention | No | 7 | Number of backups to retain per cluster. |
pvcSize | No | 10Gi | PVC size per cluster. |
postgresImage | No | Auto-detected | PostgreSQL image for backup jobs. |
clusters | No | Default clusters | List of clusters to back up. |
Storage sizing guidelines
To calculate the required storage per cluster:
Required size = (database size × 0.3) × retention × 1.5
Example:
- Database: 5 GB
- Compression: 0.3 (70% compression)
- Retention: 7 backups
- Safety factor: 1.5
Required: 5 × 0.3 × 7 × 1.5 = 15.75 GB ≈ 20 GB| Database size | Recommended PVC | Retention |
|---|---|---|
| Less than 1 GB | 5 Gi | 7 |
| 1–5 GB | 10 Gi | 7 |
| 5–20 GB | 50 Gi | 7 |
| 20–50 GB | 100 Gi | 5 |
| Greater than 50 GB | Custom | 3–5 |
Backup and restore
Configure, manage, and restore PostgreSQL database backups for IBM Bob on-premises to protect application data and support recovery scenarios.
Scheduling backups
Configure and manage automated PostgreSQL backup schedules for IBM Bob, including cron expressions, retention policies, suspend and resume, and monitoring.