Backup and Restore v0.0.15
This guide explains how to take backups of PostgreSQL clusters managed by CloudNativePG and restore them using Klio.
Overview
Klio follows PostgreSQL's native physical backup and recovery mechanisms,
leveraging CloudNativePG's backup and restore capabilities through its
Backup resource
and
ScheduledBackup resource.
A working online backup is composed of:
- A physical base backup: A filesystem copy of the PostgreSQL data directory.
- A set of WAL (Write-Ahead Log) files: Continuous logs of all changes made to the database during the entire period of the base backup.
Important
It is recommended to periodically test backup restores to ensure correct recovery procedures.
Prerequisites
Before performing backup and restore operations, ensure you have:
- A running Klio server with proper configuration
- A PostgreSQL cluster configured with the Klio plugin
Taking a Backup
With the Klio plugin configured, you can take on-demand backups using
CloudNativePG's Backup resource
or the Kubectl plugin
for CNPG.
Create a Backup
You can trigger a new backup by creating a Backup resource.
apiVersion: postgresql.cnpg.io/v1 kind: Backup metadata: name: my-cluster-backup-20251027 namespace: default spec: method: plugin target: primary cluster: name: my-cluster pluginConfiguration: name: klio.enterprisedb.io
Apply the manifest:
kubectl apply -f backup.yamlAlternatively, you can request a backup directly using the
kubectl cnpg plugin:
kubectl cnpg backup my-cluster \ --method plugin \ --plugin-name klio.enterprisedb.io \ --backup-target primary
If you don’t specify the --backup-name option, the cnpg backup command
automatically generates one using the format <CLUSTER_NAME>-<YYYYMMDDhhmmss>,
which is suitable in most cases.
For a complete list of available options, run:
kubectl cnpg backup --helpMonitor Backup Progress
Check the backup status:
# Watch the backup status kubectl get backup my-cluster-backup-20251027 -w # Get detailed backup information kubectl describe backup my-cluster-backup-20251027
A successful backup will show:
NAME AGE CLUSTER METHOD PHASE ERROR my-cluster-backup-20251027 2m my-cluster plugin Completed
Scheduled Backups
You can schedule automatic backups using CloudNativePG's
ScheduledBackup resource.