PostgreSQL backup configuration
There are the following jobs for backups management:
-
CronJob for backups creation (running by a schedule
postgresBackup.schedule
) -
CronJob for backups rotation (running by a schedule
postgresBackup.rotationSchedule
)
Backup configuration values (postgresBackup
prefix):
-
enabled
- boolean flag for enabling/disabling backups -
schedule
- cron-like schedule for backups -
rotationSchedule
- cron-like schedule for backups rotation -
maxNumber
- maximum number of backups to store -
image
- Docker image containingpotgres
andminio
(client) binaries (opennode/postgres-minio by default)
Backups restoration
To restore backups you need to connect to the restoration pod. The major prerequisite for this is stopping the Waldur backend pods to avoid errors. NB: During restoration process, the site will be unavailable. For this, please execute the following lines in the Kubernetes node:
1 2 3 4 5 6 |
|
This will give you access to a terminal of a restoration pod. In this shell, please, execute the command:
1 |
|
This will print the recent 5 backups available for restoration. Example:
1 2 3 4 5 6 7 8 9 10 11 |
|
As you can see, the backup name contains the date and time when it was created in YYYY-mm-dd-HH-MM
format. You can freely choose the one you need.
1 2 3 4 5 6 7 8 9 10 |
|
Restoration from external backup
If you want to use a pre-created backup from an external system, copy the backup file:
- Copy the backup file to your local machine
-
Copy the file to pod
1 2
export RESTORATION_POD_NAME=$(kubectl get pods --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' | grep restore) kubectl cp <BACKUP_FILE> $RESTORATION_POD_NAME:/tmp/backup.sql.gz
-
Connect to pod's terminal
1
kubectl exec -it $RESTORATION_POD_NAME -- bash
-
Apply the backup
1 2 3 4 5 6 7
gzip -d /tmp/backup.sql.gz # Be careful: the next lines have potentially danger operations psql -d postgres -c "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'waldur' AND pid <> pg_backend_pid();" psql -d postgres -c 'DROP DATABASE waldur;' createdb waldur psql -f /tmp/backup.sql rm /tmp/backup.sql