reference
- https://docs.pingcap.com/zh/tidb-in-kubernetes/stable/backup-restore-cr
- https://github.com/pingcap/tidb-operator/blob/master/pkg/apis/pingcap/v1alpha1/types.go#L1912
- https://asktug.com/t/topic/1042360
introduction
prepare
- optional: only for local storage
- requirements
- for backup/restore by br,
local://
protocol requires a local path in tikv to store the backup/restore files - therefore, we need to create a pvc to mount the local path in tikv
- for backup/restore by br,
- prepare
backup.pvc.yaml
-
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: tidb-cluster-backup-pvc namespace: tidb-cluster spec: accessModes: - ReadWriteMany resources: requests: storage: 20Gi storageClassName:
- apply to the cluster
-
kubectl -n tidb-cluster apply -f backup.pvc.yaml
-
-
- patch the tidb cluster
-
kubectl -n tidb-cluster patch tidbcluster basic --type=merge -p '{"spec":{"tikv":{"additionalVolumes":[{"name":"backup","persistentVolumeClaim":{"claimName":"tidb-cluster-backup-pvc"}}],"additionalVolumeMounts":[{"name":"backup","mountPath":"/backup"}]}}}'
- check and waiting for the cluster status to be ready
-
kubectl -n tidb-cluster get tidbcluster basic -w
-
-
- perpare default service account
tidb-backup-manager
-
apiVersion: v1 kind: ServiceAccount metadata: name: tidb-backup-manager namespace: tidb-cluster --- apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: tidb-backup-manager-role namespace: tidb-cluster rules: - apiGroups: ["pingcap.com"] resources: - backups - restores verbs: - list - get - update - watch - patch - create - delete --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: tidb-backup-manager-rolebinding namespace: tidb-cluster subjects: - kind: ServiceAccount name: tidb-backup-manager namespace: tidb-cluster roleRef: kind: Role name: tidb-backup-manager-role apiGroup: rbac.authorization.k8s.io
-
About 1 min