Complete API reference for the AntflyBackup custom resource.

Overview#

AntflyBackup defines scheduled backup operations for Antfly clusters. The operator creates a Kubernetes CronJob to execute backups on schedule.

apiVersion: antfly.io/v1
kind: AntflyBackup
metadata:
  name: daily-backup
  namespace: default
spec:
  # ... spec fields
status:
  # ... status fields (read-only)

Spec#

Top-Level Fields#

FieldTypeRequiredDefaultDescription
clusterRefClusterReferenceYes-Reference to the cluster to backup
schedulestringYes-Cron schedule expression
destinationBackupDestinationYes-Backup storage location
tables[]stringNoallSpecific tables to backup
suspendboolNofalseSuspend scheduled backups
backupTimeout*durationNo1hMaximum backup duration
successfulJobsHistoryLimit*int32No3Successful job history to retain
failedJobsHistoryLimit*int32No1Failed job history to retain

ClusterReference#

FieldTypeRequiredDefaultDescription
namestringYes-Name of the AntflyCluster
namespacestringNosame as backupNamespace of the AntflyCluster

BackupDestination#

FieldTypeRequiredDescription
locationstringYesBackup URL (s3:// or file://)
credentialsSecret*SecretReferenceNoSecret with storage credentials

Location format:

  • S3: s3://bucket-name/path/to/backups
  • GCS (via S3 API): s3://bucket-name/path with endpoint in credentials
  • Local: file:///path/to/backups (testing only)

SecretReference#

FieldTypeRequiredDescription
namestringYesName of the Secret

Expected Secret keys:

KeyRequiredDescription
AWS_ACCESS_KEY_IDYesAccess key
AWS_SECRET_ACCESS_KEYYesSecret key
AWS_REGIONNoAWS region
AWS_ENDPOINT_URLNoCustom S3 endpoint

Schedule Syntax#

Standard cron format: minute hour day-of-month month day-of-week

FieldValues
Minute0-59
Hour0-23
Day of Month1-31
Month1-12
Day of Week0-6 (0=Sunday)

Examples:

ScheduleCron Expression
Every hour0 * * * *
Daily at 2am0 2 * * *
Weekly Sunday 3am0 3 * * 0
Monthly 1st at 4am0 4 1 * *
Every 6 hours0 */6 * * *

Status#

Top-Level Status Fields#

FieldTypeDescription
phaseBackupPhaseCurrent phase
lastScheduledTime*TimeLast backup scheduled time
lastSuccessfulBackup*BackupRecordMost recent successful backup
recentBackups[]BackupRecordRecent backup records
conditions[]ConditionCurrent conditions
nextScheduledBackup*TimeNext planned backup time
cronJobNamestringName of managing CronJob

BackupPhase#

PhaseDescription
ActiveBackup schedule is active
SuspendedBackup schedule is suspended
FailedBackup schedule has failed

BackupRecord#

FieldTypeDescription
backupIdstringUnique backup identifier
startTimeTimeWhen backup started
completionTime*TimeWhen backup completed
statusstring"Running", "Completed", "Failed"
tables[]stringTables that were backed up
errorstringError message if failed

Conditions#

TypeDescription
ScheduleReadyCronJob is created and ready
ClusterReadyReferenced cluster exists and is ready

Condition reasons:

  • CronJobCreated - CronJob created successfully
  • ClusterNotFound - Referenced cluster not found
  • InvalidSchedule - Cron schedule is invalid
  • InvalidDestination - Backup destination is invalid

Validation Rules#

  • schedule must be valid cron syntax
  • destination.location must start with s3:// or file://
  • clusterRef.name must reference an existing AntflyCluster
  • successfulJobsHistoryLimit must be >= 0
  • failedJobsHistoryLimit must be >= 0

Examples#

Basic Daily Backup#

apiVersion: antfly.io/v1
kind: AntflyBackup
metadata:
  name: daily-backup
  namespace: production
spec:
  clusterRef:
    name: my-cluster
  schedule: "0 2 * * *"
  destination:
    location: s3://my-bucket/antfly-backups
    credentialsSecret:
      name: backup-credentials

Backup Specific Tables#

apiVersion: antfly.io/v1
kind: AntflyBackup
metadata:
  name: critical-tables-backup
  namespace: production
spec:
  clusterRef:
    name: my-cluster
  schedule: "0 * * * *"  # Hourly
  destination:
    location: s3://my-bucket/critical-backups
    credentialsSecret:
      name: backup-credentials
  tables:
    - users
    - transactions
    - audit_log
  backupTimeout: 30m
  successfulJobsHistoryLimit: 24  # Keep 24 hours of hourly backups

GCS Backup with HMAC#

apiVersion: antfly.io/v1
kind: AntflyBackup
metadata:
  name: gcs-backup
  namespace: production
spec:
  clusterRef:
    name: my-cluster
  schedule: "0 2 * * *"
  destination:
    location: s3://my-gcs-bucket/antfly-backups
    credentialsSecret:
      name: gcs-hmac-credentials
---
apiVersion: v1
kind: Secret
metadata:
  name: gcs-hmac-credentials
  namespace: production
stringData:
  AWS_ACCESS_KEY_ID: "GOOGABC123DEF456"
  AWS_SECRET_ACCESS_KEY: "your-hmac-secret"
  AWS_ENDPOINT_URL: "https://storage.googleapis.com"
  AWS_REGION: "auto"

Cross-Namespace Backup#

apiVersion: antfly.io/v1
kind: AntflyBackup
metadata:
  name: prod-backup
  namespace: backup-jobs
spec:
  clusterRef:
    name: production-cluster
    namespace: production
  schedule: "0 */6 * * *"
  destination:
    location: s3://backup-bucket/production
    credentialsSecret:
      name: backup-credentials

Suspended Backup#

apiVersion: antfly.io/v1
kind: AntflyBackup
metadata:
  name: suspended-backup
  namespace: production
spec:
  clusterRef:
    name: my-cluster
  schedule: "0 2 * * *"
  destination:
    location: s3://my-bucket/backups
    credentialsSecret:
      name: backup-credentials
  suspend: true  # Temporarily disabled

Managing Backups#

List Backups#

kubectl get antflybackup -n production

View Backup Status#

kubectl get antflybackup daily-backup -n production -o yaml

Check Last Successful Backup#

kubectl get antflybackup daily-backup -n production \
  -o jsonpath='{.status.lastSuccessfulBackup}'

View CronJob#

kubectl get cronjob -l antfly.io/backup=daily-backup -n production

Suspend Backup#

kubectl patch antflybackup daily-backup -n production \
  --type='merge' -p='{"spec":{"suspend":true}}'

Resume Backup#

kubectl patch antflybackup daily-backup -n production \
  --type='merge' -p='{"spec":{"suspend":false}}'

Trigger Immediate Backup#

# Create a job from the CronJob
kubectl create job --from=cronjob/daily-backup-cron manual-backup-$(date +%s) -n production

See Also#