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
| Provider | Bucket |
| AWS | S3 |
| GCP | GCS |
| Azure | Blob Storage |
| MinIO | S3-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
| Flag | Use |
--exclude-resources | Skip kinds |
--selector | Label-based selection |
--include-cluster-resources | Include 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
- Backup source cluster (Velero with same bucket)
- Install Velero in target with same BackupStorageLocation
velero backup get sees backups
velero restore create in target
- Validate workloads, repoint DNS
10. Monitoring Backup Status
velero backup get
velero backup logs full-2026-05-01
11. Troubleshooting Backups
| Symptom | Cause |
| PartiallyFailed | Some items skipped; check logs |
| Snapshot timeout | Volume too large; increase deadline |
| Auth errors | Rotate IAM/SP creds |
| CSI snapshots missing | Install CSI snapshot plugin |