This guide demonstrates how to create backups for etcd clusters managed by KubeBlocks using the datafile backup method.
KubeBlocks etcd uses datafile for full backups:
| Method | Description |
|---|---|
datafile | Saves an etcd snapshot using etcdctl snapshot save to a backup repository. Runs on the leader node. |
Before proceeding, verify your environment meets these requirements:
kubectl v1.21+ installed and configured with cluster accessReady state. See Create a BackupRepo for setup instructions.kubectl get backuprepo
NAME STATUS STORAGEPROVIDER ACCESSMETHOD DEFAULT AGE
minio-repo Ready minio Tool true 6h
KubeBlocks automatically generates a BackupPolicy for each etcd cluster:
kubectl get backuppolicy -n demo -l app.kubernetes.io/instance=etcd-cluster
NAME BACKUP-REPO STATUS AGE
etcd-cluster-etcd-backup-policy Available 10m
etcd supports one backup method: datafile.
apiVersion: dataprotection.kubeblocks.io/v1alpha1
kind: Backup
metadata:
name: etcd-cluster-backup
namespace: demo
spec:
# Backup method: datafile
backupMethod: datafile
backupPolicyName: etcd-cluster-etcd-backup-policy
# `Retain`: backup data is kept when the Backup CR is deleted
# `Delete`: backup data is removed when the Backup CR is deleted
deletionPolicy: Delete
Apply it:
kubectl apply -f https://raw.githubusercontent.com/apecloud/kubeblocks-addons/refs/heads/main/examples/etcd/backup.yaml
kubectl get backup etcd-cluster-backup -n demo -w
NAME POLICY METHOD REPO STATUS TOTAL-SIZE DURATION DELETION-POLICY CREATION-TIME
etcd-cluster-backup etcd-cluster-etcd-backup-policy datafile minio-repo Running 0 0s Delete 2026-04-03T17:20:00Z
etcd-cluster-backup etcd-cluster-etcd-backup-policy datafile minio-repo Completed 853 10s Delete 2026-04-03T17:20:00Z
A Completed status means the backup succeeded.
Enable automatic scheduled backups by updating the BackupSchedule:
kubectl patch backupschedule etcd-cluster-etcd-backup-schedule -n demo \
--type merge \
-p '{"spec":{"schedules":[{"backupMethod":"datafile","cronExpression":"0 2 * * *","enabled":true,"retentionPeriod":"7d"}]}}'
This schedules a daily backup at 2:00 AM with a 7-day retention period.
Verify:
kubectl get backupschedule etcd-cluster-etcd-backup-schedule -n demo -oyaml \
| grep -A5 "schedules:"
schedules:
- backupMethod: datafile
cronExpression: 0 2 * * *
enabled: true
retentionPeriod: 7d
If a backup fails or stays in Running state:
Check the Backup resource for errors:
kubectl describe backup etcd-cluster-backup -n demo
Check the backup job:
kubectl get job -n demo -l app.kubernetes.io/instance=etcd-cluster,app.kubernetes.io/managed-by=kubeblocks-dataprotection
Check job pod logs:
kubectl logs -n demo -l app.kubernetes.io/instance=etcd-cluster,app.kubernetes.io/managed-by=kubeblocks-dataprotection
kubectl delete backup etcd-cluster-backup -n demo
kubectl delete cluster etcd-cluster -n demo
kubectl delete ns demo