Skip to main content
Version: release-0.9

Scheduled backup

KubeBlocks supports configuring scheduled backups for clusters.

kbcli cluster update mysql-cluster --backup-enabled=true \
--backup-method=xtrabackup --backup-repo-name=my-repo \
--backup-retention-period=7d --backup-cron-expression="0 18 * * *"
  • --backup-enabled indicates whether to enable scheduled backups.
  • --backup-method specifies the backup method. You can use the kbcli cluster describe-backup-policy mysql-cluster command to view the supported backup methods.
  • --backup-repo-name specifies the name of the backupRepo.
  • --backup-retention-period specifies the retention period for backups, which is 7 days in the example.
  • --backup-cron-expression specifies the backup schedule using a cron expression in UTC timezone. Refer to cron for the expression format.

After the scheduled backup is enabled, execute the following command to check if a CronJob object has been created:

kubectl get cronjob
>
NAME SCHEDULE SUSPEND ACTIVE LAST SCHEDULE AGE
96523399-mysql-cluster-default-xtrabackup 0 18 * * * False 0 <none> 57m

You can also execute the following command to view cluster information, where the Data Protection: section displays the configuration details of automatic backups.

kbcli cluster describe mysql-cluster
>
...
Data Protection:
BACKUP-REPO AUTO-BACKUP BACKUP-SCHEDULE BACKUP-METHOD BACKUP-RETENTION
my-repo Enabled 0 18 * * * xtrabackup 7d