skills/kubeblocks-backup/SKILL.md
Create backups for KubeBlocks database clusters. Supports on-demand full backups, scheduled (cron-based) backups, and continuous backups for Point-in-Time Recovery (PITR). Covers BackupRepo configuration for S3, GCS, Azure Blob, and MinIO. Use when the user wants to backup, snapshot, protect, or archive database data. NOT for restoring from backups (see restore skill) or managing backup storage infrastructure (see BackupRepo docs).
npx skillsauth add apecloud/kubeblocks-skills kubeblocks-backupInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
KubeBlocks provides data protection through full backups, scheduled backups, and continuous backups (for Point-in-Time Recovery). Backups are managed via the Backup CR or OpsRequest CR, and stored in a configured BackupRepo.
Official docs: https://kubeblocks.io/docs/preview/user_docs/concepts/backup-and-restore/introduction
| Addon | Physical Backup Method | Snapshot Method | Continuous (PITR) | |------------|----------------------|---------------------|---------------------| | MySQL | xtrabackup | volume-snapshot | archive-binlog | | PostgreSQL | pg-basebackup | volume-snapshot | wal-archive | | Redis | datafile | volume-snapshot | — | | MongoDB | datafile | volume-snapshot | — |
Before proceeding, verify the cluster is healthy and no other operation is running:
# Cluster must be Running
kubectl get cluster <cluster-name> -n <namespace> -o jsonpath='{.status.phase}'
# No pending OpsRequests
kubectl get opsrequest -n <namespace> -l app.kubernetes.io/instance=<cluster-name> --field-selector=status.phase!=Succeed
If the cluster is not Running or has a pending OpsRequest, wait for it to complete before proceeding.
- [ ] Step 1: Ensure BackupRepo exists
- [ ] Step 2: Check BackupPolicy for the cluster
- [ ] Step 3: Create backup (on-demand or scheduled)
- [ ] Step 4: Verify backup
A BackupRepo defines where backups are stored (S3, OSS, MinIO, GCS, etc.). At least one must be configured before creating backups.
kubectl get backuprepo
If no BackupRepo exists, see reference.md for setup instructions with various storage providers.
Each cluster automatically gets a BackupPolicy when KubeBlocks creates it. Verify it exists:
kubectl get backuppolicy -n <ns>
The default naming convention is <cluster>-<component>-backup-policy. The BackupPolicy defines available backup methods and their configurations.
apiVersion: operations.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
name: <cluster>-backup-ops
namespace: <ns>
spec:
clusterName: <cluster>
type: Backup
backup:
backupPolicyName: <cluster>-<component>-backup-policy
backupMethod: <method> # xtrabackup / volume-snapshot / pg-basebackup etc.
deletionPolicy: Delete
retentionPeriod: 7d
Before applying, validate with dry-run:
kubectl apply -f backup-ops.yaml --dry-run=server
If dry-run reports errors, fix the YAML before proceeding.
Apply it:
kubectl apply -f backup-ops.yaml
kubectl get ops <cluster>-backup-ops -n <ns> -w
Success condition:
.status.phase=Succeed| Typical: varies | If stuck >30min:kubectl describe ops <cluster>-backup-ops -n <ns>
apiVersion: dataprotection.kubeblocks.io/v1alpha1
kind: Backup
metadata:
name: <backup-name>
namespace: <ns>
spec:
backupMethod: <method>
backupPolicyName: <policy-name>
deletionPolicy: Delete
Before applying, validate with dry-run:
kubectl apply -f backup.yaml --dry-run=server
If dry-run reports errors, fix the YAML before proceeding.
Apply it:
kubectl apply -f backup.yaml
kubectl get backup <backup-name> -n <ns> -w
Success condition: Full backup:
.status.phase=Completed| Typical: varies | If stuck >30min:kubectl describe backup <backup-name> -n <ns>— Continuous backup:.status.phase=Running| Typical: 1min | If stuck >5min:kubectl describe backup <backup-name> -n <ns>
Add a backup section to the Cluster CR spec:
spec:
backup:
enabled: true
retentionPeriod: 30d
method: xtrabackup
cronExpression: "0 0 * * *"
repoName: <repo-name>
Common cron expressions:
"0 0 * * *" — daily at midnight"0 2 * * 0" — weekly on Sunday at 2 AM"0 */6 * * *" — every 6 hoursContinuous backups stream transaction logs (binlogs/WAL) to enable point-in-time recovery. Create a Backup CR with the continuous method:
apiVersion: dataprotection.kubeblocks.io/v1alpha1
kind: Backup
metadata:
name: <cluster>-continuous
namespace: <ns>
spec:
backupMethod: archive-binlog # MySQL; use wal-archive for PostgreSQL
backupPolicyName: <cluster>-<component>-backup-policy
deletionPolicy: Delete
For PITR to work, you need both a completed full backup and a running continuous backup.
kubectl get backup -n <ns>
Expected output shows Completed status:
NAME POLICY METHOD STATUS AGE
my-backup mycluster-mysql-backup-policy xtrabackup Completed 5m
Check backup details:
kubectl describe backup <backup-name> -n <ns>
Backup stuck in InProgress:
kubectl describe backuprepokubectl logs -n <ns> -l app.kubernetes.io/name=backupBackupPolicy not found:
kubectl get cluster -n <ns>Volume-snapshot backup fails:
kubectl get volumesnapshotclassFor BackupRepo setup (S3, OSS, MinIO, GCS), continuous backup configuration, and advanced BackupPolicy customization, see reference.md.
For general agent safety conventions (dry-run, status confirmation, production protection), see safety-patterns.md.
devops
Expand persistent volume storage for KubeBlocks database clusters via OpsRequest. Requires the StorageClass to support volume expansion (allowVolumeExpansion=true). Use when the user needs more disk space, wants to increase storage, expand volumes, or resize PVCs. NOT for changing CPU/memory (see vertical-scaling) or adding more replicas (see horizontal-scaling). Note that volume shrinking is not supported by Kubernetes.
data-ai
Scale CPU and memory resources for KubeBlocks database clusters via OpsRequest (vertical scaling). Supports in-place updates when the feature gate is enabled. Use when the user wants to change, increase, decrease, resize, or adjust CPU or memory resources of a database cluster. NOT for adding/removing replicas or shards (see horizontal-scaling) or expanding disk storage (see volume-expansion).
data-ai
Upgrade the KubeBlocks operator itself via Helm. Covers update operator, upgrade to v1.0, update kubeblocks version, and CRD updates. Use when the user wants to upgrade KubeBlocks, update the operator, or upgrade to a new KubeBlocks release. NOT for upgrading database engine versions (see minor-version-upgrade).
development
Diagnostic guide for KubeBlocks-managed database clusters. Use when the user reports troubleshoot, debug, diagnose, not working, error, failed, stuck, CrashLoopBackOff, cluster exception, or similar problems with their database cluster. This skill guides the agent through diagnostic steps — it does NOT perform actions.