Init cluster from backup

The initialData section allows you to create a new cluster and initilized the PGDATA from an existing backup. First you need to identify the backup you want to restore and get the backup’s UID:

kubectl get sgbackups --namespace $NAMESPACE $CLUSTER_BACKUP_NAME -o jsonpath="{.metadata.uid}"

This command will print the UID:

0a3bb287-6b3f-4309-87bf-8d7c4c9e1beb

Create the file sgcluster-from-backup.yaml that contains the UID from the previous step:

apiVersion: stackgres.io/v1
kind: SGCluster
metadata:
  name: stackgres
spec:
  initialData:
    restore:
      fromBackup: 0a3bb287-6b3f-4309-87bf-8d7c4c9e1beb

and deploy it to Kubernetes:

kubectl apply -f sgcluster-from-backup.yaml

Check the complete explanation about restoring a backup in the Restore a backup Runbook.