Implementing Backup and Disaster Recovery

1. Installing Velero

velero install \
  --provider aws \
  --plugins velero/velero-plugin-for-aws:v1.10.0 \
  --bucket k8s-backups \
  --backup-location-config region=us-east-1 \
  --snapshot-location-config region=us-east-1 \
  --secret-file ./creds-velero

2. Configuring Backup Storage

ProviderBucket
AWSS3
GCPGCS
AzureBlob Storage
MinIOS3-compatible on-prem

3. Creating Backups

velero backup create full-2026-05-01 --include-namespaces prod
velero backup describe full-2026-05-01 --details

4. Scheduling Backups

velero schedule create daily \
  --schedule="0 2 * * *" \
  --ttl 720h --include-namespaces prod

5. Restoring from Backup

velero restore create --from-backup full-2026-05-01
velero restore create rename --from-backup full-2026-05-01 \
  --namespace-mappings prod:prod-restore

6. Backing Up Specific Namespaces

velero backup create ns-backup \
  --include-namespaces prod,stage \
  --exclude-resources events,events.events.k8s.io

7. Excluding Resources

FlagUse
--exclude-resourcesSkip kinds
--selectorLabel-based selection
--include-cluster-resourcesInclude cluster-scoped resources

8. Using Backup Hooks

annotations:
  pre.hook.backup.velero.io/command: '["/bin/sh","-c","fsfreeze -f /data"]'
  pre.hook.backup.velero.io/container: app
  post.hook.backup.velero.io/command: '["/bin/sh","-c","fsfreeze -u /data"]'

9. Migrating Across Clusters

Cluster Migration Steps

  1. Backup source cluster (Velero with same bucket)
  2. Install Velero in target with same BackupStorageLocation
  3. velero backup get sees backups
  4. velero restore create in target
  5. Validate workloads, repoint DNS

10. Monitoring Backup Status

velero backup get
velero backup logs full-2026-05-01

11. Troubleshooting Backups

SymptomCause
PartiallyFailedSome items skipped; check logs
Snapshot timeoutVolume too large; increase deadline
Auth errorsRotate IAM/SP creds
CSI snapshots missingInstall CSI snapshot plugin