Skip to main content
In this lesson we cover common Kubernetes backup and restore approaches and what to include in your backups. You’ll learn which cluster artifacts to protect, practical commands for capturing them, and high-level restore notes for etcd snapshots. Earlier you deployed applications using Deployments, Pods, and Services defined in manifest files. The primary backup candidates are:
  • Resource configuration (object manifests)
  • etcd cluster (Kubernetes datastore)
  • Persistent Volumes (application data)
A dark-slide graphic titled "Backup Candidates" showing three items: Resource Configuration, etcd Cluster, and Persistent Volumes. Each item is represented by a blue icon (file with gear, gear-like cluster icon, and stacked-database icon).
Why back these up?
  • Resource manifests let you redeploy and recreate objects in a new cluster or namespace.
  • etcd snapshots capture the authoritative cluster state (including secrets) at a point in time.
  • Persistent Volumes contain application data that must be restored separately from object definitions.

Resource configurations

Kubernetes objects can be created imperatively (kubectl create) or declaratively (apply manifest files). The declarative approach—storing manifests in version control—is the recommended best practice because it enables reproducible deployments, audit history, and CI/CD automation (GitOps). Example Pod manifest (save as pod-definition.yml):
Apply the manifest:
Store manifests in a source-code repository (GitHub, GitLab, etc.) so they are versioned and shareable. With manifests available, you can redeploy workloads even if the cluster is lost. Exporting current cluster objects
  • Not every team follows declarative manifests. When objects are created imperatively, you can export the current API state and persist it as YAML files.
  • A simple capture of common workload objects:
Note: kubectl get all is a convenience resource and does not include every resource type (for example, PersistentVolumeClaims, PersistentVolumes, CustomResourceDefinitions, ClusterRoleBindings, etc.). A comprehensive backup requires enumerating the resource types you need or using a purpose-built tool. Recommended options:
  • Use provider or community tools (for example, Velero) to automate resource and persistent volume backups: https://velero.io
  • If you build scripts, enumerate resources using kubectl api-resources and capture each resource type you depend on.

etcd backups

etcd is the authoritative key-value store for Kubernetes cluster state. Backing up etcd (via filesystem copies or snapshots) gives you a full point-in-time capture of object definitions, node membership, and most cluster metadata. This can be crucial for disaster recovery. Create a snapshot (basic example):
If you have multiple etcdctl binaries, ensure you use the v3 client (for example via ETCDCTL_API=3), and confirm compatibility with the etcd server version. Secure example with explicit endpoints and certificate files:
Verify the snapshot file exists:
High-level restore process
  • Stop kube-apiserver so it does not try to communicate with etcd during restore.
  • Use etcdctl snapshot restore to create a new data directory from the snapshot.
  • Reconfigure the etcd service (or static-pod manifest) to point to the restored directory, set correct cluster bootstrap parameters, restart etcd, and then start kube-apiserver.
Important restore notes:
  • If control plane components are run as static pods (kubeadm managed), the kube-apiserver and etcd may be defined as static pod manifests—stop or replace those manifests appropriately.
  • etcdctl snapshot restore initializes a new data directory and generates fresh cluster metadata (new member IDs). Do not assume a restored data directory will automatically rejoin an existing cluster. Carefully set --initial-cluster, --name, and --initial-cluster-state to match whether you intend to form a new cluster or rejoin nodes.
Example commands (stop kube-apiserver, restore, then restart services):
After the restore, update your etcd service/startup options so --data-dir points to the restored directory and bootstrap flags are correct. Example systemd unit snippet (update --data-dir accordingly):
Reload and restart services:
When running etcdctl in a TLS-enabled cluster, always specify the --endpoints and the CA, client certificate, and key files (--cacert, --cert, --key). Without these flags, etcdctl cannot connect to a secured etcd endpoint.

Choosing a method

Both backing up resource manifests and backing up etcd snapshots have trade-offs. Use the table below to choose the right approach for your environment. Additional considerations
  • Managed Kubernetes (EKS, GKE, AKS): You may not have etcd access. Use provider-managed backup features or export manifests and PV snapshots as supported by the cloud provider.
  • Secrets: Secrets stored in etcd are captured by etcd snapshots. If you only export manifests you must take care not to lose secret data (store secrets in external secret stores or securely back them up).
  • Consistency: For a consistent restore of application state, coordinate etcd snapshots with PV snapshots (application-consistent backups require quiescing or using storage-provider volume snapshots).
Tools and references That’s it for this lesson. Practice taking and restoring etcd snapshots and exporting manifests in a lab environment to validate your processes and scripts.

Watch Video