etcd Backup and Restore in Kubernetes
Learn what etcd really holds, how snapshots work, how to plan, automate, verify and restore them, and what the cluster does after a restore, so a bad day never becomes the end of your cluster.
Imagine a large office building where every door, every key card, every room booking and every staff list is written in one master ledger kept in the manager’s office. The guards, the cleaners and the receptionists all work by reading that ledger. Now imagine the ledger is destroyed in a fire and nobody ever made a copy. The building is still standing, and people are still inside, but nobody knows who is allowed where, and nothing new can be arranged.
In Kubernetes, that master ledger is called etcd. Everything the cluster knows about itself lives there. If etcd is lost and there is no backup, the cluster loses its memory. In this guide you will learn what etcd stores, how it works, how to take snapshots, how to keep them safe, how to restore from them, and what to expect afterwards. You will also learn the habits that separate calm recoveries from long, painful nights.
1What Is etcd and Why Does Kubernetes Depend on It?
etcd is the one place where a Kubernetes cluster keeps its memory. Lose it, and the cluster forgets who it is.
etcd is a small, very reliable database. Its name comes from the Linux folder /etc, where configuration files live, plus the letter “d” for “distributed”. It stores information as key-value pairs, which means each piece of data has a name (the key) and a content (the value), much like a labelled folder in a filing cabinet. It was created at CoreOS in 2013 and is now a graduated project of the Cloud Native Computing Foundation.
Kubernetes uses etcd as the only permanent store of cluster state. When you create a Deployment, the record of that Deployment is written to etcd. When a node joins, its record is written to etcd. When you change a setting, the new value goes to etcd. Nothing else in the control plane keeps durable data of its own.
Think of etcd as the master ledger of a hotel. It lists every room, every guest, every booking and every rule. The front desk (the API server) reads and writes the ledger all day. The housekeepers (controllers) check it to see what work is needed. If the ledger vanishes, the hotel can still have guests sleeping in rooms, but nobody can check in, check out or fix anything.
Who is allowed to talk to etcd?
Only the Kubernetes API server talks to etcd directly. The scheduler, the controller manager, the kubelets and all your tools talk to the API server instead. This keeps one gatekeeper in front of the data and means every change passes through authentication, authorization and validation first.
flowchart LR
U["Users and kubectl"] --> A["API Server"]
S["Scheduler"] --> A
M["Controller Manager"] --> A
K["Kubelets on Nodes"] --> A
A --> E[("etcd Cluster")]
E --> B["Backup Snapshot Files"]
What happens if etcd is lost?
Containers that are already running on worker nodes usually keep running for a while, because the kubelet on each node does not need etcd to keep an existing container alive. But the cluster can no longer be managed. You cannot deploy, scale, heal, or even list what exists. If the data is truly gone, the whole description of your cluster is gone with it, and you would have to rebuild every object by hand.
Backing up etcd is not about protecting your application data. It is about protecting the description of your cluster: the objects, settings and permissions that make it work.
2What Lives Inside etcd, and What Does Not
Knowing exactly what a snapshot contains tells you what a restore can bring back, and what it cannot.
etcd holds the desired state and the recorded state of every Kubernetes object. That includes Pods, Deployments, StatefulSets, Services, ConfigMaps, Secrets, Namespaces, Roles and Role Bindings, Persistent Volume records, Custom Resource Definitions and every custom resource, plus the records of nodes and short-lived leases. Each object is saved under a key that starts with a common prefix, usually /registry, followed by the type and the namespace and name.
Workload objects
Deployments, StatefulSets, DaemonSets, Jobs and Pods. These describe what should be running.
Configuration
ConfigMaps, Secrets, Services and Ingress rules that tell applications how to behave and how to be reached.
Access rules
Roles, bindings and service accounts. Without these, nobody can log in or do anything.
Extensions
Custom Resource Definitions and every custom resource made from them, which operators depend on.
Container images
These live in registries and on node disks, not in etcd.
Volume data
Your databases, uploaded files and anything on persistent disks. etcd stores only the record that a volume exists.
The etcd database is like the table of contents and the rules of a library, not the books. It records which shelves exist, who may borrow what and which books are checked out. If you lose the table of contents you can still find the books, but only with much pain. If you lose the books themselves, the table of contents cannot bring them back.
A word about Secrets
Kubernetes Secrets are stored in etcd, and by default they are only encoded, not encrypted. A snapshot file therefore contains your passwords, tokens and keys in a readable form. If you turn on encryption at rest in the API server, the Secrets inside etcd are scrambled with a key that lives in a separate configuration file. That helps, but it adds one more thing to protect and back up, which later chapters explain.
An etcd snapshot does not contain the contents of your volumes or the cloud resources your cluster created, such as load balancers and disks. A complete recovery plan needs more than etcd alone.
3Internal Working: Raft, the Write-Ahead Log and Revisions
You do not need to be a database expert, but four ideas explain almost every backup and restore rule you will ever meet.
Idea 1: A group of members that agree
A production etcd runs as a group of three or five members, each on its own machine. They use an agreement method called Raft. In Raft, one member is the leader and the others are followers. All writes go through the leader. The leader sends each change to the followers, and the change counts as saved only when a majority of members confirm that they wrote it to disk.
That majority is called a quorum. For three members the quorum is two, and for five members it is three. A group can lose members and keep working only while a quorum survives.
Picture a committee that must approve every decision by majority vote. One person, the chair, proposes. Others reply “yes, I wrote it down”. Once more than half have said yes, the decision is final. If too many members are absent, the committee cannot vote at all, and everything freezes until enough of them return.
sequenceDiagram
participant A as API Server
participant L as Leader
participant F1 as Follower 1
participant F2 as Follower 2
A->>L: Write request
L->>L: Append to write-ahead log
L->>F1: Send log entry
L->>F2: Send log entry
F1-->>L: Entry saved
F2-->>L: Entry saved
L->>L: Quorum reached, commit
L-->>A: Write confirmed
Idea 2: The write-ahead log
Before a change is applied to the main database file, each member writes it to a write-ahead log, usually called the WAL, and forces it onto the disk. If the machine loses power in the next second, the log still holds the change and the member can replay it on restart. This is why etcd is very sensitive to slow disks: every write waits for the disk to confirm.
Idea 3: Revisions and history
etcd never overwrites a value in place. Every change creates a new revision, a number that only goes up. Old versions of a key stay on disk until a cleanup step called compaction removes history older than a chosen point. After compaction, the database file still has empty holes in it, and a second step called defragmentation squeezes them out. Kubernetes triggers compaction automatically on a regular schedule, but defragmentation is usually something operators schedule themselves.
Idea 4: Internal snapshots versus backup snapshots
etcd itself takes internal snapshots of its state from time to time so it can shorten the log. These are part of normal housekeeping and are not a backup plan. A backup snapshot is one that you ask for, copy out of the etcd data folder and store somewhere safe. The rest of this guide is about the second kind.
Because etcd keeps a consistent view at each revision, a snapshot taken from one healthy member is a complete, point-in-time picture of the whole cluster. You do not need to freeze the cluster or stop any member to take it.
4Why Back Up at All? High Availability Is Not a Backup
Many teams think three etcd members means they are safe. They are safe from some failures, and completely exposed to others.
Running several etcd members protects you when one machine dies. It does not protect you when the data itself is wrong, because every member holds a copy of the same wrong data a few milliseconds later. If someone deletes a namespace by mistake, all members agree that it is deleted. Replication spreads mistakes as faithfully as it spreads good data.
A mirror shows you exactly what is in front of it, right now. If you spill coffee on your shirt, the mirror shows the stain instantly. A photo album, on the other hand, keeps a picture of yesterday. High availability is the mirror. A backup is the photo album.
The failures you should plan for
| What went wrong | Does replication help? | What you need |
|---|---|---|
| One member machine dies | Yes, the others carry on | Replace the member; no restore needed |
| A minority of members lost | Yes, quorum remains | Replace members one by one |
| A majority of members lost | No, writes stop | Restore from a snapshot |
| All members lost, for example a whole zone or site outage | No | Restore from an off-site snapshot |
| Disk corruption or a software bug | Maybe not | A clean earlier snapshot |
| Human error, such as deleting a namespace | No, it replicates the deletion | A recent snapshot taken before the mistake |
| Bad upgrade or migration | No | A snapshot taken just before the change |
| Malicious attack or ransomware | No | A protected, immutable, off-site copy |
The two kinds of recovery
It helps to split recovery into two very different jobs. Member repair is the gentle job: you remove a dead member and add a fresh one, and the new member copies the data from its healthy peers. No backup is used. Cluster restore is the heavy job: the group has lost its quorum or its data, so you build a brand-new group from a snapshot file. Always try to use the gentle job when it is enough, and keep the heavy job for when you truly need it.
Restoring a snapshot when you only lost one member throws away every change made since the snapshot was taken. Before you restore, always check whether the remaining members still hold a healthy quorum.
5Planning Your Backups: RPO, RTO, Frequency and Retention
Before you type a single command, decide how much you can afford to lose and how long you can afford to wait.
Two short terms guide every backup plan. RPO, the Recovery Point Objective, is how much recent data you can afford to lose. If your RPO is thirty minutes, you must have a snapshot at least every thirty minutes. RTO, the Recovery Time Objective, is how long you can afford to be down. If your RTO is one hour, your restore steps must be rehearsed and fast enough to finish within an hour.
If you write an important essay, RPO is how often you press “save”: every minute, or only at the end of the day. RTO is how fast you can get back to typing after your laptop breaks: a spare laptop ready on the desk, or a trip to the shop to buy one.
Choosing how often to snapshot
Clusters change at different speeds. A development cluster that changes once a day may need a snapshot only every few hours. A busy production cluster where deployments run all day and operators update status constantly may need a snapshot every fifteen to thirty minutes. Remember that anything created after the last snapshot is lost in a restore, so frequency is the main lever for reducing loss.
Choosing how long to keep them
Keep several generations, not only the newest. Mistakes are often noticed days later, and the newest snapshot may already contain the mistake. A common pattern is to keep frequent snapshots for a day or two, daily ones for a few weeks and weekly ones for a few months. Apply the pattern with automatic rules so old files do not pile up forever.
List what you must recover
Write down which clusters matter, which are production, and which could simply be rebuilt from code.
Set RPO and RTO per cluster
Agree on numbers with the business owners, not just the platform team. Different clusters can have different goals.
Pick frequency and retention
Choose a schedule that meets the RPO, and a retention ladder that covers late-noticed mistakes.
Choose where copies live
At least one copy must live outside the cluster, outside the machine and ideally outside the region.
Write and rehearse the restore steps
An untested restore plan is only a hope. Schedule practice runs and time them against the RTO.
Take a fresh snapshot just before every cluster upgrade, certificate rotation, large migration or risky maintenance. It costs a few seconds and turns a disaster into a short delay.
6Taking a Snapshot: What Really Happens
Taking a snapshot is a short, safe operation, and understanding its parts helps you do it correctly every time.
The standard tool is etcdctl, the command-line client that ships with etcd. Its snapshot save action connects to one etcd member and asks it to stream a consistent copy of its database into a single file. The cluster keeps running while this happens. The copy represents the exact state of the cluster at one moment, even though the stream takes a few seconds or minutes to write.
Think of taking a photograph of a busy street with a camera that freezes the whole scene in one click. People keep walking afterwards, but the photo shows the exact moment you pressed the button. A snapshot freezes a point in the life of the cluster in the same way.
What the tool needs from you
- An address. The location of one etcd member, usually on port 2379 for client traffic. A snapshot talks to a single member, so give it one address.
- Proof of identity. etcd in a Kubernetes cluster almost always requires TLS, so you must provide the certificate authority file, a client certificate and its private key. In clusters created by kubeadm, these usually live under the Kubernetes PKI folder in an etcd sub-folder on the control plane node.
- A matching tool version. Use an
etcdctlthat matches the major and minor version of the running etcd. Mismatched versions are a common cause of strange errors. - A place to write. A folder with enough free space for a file about as large as the etcd database.
Where to run it
You can run the tool directly on a control plane node, where the certificates already exist. You can also run it inside the etcd Pod in clusters where etcd runs as a static Pod, or from a small helper Job scheduled onto a control plane node. The goal is the same: reach a healthy member with valid credentials.
Checking the result
A snapshot file that cannot be read is worse than no snapshot, because it gives false comfort. After saving, inspect the file with the status action of etcdutl, the companion tool for working on files. It shows the file’s integrity hash, the revision it represents, the total number of keys and the size. If the key count is zero or the size is tiny, something went wrong. Newer etcd releases moved offline file operations from etcdctl to etcdutl, so older tutorials may show different tool names.
Why not just copy the data folder?
You may see advice to copy the database file straight from the member’s data folder. This can work, but the file may be in the middle of a write, the copy lacks the safety checks, and restoring from it needs a special flag to skip the integrity hash. The snapshot action is the supported way because it produces a verified, consistent file.
If the tool cannot reach a member, it may fail silently inside a script that never checks the exit code. Automated jobs must treat any failure as a failed backup and raise an alert.
7Verifying and Storing Snapshots Safely
A backup that sits on the same disk as the thing it protects is not a backup. Where you store the file matters as much as taking it.
The control plane node that holds etcd is exactly the machine most likely to be lost in a disaster. Copy every snapshot off that machine right away. Good homes for snapshots are object storage such as Amazon S3, a separate backup system, or at least a different server in a different zone. Name the files with the cluster name and the date and time, so you can find the right one quickly when you are tired and stressed.
Keeping your backup on the same server is like keeping a spare house key under the doormat of the house it opens. It is convenient, and useless on the day you are locked out by a fire. A spare key at a friend’s home across town is the real backup.
A safe layout on Amazon S3
If you run Kubernetes on AWS, S3 is a natural home. These features make it much safer.
Versioning
Keeps old copies when a file is overwritten or deleted, so one wrong command cannot erase your history.
Encryption with KMS
Encrypts every file with a key you control. Snapshots contain Secrets, so this is not optional for production.
Object Lock
Makes files unchangeable for a set time, which defends against attackers and accidents that try to delete backups.
Cross-region replication
Copies files to another region automatically, so a regional outage cannot take both the cluster and the backup.
Lifecycle rules
Moves old files to cheaper storage and deletes them after the retention period you chose.
Narrow permissions
The job that uploads snapshots should be able to write, but not to delete or read others. Restoring is a separate, more guarded role.
Verify, do not assume
For each new snapshot, run at least the cheap checks automatically: the file exists, its size is within an expected range of the last one, and its status can be read with the hash and revision. Record the result in a log or metric. Once in a while, run the expensive check as well: restore the snapshot in a scratch environment and make sure a test API server starts and shows the objects you expect. Chapter 18 explains these drills.
8What Else to Back Up Besides the Snapshot
An etcd snapshot is the heart of the plan, but a few other pieces decide whether a restore really works.
Encryption configuration and keys
If Secrets are encrypted at rest, the API server uses a key listed in its encryption configuration file. A snapshot restored without that key contains Secrets that nobody can read, and the API server may fail to start. Back this file up separately from the snapshots, in a place with tight access control.
Certificates and the PKI folder
The control plane’s certificates and keys tie the components together. Clusters made with kubeadm keep them in a known folder. Without the original certificate authority you must regenerate every certificate and re-join every node. Copy this folder to the same safe place.
Control plane manifests and configuration
The static Pod files for the API server, controller manager, scheduler and etcd, and the kubeadm configuration, show exactly how your control plane was built. They are small and precious when you need to rebuild a node.
Persistent volume data
etcd holds only the record of a volume. The real data sits on disks. Use cloud disk snapshots, such as Amazon EBS snapshots, or a tool that handles volumes, and keep them in step with your etcd snapshots as far as you can.
Application manifests in Git
If your Deployments, Services and settings are stored in Git and applied by a GitOps tool such as Argo CD or Flux, you can rebuild most of the cluster’s workloads without any snapshot at all. Git and etcd snapshots complement each other: Git gives you the intended state, the snapshot gives you the exact runtime state.
Object-level backup tools
Open-source tools such as Velero back up Kubernetes objects through the API and can snapshot volumes too. They let you restore a single namespace without rolling back the whole cluster, which an etcd snapshot cannot do. Many teams use both: etcd snapshots for full disaster recovery and an object-level tool for everyday, smaller restores.
Ask yourself, “If this machine and everything on it vanished tonight, could I rebuild the cluster from what I have stored elsewhere?” If any answer is “no”, you have found a gap.
9Automating Backups So Nobody Has to Remember
A backup that depends on a person remembering will eventually be forgotten. Automation turns good intentions into a habit.
A reliable backup job has four small parts. It takes a snapshot, checks it, copies it to safe storage, and reports success or failure. The job runs on a schedule that matches your RPO. If any part fails, a person is told within minutes, not months.
flowchart LR
T["Scheduler: CronJob or timer"] --> S["Take snapshot from one etcd member"]
S --> V["Check hash, revision and size"]
V --> U["Upload to remote object storage"]
U --> R["Apply retention rules"]
V -- "Failed" --> X["Raise alert"]
U -- "Failed" --> X
U --> M["Record success metric"]
Common ways to schedule it
A CronJob on the control plane
A small Pod is scheduled onto a control plane node, mounts the certificate folder, takes the snapshot and uploads it. It needs permission to run on those protected nodes.
A system timer or cron entry
A simple script run by the operating system on a control plane node. It does not depend on the cluster being healthy, which is a big advantage during an outage.
Built into the distribution
Some tools do this for you. The kops project uses a helper called etcd-manager that backs up etcd to its S3 state store. RKE2 and K3s take scheduled snapshots by default, and OpenShift provides a documented backup script for control plane nodes.
A central backup system
Large companies often run snapshots through their existing backup software, so etcd follows the same retention and reporting rules as everything else.
Think of a smoke alarm versus a person who promises to sniff for smoke every hour. The alarm never forgets, never sleeps, and shouts when something is wrong. An automated backup is a smoke alarm for your data.
Keep the backup path independent
Where possible, make the backup job work even when the Kubernetes API is down. A node-level timer that reads straight from etcd keeps working when the API server is broken. If you use a CronJob, remember that it needs a working scheduler and API server to run at all, so also watch for the case where backups silently stop because the cluster itself is unhealthy.
The most dangerous failure is a backup job that quietly stops running. Alert when no new snapshot has appeared in more than twice the normal interval, not only when a job reports an error.
10Before You Restore: Decide, Prepare, Protect
A restore is an emergency operation that rewinds time. Slow down for five minutes at the start, and you may save five hours at the end.
Restoring is a big step. It replaces the cluster’s memory with an older one. Everything changed since the snapshot is gone from Kubernetes’ point of view. So the first question is not “how do I restore?” but “do I need to?”
| Situation | Best action |
|---|---|
| One member is down; the others are healthy | Replace that member; do not restore |
| Quorum is intact but a member has a corrupt disk | Remove it and add a fresh member |
| Quorum is lost and cannot be recovered | Restore the cluster from a snapshot |
| All members are gone | Restore into new machines from an off-site snapshot |
| A namespace or a few objects were deleted | Prefer an object-level restore tool or Git; use a snapshot only if nothing else is possible |
| Data is wrong but the cluster is up | Pick the last snapshot taken before the problem |
The pre-restore checklist
Confirm the real problem
Check member health and quorum before you decide. A network problem can look like a data loss and fix itself.
Choose and verify the snapshot
Pick the newest one that is known to be good. Check its status and confirm the revision and key count look right.
Stop writers
Pause anything that writes to the cluster: automation, deployment pipelines and operators. Tell the team the cluster is in recovery.
Preserve the evidence
Copy or rename the current etcd data folders instead of deleting them. They may help you understand what happened, or save you if the restore goes wrong.
Match the versions
Use the same etcd version as the one that produced the snapshot, or a version the etcd project documents as compatible. Never restore with a much older tool.
Gather the companions
Have the certificates, encryption configuration and control plane manifests at hand before you begin.
Before a surgeon operates, the team confirms the patient, the procedure and the side. They pause on purpose. A restore deserves the same pause, because the wrong snapshot or the wrong cluster can turn a bad day into a much worse one.
11Restoring a Cluster Step by Step
The restore itself is a handful of clear steps. Understanding why each step exists makes it hard to get wrong.
The key idea is that a restore does not put data back into a running etcd. Instead, the tool reads the snapshot file and builds a brand-new data folder for a brand-new cluster. Then you start etcd from that new folder. The restored cluster has a new identity, which protects it from accidentally mixing with any old members that might still be alive somewhere on the network.
flowchart TD
A["Stop API servers and other writers"] --> B["Stop every etcd member"]
B --> C["Keep old data folders safe"]
C --> D["Run snapshot restore on each member using the same snapshot file"]
D --> E["Give each member its name, peer address and the full member list"]
E --> F["Point etcd to the new data folder"]
F --> G["Start all etcd members"]
G --> H{"Members healthy and has leader?"}
H -- "No" --> D
H -- "Yes" --> I["Start API server, controller manager, scheduler"]
I --> J["Verify nodes, objects and workloads"]
Stop the writers
On kubeadm clusters, control plane components run as static Pods defined by files in a manifests folder. Moving those files out of the folder makes the kubelet stop the Pods. Stop the API server first so nothing writes during the restore.
Stop every etcd member
The old group must not run while you build the new one. Make sure no etcd process is still active on any control plane node.
Set the old data aside
Rename the existing data folder, usually under the system’s lib directory, so the restore can write to a clean place and you keep a fallback.
Restore on every member
Run the restore action of etcdutl on each control plane node, using the same snapshot file. For each node, give its member name, its own peer address, the complete list of all members and their peer addresses, a fresh cluster token and the new data folder. In a single-node cluster this is one run.
Point etcd at the new folder
Update the etcd static Pod definition so its data folder setting and its host path mount refer to the restored folder. Make sure the member settings match what you gave the restore.
Start etcd and check health
Bring the members up together. Confirm that all members are listed, that one is the leader and that the health check passes with your certificates.
Start the rest of the control plane
Put the API server, controller manager and scheduler manifests back. Watch their logs for errors, especially about encryption keys or certificates.
Verify and reconcile
Check that nodes are Ready, that the objects you expect exist, and that workloads come back. Chapter 12 explains what to look for.
Each member must be told about all the others during the restore. If one member is restored with a different list or a different token, the group cannot form, and you will see members that refuse to join. Write the list down once and reuse it on every node.
If you only have a copied database file rather than a proper snapshot, the restore tool will reject it because the integrity hash is missing. A special option lets you skip that check, but treat this as a last resort, because you lose the safety net of the hash.
12After the Restore: Data Flow and Lifecycle of a Time Jump
A restored cluster has travelled back in time. The world outside the cluster did not.
When etcd comes back from a snapshot, Kubernetes believes it is the moment the snapshot was taken. Meanwhile, the real world has moved on: containers kept running, cloud resources were created, passwords were changed. Most of the effort after a restore is about reconciling that gap.
Imagine the hotel ledger is replaced with yesterday’s copy. Guests who checked in today are in rooms the ledger says are empty. Guests who left this morning are shown as still staying. Staff must walk the corridors and fix the differences room by room. Controllers and kubelets do exactly this walk.
What you can expect
Objects created after the snapshot are gone
A Deployment made an hour after the snapshot does not exist anymore. Its Pods are no longer wanted, so kubelets will usually stop those containers once they see that the Pods are missing from the restored state.
Objects deleted after the snapshot come back
Something you intentionally removed will reappear and controllers will happily recreate its Pods. Review the list of recent deletions so you can remove them again.
Rotated Secrets may be out of date
If a password or token was changed after the snapshot, the cluster now holds the old one while the real system expects the new one. Applications may fail to log in until the Secret is updated.
Cloud resources can be orphaned or recreated
Load balancers, disks and databases created by the cluster after the snapshot still exist in your cloud account but are unknown to Kubernetes, which means they may cost money and confuse people. In the other direction, a custom resource that manages cloud resources, such as those from AWS Controllers for Kubernetes, may cause something you deleted to be created again, so check them first.
Volumes need a close look
A volume record may point to a disk that was deleted or replaced after the snapshot. Check that every persistent volume still matches a real disk before letting stateful workloads write data.
Clients and caches may need to refresh
Controllers and tools keep a local cache and remember a revision number. After a restore, those numbers can be ahead of the new cluster’s. Most clients notice and reload everything, but long-running operators sometimes need a restart. Newer etcd releases offer options on restore that move the revision forward so that watchers know to refresh.
The lifecycle in order
Control plane returns
The API server starts, reads the restored state, and controllers begin to reconcile.
Nodes report in
Kubelets reconnect, refresh their heartbeats and compare running containers to the restored list of Pods.
Workloads converge
Missing Pods are recreated and unwanted ones are stopped, until the actual state matches the restored desired state.
People reconcile the outside world
Teams re-apply lost changes from Git, update stale Secrets, clean orphaned cloud resources and confirm data volumes.
13Managed Kubernetes: EKS, GKE and AKS
In a managed service, the provider runs etcd for you, and the rules of backup change completely.
On services like Amazon EKS, Google GKE and Azure AKS, the control plane, including etcd, belongs to the provider. You cannot log in to the etcd machines, read their certificates or run a snapshot command against them. Amazon, for example, runs the EKS control plane across several Availability Zones, with multiple API server instances and an etcd group spread across three zones, so a single machine or zone failure does not stop the cluster.
Living in a managed apartment building is different from owning a house. The building company looks after the boiler, the wiring and the fire exits. You cannot repair the boiler, but you also do not have to. You are still responsible for locking your own door and keeping a copy of your own documents.
What is still your job
The provider protects against infrastructure failure. It does not protect against your own mistakes. If someone deletes a namespace in your EKS cluster, the cloud company will not bring it back. Provider-side backups exist for their own disaster recovery and are not offered as a self-service restore point for individual customers.
Keep manifests in Git
Apply them with GitOps tools so the cluster can be rebuilt from code at any time.
Use an object-level backup tool
Tools such as Velero save Kubernetes objects and volume snapshots to your own storage, and can restore a namespace or a whole cluster into a new one.
Snapshot your volumes
Use cloud disk snapshots for stateful data, scheduled and retained like your other backups.
Protect the infrastructure code
Keep the cluster’s own definition, in tools like Terraform or CloudFormation, in version control so a new cluster can be created quickly.
With managed clusters, the strongest recovery plan is usually “create a new cluster from code, then restore objects and volumes into it”. Practise it, because it is your real disaster recovery path.
14Security of etcd and Its Backups
Whoever holds an etcd snapshot holds the keys to the entire cluster. Treat the file like a master password.
A snapshot contains every object, including Secrets, service account tokens and configuration. Someone who obtains a snapshot can read it offline, at their leisure, with no logs and no alarms. This makes backups a favourite target. The following rules reduce the risk.
Never expose etcd
Allow the client port (2379) only from the API servers and backup jobs, and the peer port (2380) only between etcd members. Use firewalls or security groups.
Mutual TLS everywhere
Both clients and members should prove who they are with certificates. Keep the etcd certificate authority separate from other uses.
Encryption at rest for Secrets
Turn on API server encryption for Secrets, so even a stolen snapshot does not reveal them directly. Store the key separately from the snapshots.
Encrypted backup storage
Encrypt snapshot files in storage with a managed key, and restrict who can use that key.
Separate roles
The backup job needs write access only. A small, audited group should hold the right to read snapshots or run a restore.
Immutable copies
Use write-once storage settings for at least one copy so that an attacker, or a tired operator, cannot erase your history.
A backup tape of your bank’s records is as sensitive as the vault itself. You would not leave it on a shelf by the front door. You would lock it in a different building, record who takes it out, and keep the lock’s key somewhere else.
Keep the key apart from the lock
A good rule is that stealing one thing must never be enough. Store encryption keys in a different place, with different access, than the snapshots they protect. Log every read of the backup bucket and alert on unusual access. Review the list of people and systems that can restore at least once a year.
The permission to restore an etcd snapshot is effectively the permission to replace the entire cluster state. Grant it rarely, use it with two people, and record every use.
15Performance, Size and Scalability
etcd is small by database standards, but it is picky. Disk speed and database size decide how healthy your backups and restores will be.
etcd waits for the disk on every write, so fast, low-latency disks matter more than anything else. Solid-state drives, and on cloud platforms provisioned or local SSD volumes, are the norm. Keep the etcd data on its own disk where you can, so a noisy neighbour such as logging cannot slow down the cluster’s memory.
Size and the quota
etcd has a storage size limit, 2 GiB by default and adjustable. If the database grows past the limit, etcd raises an alarm and switches to a read-only mode where it only accepts deletions. The cluster is effectively frozen. The cure is to compact old revisions, defragment and then clear the alarm. This is one of the most common etcd emergencies and is entirely avoidable with monitoring.
A cupboard keeps filling up with old magazines. Compaction is throwing the old issues away. Defragmentation is rearranging what is left so the empty space becomes one big gap instead of lots of small holes. Without both, you run out of room even though half the cupboard is air.
| Topic | Why it matters for backup and restore | What to do |
|---|---|---|
| Database size | Bigger databases mean bigger snapshots, slower uploads and longer restores | Keep objects small; clean up unused objects; watch growth |
| Defragmentation | Blocks a member while it runs and reclaims space | Do one member at a time, off-peak, followers before the leader |
| Churn | Very frequent updates, for example constant status writes or many short-lived objects, grow history fast | Reduce needless updates; review noisy operators |
| Snapshot timing | Streaming a large file reads the disk heavily | Snapshot from a follower; avoid the busiest times when possible |
| Restore time | Depends on file size and disk speed | Time your drills and compare to your RTO |
Keep objects and namespaces tidy
Large ConfigMaps, thousands of leftover Jobs and huge custom resources inflate etcd. Each Kubernetes request is also limited in size, around a megabyte and a half by default. Set time-to-live values on finished Jobs so Kubernetes cleans them up, and avoid storing big payloads in objects.
16High Availability: Topologies and Replacing Members
Good high availability means you rarely need the heavy restore, because most failures are handled by the group itself.
How many members?
Always use an odd number. Three members tolerate one failure, and five tolerate two. Four members tolerate only one failure, the same as three, so the extra machine only adds cost and slightly slower writes. More than five is rarely useful, because every write must reach a majority, and more members mean more messages. Spread members across at least three failure zones, so losing one zone still leaves a majority.
| Members | Quorum | Failures tolerated |
|---|---|---|
| 1 | 1 | 0, no protection at all |
| 3 | 2 | 1 |
| 4 | 3 | 1 |
| 5 | 3 | 2 |
| 7 | 4 | 3 |
Stacked or external?
In a stacked topology, which is the kubeadm default, each control plane node runs an API server and an etcd member together. It is simple and needs fewer machines, but losing a node loses both a control plane instance and an etcd member. In an external topology, etcd runs on its own machines. It costs more but separates the failure of etcd from the failure of the control plane, and lets you tune and protect etcd on its own.
flowchart TB
subgraph Stacked["Stacked topology"]
direction LR
N1["Control plane node 1: API server + etcd"]
N2["Control plane node 2: API server + etcd"]
N3["Control plane node 3: API server + etcd"]
N1 --- N2
N2 --- N3
N1 --- N3
end
subgraph External["External topology"]
direction LR
C1["Control plane node 1: API server"]
C2["Control plane node 2: API server"]
C3["Control plane node 3: API server"]
E1[("etcd 1")]
E2[("etcd 2")]
E3[("etcd 3")]
C1 --> E1
C2 --> E2
C3 --> E3
E1 --- E2
E2 --- E3
E1 --- E3
end
A stacked setup is a small shop where each manager also keeps a copy of the ledger in their own office. An external setup is a company that keeps the ledgers in a separate records building with its own guards. The second costs more, and is safer when the shop has a problem.
Replacing a dead member without a restore
If one member of a healthy group is lost, you do not need a snapshot. You tell the group to forget the dead member, prepare a fresh machine, and ask the group to add it as a new member. The new member then copies the data from its peers on its own. Do this carefully and one member at a time, never replacing two at once, so the group never loses its quorum while you work.
When a member is truly dead, remove it from the group before adding its replacement. Adding a fourth member while one is down raises the number of votes needed for quorum from two to three, which can leave the group stuck if another member fails. After the swap, check health before touching anything else.
17Monitoring, Logging and Metrics
You want to hear about a sick etcd or a missing backup from an alert, not from an angry user.
etcd publishes detailed metrics in the Prometheus format on its own metrics address. Collect them and graph them. Good monitoring watches two things: the health of the etcd group, and the health of the backup process. Many teams do the first and forget the second.
Signals about etcd itself
Has a leader
The metric etcd_server_has_leader should always be 1. A zero means the member sees no leader, often a sign of lost quorum or a network split.
Leader changes
The counter etcd_server_leader_changes_seen_total rising often points to unstable networks or overloaded disks.
Write-ahead log sync time
The histogram etcd_disk_wal_fsync_duration_seconds shows how long disk syncs take. Slow values are the leading cause of etcd trouble.
Database size versus quota
Compare etcd_mvcc_db_total_size_in_bytes against the configured quota and alert well before it is full, for example at 70 to 80 percent.
Failed proposals
The counter etcd_server_proposals_failed_total grows when writes cannot reach agreement, often during leader trouble.
Peer round-trip time
The histogram etcd_network_peer_round_trip_time_seconds shows how fast members talk to each other. Spikes come before many incidents.
Signals about backups
- Freshness. Time since the last successful snapshot. This is the most important backup alert.
- Size trend. A sudden drop to a tiny size, or a jump to many times the usual, deserves a look.
- Upload success. Whether the copy to remote storage finished, and whether the remote copy can be read.
- Drill results. The date and outcome of the last restore test, and how long it took against your RTO.
A car dashboard has a temperature gauge and a low-fuel light. You do not wait for the engine to stop. The metrics above are your dashboard. And the backup freshness alert is the light that tells you the spare tyre is missing, long before you get a flat.
Logs worth reading
etcd logs warnings such as requests that took too long and slow disk syncs. They often appear hours before a visible outage. Send etcd logs to your central logging system, keep them for a fair period, and add a search for those slow-disk and leader-change messages to your regular health review.
18Testing Restores: Drills That Build Confidence
The only backup you can trust is one you have already restored.
Many teams discover on the worst day that their backups were empty, that the keys were missing, or that the steps took four hours instead of one. A restore drill is a rehearsal done on a quiet day in a safe place. It finds those surprises while they are cheap.
A fire drill feels like a waste of time until the day there is a fire. People know where the exits are, who is in charge and which door sticks. A restore drill gives your team the same calm muscle memory.
Pick a recent production snapshot
Fetch it from the real backup storage, using the real permissions, so the access path gets tested too.
Build an isolated scratch environment
Use a few spare machines or a throwaway cluster with no route to production, so the restored cluster cannot touch real cloud resources.
Follow the written runbook exactly
Do not use memory. If the runbook is wrong or unclear, fix it right away. Start a timer.
Check the results
Confirm the API server starts, key namespaces and Secrets exist, custom resources are present, and a sample workload runs.
Compare to your RTO
Record how long each step took. If the total is longer than your RTO, simplify, automate or practise more.
Record lessons and update
Update the runbook, scripts and alerts. Share the results with the whole team, and schedule the next drill.
What to rehearse
- Replacing a single failed member in a healthy group.
- Rebuilding a whole group from a snapshot after total loss.
- Recovering when the encryption key is needed, and when it is missing, so you know the real consequences.
- Restoring into brand-new machines in a different zone or region.
- Handling the aftermath: stale Secrets, orphaned cloud resources and volume checks.
Run a restore drill after every major cluster upgrade and at least a few times a year. Automate the parts that can be automated, such as fetching a snapshot and checking that an isolated etcd starts from it.
19Advantages, Disadvantages and Trade-offs
No single backup method does everything. Knowing what each tool is good at lets you combine them wisely.
| Method | Best at | Not good at |
|---|---|---|
| etcd snapshot | Whole-cluster disaster recovery; exact state of every object | Restoring one namespace; saving volume data; managed clusters |
| Object-level backup tool | Namespace restores, migrations, cloud and managed clusters | Replacing the control plane’s internal state exactly |
| GitOps repository | Rebuilding intended workloads, audit history | Capturing runtime-created objects, Secrets and status |
| Volume snapshots | Protecting application data on disks | Protecting cluster definitions |
| Infrastructure as code | Recreating clusters, networks and nodes quickly | Anything that lives inside the cluster |
Advantages of etcd snapshots
- Complete picture of the cluster at one exact moment.
- Online and quick; no downtime to take it.
- Works at the level just below Kubernetes, so it does not depend on a healthy API server.
- Official tooling from the etcd project and documented by Kubernetes.
- Small files compared with application data backups.
Disadvantages of etcd snapshots
- All-or-nothing: restoring rewinds the whole cluster.
- Does not save volume data or cloud resources.
- Contains Secrets, so it needs strong protection.
- Cannot be taken on most managed Kubernetes services.
- Restore requires careful, practised steps.
Trade-offs to decide on purpose
- Frequency versus load. More frequent snapshots reduce data loss but add disk reads and storage cost. Tune to your RPO instead of guessing.
- Retention versus risk. Keeping snapshots longer helps with late-noticed mistakes, but it also keeps old Secrets around for longer. Balance both.
- Convenience versus isolation. A backup job inside the cluster is easy to build, but one outside the cluster still works when the cluster is down.
- Speed versus safety. Immutable, off-region copies are slower to reach and costlier, but they are the ones that survive the worst days.
20Design Patterns and Anti-patterns
Teams that recover calmly tend to follow the same few patterns. Teams that suffer tend to repeat the same few mistakes.
Patterns worth copying
The 3-2-1 rule
Keep three copies of important data, on two different kinds of storage, with one copy somewhere else entirely. It is an old idea that fits snapshots perfectly.
Layered recovery
Use Git for intended state, an object-level tool for everyday restores, volume snapshots for data, and etcd snapshots for full disaster recovery.
Snapshot before change
Make a fresh snapshot a required step in every upgrade or risky change checklist.
Immutable off-site copy
Send one copy of each snapshot to storage that nobody in the cluster’s account can alter or delete before the retention date.
Restore into a clean room
Practise restores into isolated machines. In a real disaster, restore into fresh machines too, rather than repairing damaged ones.
Runbook as code
Turn the restore steps into reviewed scripts and documents stored in version control, so they improve over time.
Anti-patterns to avoid
What it looks like
Snapshots are saved on the same disk, or the same machine, as the etcd data they protect.
Why it hurts
A disk failure, a deleted machine or a compromised node takes the data and the backups together. The backup protects against nothing that matters.
Do this instead
Copy every snapshot to remote, encrypted storage in another zone or region immediately after it is created, and verify the copy.
What it looks like
Backups run every night but nobody has ever restored one. The team assumes it works because the job is green.
Why it hurts
A green job only proves a file was written. It does not prove the file is complete, that the keys exist or that the steps work. Surprises show up during the incident.
Do this instead
Schedule regular restore drills in an isolated environment, time them, and keep the results visible.
What it looks like
“We have three etcd members, so we are backed up.”
Why it hurts
Replication copies bad changes as quickly as good ones. One wrong delete reaches every member in a blink.
Do this instead
Treat high availability and backup as two separate jobs that protect against different failures.
What it looks like
Restoring in place on a live cluster while the API server and other writers are still running.
Why it hurts
Writers fight with the rewinding data, members can disagree about identity, and you may end up with a half-restored mess that is harder to fix than the original problem.
Do this instead
Stop writers and every etcd member first, restore into a fresh data folder, and start the pieces in order.
21Best Practices and Common Mistakes
A short list of habits, and a short list of traps, collected from many real incidents.
Best practices
Automate and alert
Schedule snapshots, verify each one, upload off-site, and alert if the newest is too old.
Protect the companions
Back up the PKI folder, encryption configuration and control plane manifests, and store them apart from the snapshots.
Write the runbook before you need it
Include exact steps, who decides, who approves, and how to talk to users during recovery.
Drill regularly
Restore into an isolated environment on a calendar and record the time taken.
Watch size and disk speed
Alert on database size, disk sync latency and leader stability to avoid emergencies in the first place.
Keep versions aligned
Record the etcd version in each backup’s name or notes, and keep a matching tool version available.
Layer your protection
Combine Git, object-level backup, volume snapshots and etcd snapshots so no single failure leaves you stranded.
Common mistakes
- Pointing the snapshot tool at a load balancer. A snapshot must come from one specific member. Use the address of a single healthy member.
- Forgetting the TLS credentials. The tool fails or hangs without the right certificate authority, client certificate and key.
- Using mismatched tool versions. An old client with a new server leads to confusing errors. Match them.
- Restoring only one member of a group. Every member must be restored from the same snapshot with the same member list.
- Reusing the old data folder. The restore needs a clean folder, so set the old one aside first.
- Losing the encryption key. A snapshot with encrypted Secrets is half-useless without the key.
- Ignoring expiring certificates. Clusters built with kubeadm issue certificates that last one year by default. A forgotten renewal can bring down the control plane and make a restore harder.
- Letting the backup folder fill the node. Old local snapshots pile up until the disk is full, which damages etcd itself. Clean up after upload.
- Skipping the aftermath. The restore is not finished when the API server starts. Reconcile Secrets, cloud resources and volumes.
If a new engineer could follow your runbook alone, at night, under stress, and finish within your RTO, your plan is real.
22Real-World and Industry Examples
Major platforms bake etcd backup into their products because they have learned how much it matters.
Kubernetes and kubeadm: the reference approach
The Kubernetes project documents the snapshot-and-restore method as the standard way to protect etcd, and kubeadm clusters follow its folder layout for certificates and static Pods. Most tutorials and training courses, including certification exams, teach this exact flow.
kops on AWS: automatic backups to S3
The kops project, which builds clusters on AWS, runs a helper called etcd-manager that takes etcd backups on a regular schedule and stores them in the S3 bucket used as its state store. It also helps with restoring a cluster from those backups, which is a good example of making backups a default, not a chore.
Amazon EKS: the provider runs etcd
EKS runs the control plane, including etcd, across multiple Availability Zones for you. Customers therefore focus on their own layer: infrastructure as code for cluster creation, GitOps for workloads, and object-level backups and disk snapshots for their data and objects.
Red Hat OpenShift: a documented backup script
OpenShift provides a supported backup script that you run on a control plane node. Its documentation tells operators to back up regularly, store the result outside the cluster, and be aware that early in a cluster’s life certificates rotate, so the first useful backup comes after that rotation.
RKE2 and K3s: scheduled snapshots by default
These lightweight distributions from the SUSE Rancher family take scheduled snapshots out of the box, twice a day by default with a short retention list, and can send them to S3-compatible storage. They show how small defaults make a big difference to safety.
Velero and GitOps tools: the everyday safety net
Many companies pair Velero for object and volume backups with Argo CD or Flux for declarative workloads. This combination handles the most common problems, like deleted namespaces and cluster migrations, so the etcd snapshot is kept for the rare, truly catastrophic day.
23Frequently Asked Questions
Short answers to the questions people ask most about etcd backups.
24Summary and Key Takeaways
etcd is the memory of your cluster, and a good backup plan is the difference between a short outage and a rebuild from scratch.
You began with a simple picture, a hotel ledger, and followed it through how etcd stores data, how a snapshot is taken, how it is protected and automated, and how a restore rewinds the cluster and what must be fixed afterwards. The pattern behind everything is simple: decide how much loss and downtime you can accept, build a layered and automated plan to meet it, protect what you store, and practise until the steps feel boring.
Key Takeaways
- etcd holds the entire state of the cluster. It stores objects and settings, not your application data or container images.
- High availability is not backup. Replication protects against machine failure; snapshots protect against corruption, mistakes, attacks and total loss.
- Plan with RPO and RTO. Let them set your snapshot frequency, retention and the speed of your restore.
- Automate, verify and store off-site. Take snapshots on a schedule, check each one, copy it to encrypted remote storage and alert when backups go stale.
- Back up the companions too. Encryption keys, certificates, manifests and volume data decide whether a restore really works.
- Restore carefully and reconcile afterwards. Stop writers, restore every member from the same snapshot, then fix Secrets, cloud resources and volumes that drifted while the cluster travelled back in time.
- Practise on a schedule. A backup you have never restored is only a hope; drills turn it into a plan.