Velero Backup and Restore for Kubernetes: Runbooks That Survive Real Disasters
Velero backup and restore for Kubernetes protects namespaces, persistent volumes and cluster-scoped resources, but a green backup phase proves nothing until a restore works. This guide covers storage locations, schedules, CSI snapshots, the data mover, file system backup, restore ordering, namespace mapping and the failure modes that turn a routine recovery into a second incident.
1. What Velero backup and restore actually protects
Velero backup and restore copies Kubernetes API objects into object storage and protects volume data through snapshots or file system backup, then recreates objects in dependency order during recovery. It protects namespaces and workloads, not the control plane itself, so etcd recovery stays a separate discipline with separate tooling.
Illustrative composite: a platform team deletes a production namespace during a cleanup script run with the wrong context. The nightly Velero schedule shows Completed, so the on-call starts a restore within minutes. The restore also ends Completed, yet the application stays down: the PersistentVolumeClaims came back, but the volumes are empty. The backup had captured API objects only, because the CSI snapshot path was never enabled for that StorageClass and file system backup was never configured for those pods. The backup was green for months; the recovery was never real. That gap between a Completed backup and a working restore is the theme of this guide.
Velero runs as a server Deployment, usually in the velero namespace, with provider plugins loaded as init containers. A Backup object selects namespaces, resources and label filters, then writes a tarball of API objects to a BackupStorageLocation, which is a bucket plus prefix in S3, GCS, Azure Blob or an S3-compatible store. Volume data travels one of three paths: provider-native snapshots, CSI snapshots optionally moved into the bucket by the data mover, or file system backup through the node-agent DaemonSet. A Restore object reads a backup and recreates objects, and by default it never overwrites objects that already exist.
Set expectations before you design anything. Velero does not back up etcd, node state, or data that lives outside volumes and API objects. Cluster-scoped resources such as CustomResourceDefinitions, StorageClasses and ClusterRoles are included only when the backup scope covers them. For the control-plane side of disaster recovery, read the etcd backup and restore guide and treat the two systems as complements: etcd snapshots rebuild the cluster, Velero rebuilds the workloads inside it.
2. How Velero backup and restore moves data
Velero backup and restore separates metadata from volume data: API objects are listed through the Kubernetes API and stored as a compressed archive, while volume contents move through snapshots, the CSI data mover, or node-agent file copies. Each path fails differently, so diagnosis starts by naming which path a volume took.
During backup, the Velero server lists the selected resources, applies item actions from plugins, and uploads the archive plus backup metadata to the BackupStorageLocation. For each PersistentVolumeClaim in scope, Velero decides how to protect the data. With provider snapshots, the cloud plugin snapshots the underlying disk and records the snapshot ID. With CSI, Velero creates a VolumeSnapshot through the external snapshotter; with the data mover enabled, a DataUpload copies snapshot data into the backup bucket so the backup survives cluster loss. With file system backup, the node-agent runs a PodVolumeBackup that streams volume files to the bucket using kopia.
Restore reverses the flow with ordering rules. Velero restores CustomResourceDefinitions and namespaces first, then storage classes and persistent volumes, then claims and workloads, so dependencies exist before consumers start. Hooks can run commands in pods before or after backup and restore, which matters for databases that need quiescing or post-restore repair. The StatefulSet storage patterns guide covers why claim retention and headless identity change what a restore must recreate.
Two properties shape every incident. First, restore is additive: existing objects are skipped with warnings, not overwritten, so a restore into a half-alive namespace can report Completed while leaving broken objects untouched. Second, volume restore binds new volumes from snapshots or uploads files into fresh claims; it never writes into a live volume in place. Both properties are safe defaults, and both surprise engineers who expect restore to mean rewind.
3. Velero backup and restore setup: storage locations first
Velero backup and restore stands or falls on the BackupStorageLocation: if the bucket, credentials, region or endpoint are wrong, backups fail validation and restores find nothing. Confirm the location reports Available and that the Velero server can list and write objects before debugging anything else.
Check the location phase and the server logs first:
An Unavailable phase with AccessDenied or NoSuchBucket in the message points at credentials, bucket policy, region mismatch or a wrong S3 endpoint for compatible stores. Velero validates the location periodically and before backups, so a location that flips between Available and Unavailable usually means flaky credentials, expiring tokens, or an endpoint that only some nodes can reach. Fix the cloud identity first; no backup flag compensates for a bucket the server cannot write.
A minimal location definition looks like this:
Keep one writable default location per cluster and treat additional locations as read-only sources for cross-cluster restore drills. Versioning and lifecycle rules on the bucket deserve the same care as the cluster itself: a lifecycle rule that expires objects after thirty days silently deletes the data behind backups whose metadata still lists them, which surfaces months later as a restore that cannot read its blobs. The kubeadm cluster administration guide covers the node and control-plane side of rebuilding a cluster before Velero restores workloads into it.
Credentials deserve a second look during setup because they fail quietly. Velero reads cloud credentials from a Secret at server start, so rotating the key in the cloud console without updating the Secret leaves the server authenticating with a dead key until it restarts. Prefer workload identity such as IRSA or GKE Workload Identity over static keys where the provider plugin supports it, and scope the identity to the backup bucket prefix only. A backup identity that can delete every bucket in the account turns a compromised Velero pod into a ransomware path, so least privilege here is a security control, not housekeeping.
4. Scheduling Velero backup and restore coverage
Velero backup and restore coverage comes from Schedule objects that create backups on a cron expression with a retention TTL. A schedule stuck in FailedValidation creates nothing, so check schedule phase and the age of the newest backup per namespace, not just the schedule's existence.
Inspect schedules and recent backups together:
FailedValidation usually means an invalid cron expression or an invalid template field, and the describe output names the problem. A schedule in Enabled phase with no recent backups points elsewhere: the Velero server may be down, the storage location unavailable, or every backup failing before upload. Correlate the newest backup timestamps with your recovery point objective; a schedule that runs nightly but whose last successful backup is nine days old is a monitoring failure, not a backup system.
A production schedule template should scope deliberately:
Decide scope per namespace, not per cluster, unless the cluster is small. Cluster-wide backups capture cluster-scoped resources that namespace backups miss, but they also grow large and restore slowly. A common pattern is one cluster-scoped schedule for platform resources plus per-team namespace schedules with shorter TTLs. Whatever you choose, alert on backup age and phase, because Velero will happily keep a broken schedule Enabled forever.
5. Velero restore ordering and namespace mapping
Velero restore recreates objects in dependency order and supports namespace mapping to restore into a different namespace than the backup captured. Ordering failures appear as PartiallyFailed restores where custom resources fail because their CRDs, webhooks or operators were not ready when Velero created them.
Run restores explicitly and watch the phase:
Velero restores CRDs before custom resources and namespaces before namespaced objects, but it cannot wait for an operator's admission webhook to become ready. When a restore races a webhook that is still starting, creates fail with server-unable-to-handle-request errors and the restore ends PartiallyFailed. The fix is sequencing: restore platform namespaces and operators first, wait for their webhooks and controllers to report ready, then restore application namespaces in a second restore. Excluding operator-managed infrastructure resources from application backups also prevents this class of failure.
Namespace mapping supports drills and migrations:
Remember the additive rule while drilling: restoring into a namespace that already holds objects skips conflicts with warnings. For a clean drill, restore into a fresh namespace or delete the target first. Check warnings in the restore describe output even when the phase is Completed, because skipped objects are listed there and a Completed phase with warnings means part of the workload was not recreated.
Selective restore is the safer tool for partial damage. Restore only the resource types you need, such as ConfigMaps and Secrets after a bad apply, and leave running workloads untouched. Narrow restores finish faster, produce fewer warnings to review, and reduce the chance that a recovery action causes a second outage. Keep the full-namespace restore for genuine loss, and practice both paths so the choice during an incident is routine rather than improvised.
6. CSI snapshots and the data mover in Velero restore
Velero restore with CSI snapshots recreates volumes from VolumeSnapshots, and the data mover copies snapshot data into object storage so backups survive losing the source cluster. Without the data mover, a CSI backup is only as durable as the snapshots in the same storage system as the volumes.
Enable CSI support and confirm the snapshot classes exist:
A backup that completes while its DataUploads sit in Failed state has metadata without portable volume data. Common causes are a VolumeSnapshotClass missing the Velero label, a CSI driver without snapshot support for that volume type, or snapshot deletion racing the upload. The backup describe output lists per-volume snapshot status; read it before trusting the backup phase.
The portability decision is the design point. Provider snapshots and plain CSI snapshots restore fast inside the same cloud account and region, but they die with the storage system that holds them. The data mover trades backup time and bucket storage for independence: DataUpload copies snapshot contents into the BackupStorageLocation, and DataDownload reverses it during restore. For disaster recovery across clusters or regions, the data mover or file system backup is mandatory. The Kubernetes storage and CSI provisioning guide explains how StorageClasses and snapshot classes bind volumes, which determines which Velero path each claim can take.
Watch snapshot hygiene while you are here. Every backup creates VolumeSnapshots that linger until the backup TTL expires, and a storage system with a low per-volume snapshot limit can start rejecting new snapshots while old ones wait for cleanup. Alert on snapshot count per volume and on DataUpload duration, because a data mover that takes longer than the backup interval guarantees overlapping backups and growing lag. Size the backup window from measured upload throughput, not from hope.
7. File system backup and node-agent failures
Velero file system backup copies volume files through the node-agent DaemonSet, which suits volumes without snapshot support but fails on permissions, busy files and missing node-agent pods. Check PodVolumeBackup phases per pod before assuming a namespace backup protected its data.
Inspect the file system backup objects directly:
A PodVolumeBackup stuck in InProgress usually means the node-agent on that node is unhealthy or the volume is huge and still uploading. Failed backups with permission errors often trace to files owned by a user the restore helper cannot read, or to volumes mounted with restrictive settings. Velero documents customizing the restore helper container security context for exactly this case; treat that as a deliberate, reviewed exception, not a default.
Choose file system backup deliberately per workload. It works with any volume type, including hostPath-backed and NFS volumes that snapshots cannot touch, but it copies file by file, so large databases restore slowly and application consistency depends on hooks quiescing writes first. Annotate pods or set defaultVolumesToFsBackup per backup so the choice is explicit in the backup spec, and verify in the backup details that each expected volume shows a completed PodVolumeBackup. A backup whose volumes silently took no path at all is the failure from the opening incident.
8. Velero backup and restore for databases and StatefulSets
Velero backup and restore for databases needs application consistency, not just volume copies: snapshot or file backup of a running database can capture torn state unless hooks quiesce writes or the database's own backup tooling runs first. Treat Velero as the transport and the database backup as the consistency mechanism.
Use backup hooks to freeze writes briefly, or exclude database volumes from Velero and restore data with native tooling:
Modern PostgreSQL versions replaced those functions with pgbackupstart and pgbackupstop; match the hook to your server version and test it in a drill, because a hook that fails silently produces a backup you cannot trust. Many teams take the simpler path: Velero restores the StatefulSet, Services and claims, while a database-native backup such as pgBackRest or a cloud snapshot restores the data. Either way, the restore runbook must name the order: infrastructure, then database data, then application pods.
StatefulSet identity adds one more trap. Restored claims must bind to volumes holding the right data, and pod ordinals must match their claims. Velero restores claims and volumes as pairs from the same backup, which preserves that mapping when the whole namespace comes from one backup point. Mixing claims from one backup with volumes from another breaks the pairing and can hand a replica the wrong data directory.
9. Cross-cluster Velero restore and disaster recovery
Velero restore into a second cluster works when the target cluster runs Velero with read access to the source BackupStorageLocation and the backup's volume data is portable through the data mover or file system backup. Provider snapshots alone cannot cross accounts or regions.
Prepare the target cluster before the disaster, not during it:
Install Velero in the recovery cluster with the source location configured as read-only, confirm backups list correctly, and rehearse a namespace restore quarterly. The rehearsal catches the usual blockers: CRDs missing in the target, StorageClass names that differ between clusters, image pull secrets that reference a registry the target cannot reach, and cloud IAM bindings such as IRSA roles that exist only in the source account. Velero restores the objects; the platform around them must already match.
StorageClass mapping deserves explicit handling. A claim restored against a StorageClass name that does not exist in the target stays Pending and the restore reports success for the claim object while the workload never starts. Standardize StorageClass names across clusters, or restore claims separately after creating matching classes. The same applies to snapshot classes for CSI restores. Cross-cluster recovery is a platform standardization exercise first and a Velero exercise second.
Network identity is the other silent mismatch. Restored Services keep their cluster IPs only when the target service CIDR matches; otherwise Velero lets the API assign new addresses, which is correct behavior but breaks anything that hardcoded an IP. Ingress hostnames, external DNS records and TLS certificates issued for the source cluster also need a cutover plan. Write the DNS and certificate steps into the recovery runbook beside the Velero commands, because a restore that finishes with unreachable endpoints has recovered data without recovering service.
10. Velero backup and restore versus etcd snapshots
Velero backup and restore and etcd snapshots solve different layers: etcd snapshots rebuild the entire control plane state, while Velero rebuilds selected workloads and their volume data inside a working cluster. Production disaster recovery needs both, tested independently, because each fails in ways the other cannot cover.
| Aspect | Velero | etcd snapshot |
|---|---|---|
| Scope | Namespaces, resources, volume data | Entire cluster state |
| Restore target | Same or different cluster | Same cluster identity |
| Granularity | Per namespace or resource | All or nothing |
| Volume data | Snapshots, data mover, file backup | Not included |
| Typical use | App recovery, migration, drills | Control-plane rebuild |
An etcd restore rewinds every object in the cluster to the snapshot moment, including objects other teams changed since, and it requires stopping the control plane. Velero restores one namespace without touching neighbors, but it cannot recreate a cluster whose control plane is gone. The etcd disaster recovery guide covers snapshot scheduling and restore mechanics; pair it with Velero schedules so both layers have current, tested copies.
Choose restore order by blast radius. Namespace deleted or corrupted: Velero only. Cluster lost but backups intact: rebuild the control plane from etcd or fresh provisioning, then Velero for workloads. Single workload data corruption: restore that namespace into a drill namespace, extract what you need, and avoid touching production objects until the data is verified.
11. Proving Velero restore works: drills and verification
Velero restore is proven only by drills that restore into an isolated namespace or cluster and verify the application serves traffic with correct data. Backup phases, schedule listings and bucket sizes are necessary signals, but none of them prove a workload can start from the backup.
Run a drill on a fixed cadence:
Verify data, not just pod status: row counts, a known record, file checksums, or a smoke transaction through the restored Service. Record drill duration as your measured recovery time and the backup age as your measured recovery point, then compare both against the objectives the business agreed. Drills also validate the bucket lifecycle rules, credentials and snapshot classes in the target environment, which are exactly the pieces that rot silently between incidents.
Automate the drill where possible and alert on drill failure with the same severity as backup failure. The Kubernetes best practices guide covers the surrounding platform habits, but the drill discipline is specific: an untested Velero restore is a hypothesis, and the first real test should never happen during an outage.
Track three numbers from every drill and trend them: time from restore start to application healthy, age of the backup used, and count of warnings in the restore describe output. Rising warnings usually mean drift between the backup scope and the live platform, such as new CRDs or renamed StorageClasses that nobody added to the recovery plan. Review the trend monthly with the same seriousness as error budgets, because recovery capability decays exactly like reliability does.
12. Velero backup and restore troubleshooting matrix and checklist
Velero backup and restore troubleshooting follows the data path: storage location, backup phase, per-volume status, then restore warnings. Most incidents resolve to an unavailable location, a volume that took no protection path, or a restore that skipped existing objects while reporting Completed.
| Symptom | Likely cause | First check |
|---|---|---|
| Backup FailedValidation | Bad scope, missing location, invalid fields | velero backup describe <name> |
| BackupStorageLocation Unavailable | Credentials, bucket, region, endpoint | kubectl describe backupstoragelocations.velero.io -n velero |
| Backup Completed, volumes empty | No snapshot or file backup path for claims | velero backup describe <name> --details |
| Restore Completed, app still broken | Existing objects skipped with warnings | velero restore describe <name> --details |
| Restore PartiallyFailed | CRD, webhook or operator not ready | velero restore logs <name> |
| PodVolumeBackup Failed | node-agent, permissions, busy files | kubectl get podvolumebackups.velero.io -n velero |
| DataUpload Failed | Snapshot class label, CSI limits | kubectl get datauploads.velero.io -n velero |
| Restored PVC Pending | StorageClass missing in target | kubectl describe pvc -n <namespace> |
Final checklist:
- BackupStorageLocation reports Available and the bucket has versioning plus lifecycle rules reviewed.
- Every schedule shows recent backups inside the recovery point objective, with alerts on backup age and phase.
- Backup details confirm each expected volume took a snapshot, data mover or file backup path.
- Database workloads use hooks or native backup tooling for application consistency.
- Restore runbook sequences platform operators before application namespaces.
- Quarterly drills restore into an isolated namespace and verify data, not just pod status.
- Cross-cluster recovery uses portable volume data and standardized StorageClass names.
- etcd snapshots exist alongside Velero, and both restore paths have been rehearsed.
Frequently Asked Questions
What does Velero backup and restore protect in Kubernetes?
Velero backup and restore protects Kubernetes API objects such as Deployments, Services, ConfigMaps, Secrets and claims, plus volume data through provider snapshots, CSI snapshots with the data mover, or file system backup. It does not protect etcd or node state, so control-plane recovery needs separate etcd snapshots.
Why did my Velero restore complete but the application is still broken?
A Velero restore never overwrites objects that already exist; it skips them with warnings and still reports Completed. Read the warnings in velero restore describe --details, then either delete the conflicting objects first or restore into a fresh namespace with namespace mapping.
Why are restored volumes empty after a Velero backup?
The backup captured API objects but the volumes took no protection path: CSI snapshots were not enabled for the StorageClass, the data mover was off, or file system backup was not configured for those pods. Check per-volume status in velero backup describe --details before trusting the backup phase.
How do I fix a Velero BackupStorageLocation that is unavailable?
Check the location message with kubectl describe backupstoragelocations.velero.io -n velero and the Velero server logs. AccessDenied and NoSuchBucket point at credentials, bucket policy, region or endpoint errors. Fix the cloud identity and bucket configuration; backup flags cannot compensate for a bucket the server cannot write.
Can Velero restore a backup into a different cluster?
Yes, when the target cluster runs Velero with read access to the source BackupStorageLocation and volume data is portable through the CSI data mover or file system backup. Provider snapshots stay inside their cloud account, and StorageClass names, CRDs and IAM bindings must match in the target cluster.
How often should I test a Velero restore?
Test Velero restore at least quarterly, and after any change to storage classes, snapshot classes, credentials or bucket lifecycle rules. Restore into an isolated namespace, verify application data rather than pod status alone, and record the measured recovery time and recovery point against your objectives.
Does Velero replace etcd backup for disaster recovery?
No. Velero rebuilds selected workloads inside a working cluster, while etcd snapshots rebuild the control plane state itself. A lost cluster needs etcd recovery or fresh provisioning first, then Velero restores. Keep both, on independent schedules, and rehearse both restore paths.
Preparing for Senior Platform & SRE Interviews
Practice real-world cluster triage, RBAC debugging, and pod scheduling scenarios in our Kubernetes scenario interview questions hub.
Explore Interview Scenarios →