How to Back Up a Kubernetes Cluster: Step-by-Step Methods and Restore

A Kubernetes cluster has no single “back up everything” button: cluster state lives in etcd, application definitions in API objects, and data in persistent volumes. This guide shows how to back up and restore all three with etcd snapshots, Velero and native tools, for self-managed and managed clusters.

Free Download
for VM, OS, DB, File, NAS, etc.
jack-smith

Updated by Jack Smith on 2026/11/19

Table of contents
  • What Needs to Be Backed Up in a Kubernetes Cluster?

  • Kubernetes Backup Methods Compared

  • Method 1: Back Up and Restore a Cluster with Velero

  • Method 2: Back Up and Restore etcd

  • Method 3: Export Resource Manifests with kubectl

  • How to Back Up Persistent Volumes

  • Backing Up Managed Kubernetes (EKS, AKS, GKE)

  • Kubernetes Backup Best Practices

  • How Vinchin Backup & Recovery Protects Your Kubernetes Cluster

  • Backup Kubernetes Cluster FAQs

  • Conclusion

A failed upgrade, a deleted namespace, a corrupted volume or a ransomware attack can take down workloads running on Kubernetes in minutes. GitOps and infrastructure-as-code help you rebuild a cluster, but they don’t bring back the data in persistent volumes or the changes made at runtime. That needs backups.

Quick answer: To back up a Kubernetes cluster, protect three things: cluster state (etcd), application objects (Deployments, Services, ConfigMaps, Secrets, CRDs) and persistent volume data. The most common approach is Velero: install it with an S3-compatible bucket, run velero backup create full-backup (with CSI snapshots or file system backup for volumes), and restore with velero restore create --from-backup full-backup. On self-managed clusters, also take etcd snapshots with etcdctl snapshot save for full control-plane recovery.

What Needs to Be Backed Up in a Kubernetes Cluster?

LayerWhat it containsHow to back it up
etcdAll cluster state: every API object, Secrets, RBAC rulesetcd snapshots (self-managed clusters only)
API objectsNamespaces, Deployments, StatefulSets, Services, ConfigMaps, Secrets, CRDs and custom resourcesVelero, or kubectl exports
Persistent volumesApplication data: databases, files, queuesCSI volume snapshots, Velero file system backup, storage-level snapshots or app-level dumps
External configurationHelm values, Git repositories, certificates, cloud IAMVersion control and secrets management

An etcd snapshot restores the whole cluster to one point in time, but can’t restore a single namespace and doesn’t include volume data. Velero backs up objects selectively and can include volumes. Most production clusters use both.

Kubernetes Backup Methods Compared

MethodCoversGranular restoreWorks on managed K8sBest for
VeleroObjects + volumesYes (namespace, resource, label)YesMost clusters; migration between clusters
etcd snapshotEntire cluster stateNoNoControl-plane disaster recovery on self-managed clusters
kubectl exportSelected objectsYes, manuallyYesSmall clusters, ad-hoc copies
Enterprise backup softwareObjects + volumes, with policies and reportingYesYesMany clusters, compliance and long retention

Method 1: Back Up and Restore a Cluster with Velero

Velero is an open-source tool that backs up Kubernetes objects to object storage and protects persistent volumes with CSI snapshots or file system backup.

Step 1. Install the Velero CLI

# macOS
brew install velero

# Linux (replace vX.Y.Z with the latest release)
curl -LO https://github.com/vmware-tanzu/velero/releases/download/vX.Y.Z/velero-vX.Y.Z-linux-amd64.tar.gz
tar -xzf velero-vX.Y.Z-linux-amd64.tar.gz
sudo mv velero-vX.Y.Z-linux-amd64/velero /usr/local/bin/

Step 2. Prepare object storage credentials

Create a bucket in Amazon S3 or any S3-compatible storage (such as MinIO), and a credentials file velero-creds:

[default]
aws_access_key_id = <your_access_key>
aws_secret_access_key = <your_secret_key>

Step 3. Install Velero in the cluster

velero install \
  --provider aws \
  --plugins velero/velero-plugin-for-aws:vX.Y.Z \
  --bucket <your-bucket> \
  --backup-location-config region=<region> \
  --snapshot-location-config region=<region> \
  --secret-file ./velero-creds \
  --use-node-agent

--use-node-agent installs the node agent needed for file system backup of volumes. For S3-compatible storage outside AWS, add s3Url=https://<endpoint>,s3ForcePathStyle=true to --backup-location-config. Check that Velero is running:

kubectl get pods -n velero
velero backup-location get

Step 4. Create backups

# Whole cluster
velero backup create full-backup

# One namespace
velero backup create finance-backup --include-namespaces finance

# Only some resource types, or exclude namespaces
velero backup create apps-backup --include-resources deployments,services,configmaps,secrets
velero backup create no-test-backup --exclude-namespaces test,dev

# Back up volume data with file system backup (when CSI snapshots aren't available)
velero backup create finance-fs-backup --include-namespaces finance --default-volumes-to-fs-backup

Check progress and results:

velero backup describe full-backup --details
velero backup logs full-backup

Step 5. Schedule backups

velero schedule create daily-cluster --schedule="0 2 * * *" --ttl 720h

This runs a full backup every day at 2:00 and keeps each one for 30 days.

Step 6. Restore from a Velero backup

# Restore everything in a backup
velero restore create --from-backup full-backup

# Restore one namespace
velero restore create --from-backup full-backup --include-namespaces finance

# Restore into a different namespace, for testing
velero restore create --from-backup finance-backup --namespace-mappings finance:finance-restore-test

# Check the result
velero restore describe <restore-name> --details

By default, Velero doesn’t overwrite objects that already exist. Delete the damaged namespace first, or restore into a new one. To migrate to another cluster, install Velero there with the same bucket and run the restore.

Method 2: Back Up and Restore etcd

On self-managed clusters (for example kubeadm), etcd holds the entire cluster state. An etcd snapshot lets you recover the control plane after corruption, a failed upgrade or the loss of all control-plane nodes. It does not include persistent volume data.

Take an etcd snapshot

Run this on a control-plane node (paths are kubeadm defaults):

ETCDCTL_API=3 etcdctl snapshot save /backup/etcd-snapshot-$(date +%F).db \
  --endpoints=https://127.0.0.1:2379 \
  --cacert=/etc/kubernetes/pki/etcd/ca.crt \
  --cert=/etc/kubernetes/pki/etcd/server.crt \
  --key=/etc/kubernetes/pki/etcd/server.key

Check the snapshot:

etcdutl snapshot status /backup/etcd-snapshot-$(date +%F).db -w table

The snapshot contains Secrets in plain or encoded form, so encrypt it and copy it off the node.

Schedule etcd snapshots with a CronJob

apiVersion: batch/v1
kind: CronJob
metadata:
  name: etcd-backup
  namespace: kube-system
spec:
  schedule: "0 */6 * * *"
  jobTemplate:
    spec:
      template:
        spec:
          nodeSelector:
            node-role.kubernetes.io/control-plane: ""
          tolerations:
          - key: node-role.kubernetes.io/control-plane
            effect: NoSchedule
          hostNetwork: true
          containers:
          - name: etcd-backup
            image: registry.k8s.io/etcd:3.5.15-0
            command:
            - /bin/sh
            - -c
            - >
              etcdctl --endpoints=https://127.0.0.1:2379
              --cacert=/etc/kubernetes/pki/etcd/ca.crt
              --cert=/etc/kubernetes/pki/etcd/server.crt
              --key=/etc/kubernetes/pki/etcd/server.key
              snapshot save /backup/etcd-$(date +%F-%H%M).db
            volumeMounts:
            - name: etcd-certs
              mountPath: /etc/kubernetes/pki/etcd
              readOnly: true
            - name: backup
              mountPath: /backup
          restartPolicy: OnFailure
          volumes:
          - name: etcd-certs
            hostPath:
              path: /etc/kubernetes/pki/etcd
          - name: backup
            hostPath:
              path: /var/backups/etcd

Use the etcd image version that matches your cluster, and copy the snapshots off the node with your usual sync tool.

Restore etcd on a kubeadm cluster

1. On each control-plane node, stop the API server and etcd by moving their static Pod manifests away:

sudo mkdir -p /etc/kubernetes/manifests-backup
sudo mv /etc/kubernetes/manifests/kube-apiserver.yaml /etc/kubernetes/manifests/etcd.yaml /etc/kubernetes/manifests-backup/

2. Restore the snapshot into a new data directory:

sudo etcdutl snapshot restore /backup/etcd-snapshot.db --data-dir /var/lib/etcd-restored

(On older etcd versions, use ETCDCTL_API=3 etcdctl snapshot restore with the same options.) For multi-member etcd clusters, restore on every member with the --name, --initial-cluster and --initial-advertise-peer-urls options matching each member.

3. Edit /etc/kubernetes/manifests-backup/etcd.yaml so the etcd-data hostPath points to /var/lib/etcd-restored.

4. Move the manifests back to start etcd and the API server:

sudo mv /etc/kubernetes/manifests-backup/etcd.yaml /etc/kubernetes/manifests-backup/kube-apiserver.yaml /etc/kubernetes/manifests/

5. Check the cluster with kubectl get nodes and kubectl get pods -A, then restart kubelet, controller-manager and scheduler if they don’t recover on their own.

Restoring etcd replaces the entire cluster state with the snapshot, including RBAC rules. Anything created after the snapshot is lost.

Method 3: Export Resource Manifests with kubectl

For small clusters or quick copies, export objects as YAML. kubectl get all misses many types, including Secrets, ConfigMaps, PVCs, Ingresses and RBAC, so export every listable resource type in a namespace:

NS=finance
for kind in $(kubectl api-resources --verbs=list --namespaced -o name); do
  kubectl get "$kind" -n "$NS" -o yaml > "backup-$NS-$kind.yaml" 2>/dev/null
done

# Cluster-scoped objects
kubectl get crds -o yaml > crds.yaml
kubectl get storageclasses -o yaml > storageclasses.yaml
kubectl get clusterroles,clusterrolebindings -o yaml > cluster-rbac.yaml

Exported YAML includes runtime fields such as uid, resourceVersion and status. Remove them, or use a tool such as kubectl-neat, before applying the files to another cluster.

Restore order: CRDs → StorageClasses → Namespaces → ConfigMaps and Secrets → PVCs → workloads → Services and Ingresses:

kubectl apply -f crds.yaml
kubectl apply -f storageclasses.yaml
kubectl apply -f backup-finance-*.yaml

This method backs up definitions only, not volume data.

How to Back Up Persistent Volumes

OptionHow it worksConsistency
CSI VolumeSnapshotsThe storage driver snapshots the volumeCrash-consistent unless the app is quiesced
Velero file system backupThe node agent copies files from the mounted volume to object storage (Kopia)Crash-consistent; works with any storage
Storage or cloud snapshotsSnapshots taken on the array or cloud diskCrash-consistent
Application-level backupDatabase tools such as mysqldump or pg_dumpApplication-consistent

A CSI snapshot looks like this:

apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
  name: data-snapshot
  namespace: finance
spec:
  volumeSnapshotClassName: csi-snapclass
  source:
    persistentVolumeClaimName: data-pvc

For databases, take application-consistent backups as well, or use Velero backup hooks to flush and freeze the database during the snapshot. See how to back up databases in Kubernetes for dump-based methods.

Backing Up Managed Kubernetes (EKS, AKS, GKE)

On managed services, the cloud provider runs the control plane and you can’t access etcd. Back up workloads and volumes instead:

  • Use Velero with the provider’s object storage and snapshot plugin.

  • Or use the provider’s backup service, such as Azure Backup for AKS or Backup for GKE.

  • Keep cluster configuration (node pools, IAM, networking) in infrastructure-as-code.

For step-by-step guides, see how to back up an EKS cluster and how to back up AKS.

Kubernetes Backup Best Practices

  • Back up all three layers: etcd (if self-managed), objects and volumes.

  • Store backups outside the cluster, ideally in another region or account, on object storage with immutability (Object Lock) enabled.

  • Encrypt backups; they contain Secrets.

  • Use separate credentials for backup storage, so a compromised cluster can’t delete its backups.

  • Schedule backups and set retention (--ttl in Velero), with longer retention for weekly or monthly backups.

  • Test restores regularly into a separate namespace or cluster; a backup you haven’t restored isn’t proven.

  • Take application-consistent backups of databases and other stateful apps.

  • Monitor backup status and alert on failures.

How Vinchin Backup & Recovery Protects Your Kubernetes Cluster

Velero and etcd scripts work, but managing them across many clusters, with retention, reporting and ransomware protection, takes effort. Vinchin Backup & Recovery provides enterprise-grade Kubernetes backup with:

  • Full and incremental backups at cluster, namespace, application, PVC and resource level

  • Fine-grained restore, including cross-cluster and cross-version recovery and migration across storage backends

  • Policy-based scheduling and multithreaded transfer for large PVCs

  • Encrypted transmission and WORM protection against ransomware

Back up a Kubernetes cluster in four steps:

1. Select the backup source

Select the backup source

2. Choose the backup storage location

Choose the backup storage location

3. Define the backup strategy

Define the backup strategy

4. Submit the job

Submit the job

Trusted globally by enterprises large and small—with top ratings for reliability—Vinchin Backup & Recovery offers a fully featured free trial valid for 60 days so you can experience its power firsthand before committing further.

Backup Kubernetes Cluster FAQs

Q1: Is an etcd backup enough to back up a Kubernetes cluster?

No. etcd contains all API objects but not the data in persistent volumes, and it can only restore the whole cluster at once. Combine etcd snapshots with volume backups, or use Velero for object and volume backups.

Q2: How often should I back up a Kubernetes cluster?

Take etcd snapshots and Velero backups at least daily, and more often for clusters that change frequently or run critical stateful workloads. Always take a backup before upgrades.

Q3: Why are my volumes missing from a Velero backup?

Velero backs up volume data only through CSI/cloud snapshots or file system backup. If neither is configured, only the PVC objects are saved. Install the node agent and use --default-volumes-to-fs-backup, or configure a VolumeSnapshotClass and enable CSI snapshots.

Q4: How do I migrate workloads to another Kubernetes cluster?

Back up the namespaces with Velero, install Velero in the new cluster pointing to the same bucket (read-only is recommended), and run velero restore create --from-backup <name>. Make sure the StorageClasses exist in the new cluster, or map them with Velero’s storage class mapping.

Q5: What should I check if a restored workload fails?

Check pod events and logs, confirm that Secrets, ConfigMaps and PVCs were restored, check that the StorageClass and CRDs exist, and verify that the restored API versions are supported by the cluster’s Kubernetes version.

Q6: How do I protect Kubernetes backups from ransomware?

Store them in object storage with Object Lock or WORM protection, in a separate account with its own credentials, and keep at least one copy offline or in another region.

Conclusion

Backing up a Kubernetes cluster means protecting cluster state, application objects and persistent data together. Use Velero for scheduled, granular backups and migrations, add etcd snapshots on self-managed clusters, take application-consistent backups of databases, and test restores regularly.

For centralized protection across many clusters, try Vinchin Backup & Recovery free for 60 days.

Share on:

Categories: Tech Tips