Operations
Backup And Restores
Custom Secret
Monitoring
tpl
Operations
Backup And Restores
Custom Secret
Monitoring
tpl
This guide demonstrates two methods to restore a PostgreSQL cluster from backup in KubeBlocks:
Before proceeding, ensure the following:
kubectl create ns demo
namespace/demo created
Before restoring, ensure that there is a full backup available. The restoration process will use this backup to create a new PostgreSQL cluster.
Completed
stateFind available full backups:
kubectl get backup -n demo -l dataprotection.kubeblocks.io/backup-type=Full,app.kubernetes.io/instance=pg-cluster # get the list of full backups
Pick ONE of the Backups whose status is Completed
.
Create a new cluster with restore configuration:
Key parameters:
kubeblocks.io/restore-from-backup
annotationapiVersion: apps.kubeblocks.io/v1
kind: Cluster
metadata:
name: pg-restored
namespace: demo
annotations:
# NOTE: replcae <FULL_BACKUP_NAME> with the backup name
kubeblocks.io/restore-from-backup: '{"postgresql":{"name":"<FULL_BACKUP_NAME>","namespace":"demo","volumeRestorePolicy":"Parallel"}}'
spec:
terminationPolicy: Delete
clusterDef: postgresql
topology: replication
componentSpecs:
- name: postgresql
serviceVersion: 16.4.0
disableExporter: true
labels:
apps.kubeblocks.postgres.patroni/scope: pg-restored-postgresql
replicas: 2
resources:
limits:
cpu: "0.5"
memory: "0.5Gi"
requests:
cpu: "0.5"
memory: "0.5Gi"
volumeClaimTemplates:
- name: data
spec:
storageClassName: ""
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
Track restore progress with:
# Watch restore status
kubectl get restore -n demo -w
# Watch cluster status
kubectl get cluster -n demo -w
Restore PostgreSQL cluster through kbcli
or OpsRequest
is not supported for now.
You can restore PostgreSQL cluster through kubectl
as the steps above.
To remove all created resources, delete the PostgreSQL cluster along with its namespace:
kubectl delete cluster pg-cluster -n demo
kubectl delete cluster pg-cluster-restored -n demo
kubectl delete ns demo
This guide covered two restoration methods:
Cluster Annotation - Simple YAML-based approach
OpsRequest API - Enhanced operational control