Velero (formerly Heptio Ark) is the standard tool for backing up and restoring Kubernetes clusters. It handles cluster resources, persistent volumes, and can migrate workloads between clusters.
Free, open source, VMware-backed. Used by companies like Plex, Mozilla, and GitLab.
Why Use Velero?
- Full cluster backup — resources + persistent volumes to S3/GCS/Azure Blob
- Scheduled backups — cron-based automatic backups
- Disaster recovery — restore entire cluster from backup
- Migration — move workloads between clusters
- Selective restore — restore specific namespaces or resources
Quick Setup
1. Install Velero
# AWS S3 backend
velero install \
--provider aws \
--plugins velero/velero-plugin-for-aws:v1.9.0 \
--bucket my-velero-backups \
--backup-location-config region=us-east-1 \
--snapshot-location-config region=us-east-1 \
--secret-file ./credentials-velero
2. Create a Backup
# Backup entire cluster
velero backup create full-backup
# Backup specific namespace
velero backup create app-backup --include-namespaces production
# Backup with labels
velero backup create critical-backup --selector app=critical
# Check status
velero backup describe full-backup
velero backup logs full-backup
# Via kubectl
kubectl get backups.velero.io -n velero -o json | jq '.items[] | {name: .metadata.name, phase: .status.phase, started: .status.startTimestamp, items: .status.progress}'
3. Schedule Backups
# Daily backup at 2 AM, keep 30 days
velero schedule create daily-backup \
--schedule="0 2 * * *" \
--ttl 720h
# Weekly full backup
velero schedule create weekly-full \
--schedule="0 0 * * 0" \
--ttl 2160h
# Check schedules
velero schedule get
4. Restore from Backup
# Restore entire backup
velero restore create --from-backup full-backup
# Restore specific namespace
velero restore create --from-backup full-backup \
--include-namespaces production
# Restore to different namespace
velero restore create --from-backup full-backup \
--namespace-mappings staging:production
# Check restore status
velero restore describe my-restore
5. Migrate Between Clusters
# Source cluster: create backup
velero backup create migration-backup --include-namespaces app
# Target cluster: install Velero with same bucket
velero install --provider aws --bucket my-velero-backups ...
# Target cluster: restore
velero restore create --from-backup migration-backup
Python Example
from kubernetes import client, config
config.load_kube_config()
api = client.CustomObjectsApi()
# List backups
backups = api.list_namespaced_custom_object(
group="velero.io", version="v1",
namespace="velero", plural="backups")
for b in backups["items"]:
name = b["metadata"]["name"]
phase = b.get("status",{}).get("phase","Unknown")
items = b.get("status",{}).get("progress",{}).get("totalItems",0)
print(f"Backup: {name} | Phase: {phase} | Items: {items}")
# List schedules
schedules = api.list_namespaced_custom_object(
group="velero.io", version="v1",
namespace="velero", plural="schedules")
for s in schedules["items"]:
print(f"Schedule: {s['metadata']['name']} | Cron: {s['spec']['schedule']} | Last: {s.get('status',{}).get('lastBackup','never')}")
Key Resources
| Resource | Description |
|---|---|
| Backup | Point-in-time cluster backup |
| Schedule | Cron-based backup schedule |
| Restore | Restore from backup |
| BackupStorageLocation | Where backups are stored (S3, GCS, etc.) |
| VolumeSnapshotLocation | Where volume snapshots are stored |
Need custom data extraction or scraping solution? I build production-grade scrapers for any website. Email: Spinov001@gmail.com | My Apify Actors
Top comments (0)