Restore data from backup set
KubeBlocks supports restoring clusters from backups with the following instructions.
View backups.
- kbcli
- kubectl
For existing clusters, execute:
kbcli cluster list-backups mysql-cluster
If the cluster has been deleted, execute:
kbcli dataprotection list-backups
kubectl get backups
Restore clusters from a specific backup.
- kbcli
- kubectl
# Restore new cluster
kbcli cluster restore myrestore --backup mybackup
>
Cluster myrestore created
# View the status of the restored cluster
kbcli cluster list myrestore
>
NAME NAMESPACE CLUSTER-DEFINITION VERSION TERMINATION-POLICY STATUS CREATED-TIME
myrestore default apecloud-mysql ac-mysql-8.0.30 Delete Running Oct 30,2023 16:26 UTC+0800You can set the
connectionPassword.annotations
of the restored cluster as that of the original cluster. The password of the original cluster can be accessed by viewing the annotation ofdataprotection.kubeblocks.io/connection-password
in the backup YAML file.kubectl apply -f - <<-'EOF'
apiVersion: apps.kubeblocks.io/v1alpha1
kind: Cluster
metadata:
name: myrestore
namespace: default
annotations:
kubeblocks.io/restore-from-backup: '{"mysql":{"name":"mybackup","namespace":"default","connectionPassword": "Bw1cR15mzfldc9hzGuK4m1BZQOzha6aBb1i9nlvoBdoE9to4"}}'
spec:
clusterDefinitionRef: apecloud-mysql
clusterVersionRef: ac-mysql-8.0.30
terminationPolicy: WipeOut
componentSpecs:
- name: mysql
componentDefRef: mysql
replicas: 1
volumeClaimTemplates:
- name: data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
EOFConnect to the restored cluster for verification. Once the cluster status is
Running
, connect to the cluster for verification.