Skip to content

Scheduled Backups

Automate backups with BackupSchedule and cron.

Basic BackupSchedule

apiVersion: retour.thebackup.company/v1
kind: BackupSchedule
metadata:
  name: daily-backup
spec:
  schedule: "0 2 * * *"   # 2 AM daily (cron)
  storageBackend: s3-production
  namespacedResources:
    - resourceType: Deployment
      namespace: production
      name: webapp
  successfulBackupsHistoryLimit: 7

Cron Schedule Format

Standard 5-field cron:

Field Values
Minute 0-59
Hour 0-23
Day of month 1-31
Month 1-12
Day of week 0-7 (0 and 7 = Sunday)

Examples:

  • 0 2 * * * — 2 AM daily
  • 0 */6 * * * — Every 6 hours
  • 0 0 * * 0 — Midnight every Sunday
  • 30 3 1 * * — 3:30 AM on the 1st of each month

Concurrency Policy

When a scheduled run would overlap with an existing backup:

Policy Behavior
Allow Create new backup (default)
Forbid Skip this run, wait for next schedule
Replace Delete active backup, create new one
spec:
  schedule: "0 2 * * *"
  concurrencyPolicy: Forbid
  # ...

Retention

  • successfulBackupsHistoryLimit: Keep last N successful backups (default: 3)
  • failedBackupsHistoryLimit: Keep last N failed backups (default: 1)

Older backups are deleted when the limit is exceeded.

Suspend a Schedule

Pause without deleting:

kubectl patch backupschedule daily-backup -p '{"spec":{"suspend":true}}'

Resume:

kubectl patch backupschedule daily-backup -p '{"spec":{"suspend":false}}'

Validation (Webhook)

When the BackupSchedule webhook is enabled, invalid cron expressions are rejected at admission time:

# Invalid: 6 fields
kubectl apply -f - <<EOF
apiVersion: retour.thebackup.company/v1
kind: BackupSchedule
metadata:
  name: bad-schedule
spec:
  schedule: "0 0 0 0 0 0"
  storageBackend: s3
  namespacedResources: []
EOF
# Error: invalid cron schedule