Creating and restoring PostgreSQL backups
Tech preview Tenant users can create a manual backup of PostgreSQL data in the tenant clusters by using the pg_dump command. Tenant users can also restore backup data by using the pg_restore command. Because an S3-compatible object storage is not available in the current version of IBM® Sovereign Core, create backups locally and manage them as a tenant user.
Before you begin
- You have access to the Red Hat® OpenShift cluster where the PostgreSQL instance is deployed.
- You are logged in to the
ocCLI with the required permissions. - You know the name of the PostgreSQL pod and the target database.
- You have local storage available for saving backup files.
Procedure
What to do next
- Move the backup file to a secure local directory.
- Optional: Set up a regular backup routine by using a CronJob, script, or scheduling tool.
Restore a PostgreSQL backup
- To restore from a plain SQL file, run:
oc exec -i <pod-name> -- psql -U postgres -d <database> < backup.sql - To restore from a custom-format backup, run:
pg_restore -U postgres -d <database> backup.dump