Cloud operationsKubernetes
Back up and restore a Kubernetes cluster with Velero
A Velero backup uploads a tarball of Kubernetes objects to object storage and can snapshot or copy the persistent volumes. A restore brings the objects and the volumes back from that backup.

What a backup contains
Velero collects the data for a backup by querying the Kubernetes API server for resources. It packs the copied objects into a tarball and uploads that to object storage. If specified, it also calls the cloud provider's API to take disk snapshots of persistent volumes. By default, a backup with no filtering options includes all objects.
Velero treats object storage as the source of truth and synchronizes the backup resources in the cluster from it.
Three ways to protect volumes
- Provider snapshots. The provider plugin calls the cloud API to snapshot the disk. The plugins for AWS, Google Cloud and Azure each include a volume snapshotter.
- CSI snapshots. With the
EnableCSIfeature flag, Velero creates aVolumeSnapshotfor each claim backed by a CSI driver. From v1.14 the CSI plugin is integrated into Velero and needs no separate install. Only Kubernetes objects are uploaded to object storage. Add--snapshot-move-datato a backup to move the snapshot data to the backup storage location as well. - File system backup. A node agent, deployed as a daemonset, accesses the volume from the mounted host path directory, and Kopia modules move the data. The documentation suggests it for volume types that have no native snapshot concept, such as EFS, AzureFile, NFS, emptyDir and local volumes.
The v1.19.0 release notes state that the Restic path for file system backup is completely removed. Velero 1.19 marks a restore from a backup made with the Restic path as FailedValidation.
Install with a provider plugin
Install the CLI with brew install velero on macOS, or from the tarball of the GitHub release. Install the server with velero install or with the Helm chart. The README of the AWS plugin gives this command:
velero install \
--provider aws \
--plugins velero/velero-plugin-for-aws:v1.15.0 \
--bucket $BUCKET \
--backup-location-config region=$REGION \
--snapshot-location-config region=$REGION \
--secret-file ./credentials-veleroThe README's compatibility table pairs plugin v1.15.x with Velero v1.19.x. Three more documented flags change the install:
--use-node-agentenables file system backup.--features=EnableCSIenables CSI snapshots.--no-secretreplaces--secret-filewhen the cluster uses an identity mechanism that needs no credentials file, such as Workload Identity on GKE.
Create a backup and a schedule
velero backup create <backup-name> --include-namespaces <namespace>
velero backup describe <backup-name>
velero schedule create example-schedule --schedule="0 3 * * *"The first command backs up one namespace and its objects. Cluster-scoped resources are not included when namespace filtering is used, unless you add --include-cluster-resources=true. The schedule creates a backup every day at 3am and saves each one as example-schedule-<TIMESTAMP>.
A backup expires after 30 days if you set no TTL. Set one with a flag in the form --ttl 24h0m0s. When a backup expires, Velero removes the backup resource, the backup file in object storage, all persistent volume snapshots and all associated restores.
File system backup is opt-in by default: each pod is annotated with the names of the volumes to back up. The documentation's example:
kubectl -n foo annotate pod/sample backup.velero.io/backup-volumes=pvc-volume,emptydir-volumeTo back up all pod volumes this way, add --default-volumes-to-fs-backup to velero backup create.
Restore from a backup
velero restore create --from-backup <backup-name>
velero restore get
velero restore describe <restore-name>Velero is non-destructive during a restore by default. If a resource already exists in the target cluster, Velero skips it and makes no change. With --existing-resource-policy=update, Velero attempts to update the existing resource to match the backup.
Test a restore somewhere else
A restore can place resources in a namespace other than the one the backup took them from:
velero restore create <restore-name> \
--from-backup <backup-name> \
--namespace-mappings old-ns-1:new-ns-1,old-ns-2:new-ns-2For a second cluster, the cluster migration page gives the steps:
- Install Velero on the second cluster with the same bucket and region.
- Configure the backup storage location as read-only with
--access-mode=ReadOnlyonvelero backup-location create. During the restore the backup is then safe from accidental deletion in the object store. - Run
velero backup describe <backup-name>to confirm the backup has synced. The default sync interval is 1 minute. - Run
velero restore create --from-backup <backup-name>.
Limits to check first
- Atomicity. Cluster backups are not strictly atomic. Objects that are created or edited during a backup can be missing from it.
- Consistency. File system backup reads the live file system, so the documentation rates it less consistent than the snapshot approaches. Backup hooks run commands during a backup. The documentation's use: before a snapshot, a database is told to write its in-memory buffers to disk.
- Volume types. File system backup does not support
hostPathvolumes. - Encryption. Velero uses a static, common encryption key for all the backup repositories it creates. Anyone who has access to the backup storage can decrypt the backup data, so limit access to it.
- Kubernetes version. A restore into a cluster whose Kubernetes version is lower than the backup's cluster is unsupported by Velero. The API group versions in the backup must exist in the target cluster.
- Cloud providers. Velero does not natively support migrating persistent volume snapshots across cloud providers. The documentation points to file system backup for that case.
Sources
Want a second pair of eyes on yours? We do this work for a living.
More guides

Kubernetes upgrades: a checklist for every minor version
Kubernetes · 4 min read
What to check before, during and after a minor version upgrade, in the order to do it.

PodDisruptionBudgets: keep pods running through node drains
Kubernetes · 4 min read
What a disruption budget covers, how to write one, and the settings that leave a node drain stuck.

Blameless postmortems: what to write after an incident
Cloud operations · 4 min read
The sections, the wording, the review meeting and the follow-up for a postmortem people learn from.