Namespace Preparation: To keep resources isolated, create a dedicated namespace for this tutorial:
kubectl create ns demo
namespace/demo created
Preparing for Restoration: Locate one Full Backup
Before restoring, ensure that there is a full backup available. The restoration process will use this backup to create a new PostgreSQL cluster.
Backup repository accessible from new cluster
Valid full backup in Completed state
Adequate CPU/memory resources
Sufficient storage capacity
Find 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.
Step 1: Create Restored Cluster
Create a new cluster with restore configuration:
Key parameters:
kubeblocks.io/restore-from-backup annotation
Backup name and namespace located from the previous steps
apiVersion:apps.kubeblocks.io/v1kind:Clustermetadata:name:pg-restorednamespace:demoannotations:# NOTE: replcae <FULL_BACKUP_NAME> with the backup namekubeblocks.io/restore-from-backup:'{"postgresql":{"name":"<FULL_BACKUP_NAME>","namespace":"demo","volumeRestorePolicy":"Parallel"}}'spec:terminationPolicy:DeleteclusterDef:postgresqltopology:replicationcomponentSpecs:-name:postgresqlserviceVersion:16.4.0disableExporter:truelabels:apps.kubeblocks.postgres.patroni/scope:pg-restored-postgresqlreplicas:2resources:limits:cpu:"0.5"memory:"0.5Gi"requests:cpu:"0.5"memory:"0.5Gi"volumeClaimTemplates:-name:dataspec:storageClassName:""accessModes:-ReadWriteOnceresources:requests:storage:20Gi
Step 3: Monitor Restoration
Track restore progress with:
# Watch restore status
kubectl get restore -n demo -w
# Watch cluster status
kubectl get cluster -n demo -w
NOTE
Restore PostgreSQL cluster through kbcli or OpsRequest is not supported for now.
You can restore PostgreSQL cluster through kubectl as the steps above.
Cleanup
To remove all created resources, delete the PostgreSQL cluster along with its namespace: