Disaster Recovery from etcd Snapshots in Kubernetes
Every Kubernetes cluster keeps its entire memory in one small database called etcd. If that memory is lost or damaged, the cluster forgets what it was running. This guide explains how snapshots protect that memory, how to take them properly, and how to bring a cluster back to life from one when things go badly wrong.
Imagine a large library where the only complete catalog of every book, every borrower and every shelf location is kept in a single notebook in the librarian’s office. The books themselves are safe on the shelves, but if the notebook is destroyed by a flood, nobody can say which book belongs where, who borrowed what, or which rules apply. A wise library therefore photographs that notebook every hour and keeps the photographs in a different building. Kubernetes has exactly such a notebook, and etcd snapshots are the photographs.
1Why etcd Is the Heart of the Cluster
Before we talk about rescuing something, we must understand what it is and why losing it hurts so much.
Kubernetes is a system that runs applications across many computers. To do that job, it needs to remember a great deal: which applications should run, how many copies of each, which settings and secrets they use, which network rules apply, and which people may do what. All of this memory lives in a database called etcd. The word is pronounced “et-see-dee”. It is a distributed key-value store, which means it keeps pairs of names and values, and it keeps copies of them on several machines at the same time.
Every other part of Kubernetes is built so that it can be thrown away and rebuilt. The API server keeps nothing of its own. The scheduler and controllers keep only short-lived notes. The nodes can be replaced. But if etcd is lost and there is no backup, all of the desired state of the cluster is gone. The containers might still be running on the machines for a while, but nothing knows what they are for or how to manage them.
Think of a ship’s logbook. The crew, the engine and the sails can all be replaced in port, but without the logbook nobody remembers the route, the cargo or the promises made to passengers. etcd is the logbook of a Kubernetes cluster, and a snapshot is a careful copy of that logbook kept safely on land.
etcd
The database where Kubernetes stores its entire desired state. Only the API server is meant to talk to it directly.
Snapshot
A single file that holds a copy of everything in etcd at one moment in time.
Restore
The process of building a fresh etcd from a snapshot file so the cluster can remember its old state again.
Disaster recovery
The planned set of steps for bringing a system back after a serious failure, not just a small hiccup.
Backing up the machines that run your applications is not the same as backing up the cluster’s memory. If you only have one backup, make it an etcd snapshot, because almost everything else can be rebuilt from it or from your source control.
2What Is Actually Stored Inside etcd
Knowing what is in the database tells you exactly what a snapshot protects.
etcd holds every object that you can create through the Kubernetes API. This includes Deployments, StatefulSets, DaemonSets, Pods, Services, ConfigMaps, Secrets, Namespaces, roles and role bindings, custom resources, storage claims and much more. Each object is stored under a key that looks like a file path, and the value is the object itself, written in a compact format.
It also stores things that you rarely think about but that are very important. Events, leases used for leader election, the list of nodes and their reported status, and the information about which version of each resource is stored all live in etcd. Because the cluster uses it for every decision, etcd is read and written constantly.
| Kind of data | Examples | How painful is losing it |
|---|---|---|
| Workload definitions | Deployments, StatefulSets, Jobs, Pods | Applications stop being managed and cannot be recreated automatically |
| Configuration | ConfigMaps, Services, Ingresses, network policies | Applications lose their settings and routing |
| Secrets | Passwords, tokens, certificates | Applications cannot authenticate to their dependencies |
| Access control | Roles, bindings, service accounts | People and programs lose their permissions or gain wrong ones |
| Storage links | PersistentVolumes and claims | Disks may still exist but the cluster forgets which application owns which |
| Custom resources | Database clusters, certificates, policy objects | Operators lose the objects they manage |
| Cluster bookkeeping | Nodes, leases, events | Mostly rebuilt automatically, but gaps can confuse controllers |
Secrets in etcd are only encoded, not protected, unless encryption at rest has been switched on. A stolen snapshot can therefore reveal every password in the cluster. Treat every snapshot file as highly sensitive.
3What a “Disaster” Really Looks Like
Not every failure is the same size, and the right response depends on which kind you are facing.
When people say disaster, they often imagine a whole data center burning down. In practice, the situations that call for a snapshot are many and varied. Some are caused by hardware, some by software, and many by people. A good plan names these situations in advance so that nobody has to guess in the middle of the night.
Loss of quorum
In a three-member etcd cluster, two machines fail at once. The remaining member cannot make decisions alone, so the cluster stops accepting changes. This is the classic case where a snapshot restore is needed.
Loss of all control plane machines
A whole site loses power, or a cloud zone goes down, or an automation mistake deletes all control plane machines. The data disks may be gone too.
Data corruption
A disk fault or a software bug damages the database files. The cluster may refuse to start, or may give strange answers.
Human error
Someone deletes a namespace, a custom resource definition, or a large set of objects by mistake. The cluster is healthy but the data is gone, and all members have faithfully copied the deletion.
Bad upgrade or bad change
A control plane upgrade, a storage migration or a faulty operator changes data in a damaging way, and rolling back the software does not undo the data change.
Malicious activity
An attacker or ransomware encrypts or deletes data. A backup that the attacker cannot reach or alter becomes the last line of defense.
Having three copies of a document on three computers protects you if one computer breaks. It does not protect you if you accidentally delete the text and all three computers dutifully save the empty file. Replication protects against machine failure, while backups protect against everything else.
4RPO and RTO: Setting Your Goals First
Two simple numbers decide how often you back up and how much you invest in practice.
Before choosing tools, a team must decide how much loss it can accept and how much waiting it can bear. Two short terms describe this.
RPO: Recovery Point Objective
How much recent data you can afford to lose, measured in time. If your RPO is one hour, you need a good backup at least every hour.
RTO: Recovery Time Objective
How long the cluster may stay unusable before it must be working again. This decides how well rehearsed and automated your recovery must be.
When you write an important essay, RPO is how much typing you are willing to redo if the computer crashes, perhaps the last ten minutes if autosave runs every ten minutes. RTO is how long you can wait to get back to your desk and keep working after the crash.
Turning goals into decisions
A short RPO means frequent snapshots, and possibly additional tools that capture changes between snapshots. A short RTO means automation, tested runbooks, spare machines ready to use, and people who have practiced the steps. A relaxed RPO and RTO mean lower cost, but you must make sure the whole organization agrees to the consequences.
| Environment | Typical RPO | Typical RTO | What it implies |
|---|---|---|---|
| Development and test | One day | Many hours | A daily snapshot is probably enough and rebuilding from source control is acceptable |
| Internal tools | Several hours | A few hours | Snapshots every hour or two with a written runbook |
| Customer-facing production | Minutes to one hour | Under an hour | Frequent snapshots, offsite copies, rehearsed recovery and often a standby plan |
Setting goals by feeling instead of by agreement. Write the RPO and RTO down, get the business owner to approve them, and check that your backup schedule and practice schedule actually match.
5Raft and Quorum in Plain Words
To know when a snapshot restore is truly needed, you must know how etcd decides things.
etcd usually runs as a group of members, often three or five. They agree on every change using a method called Raft. In Raft, one member is the leader and the others are followers. All changes go through the leader, which sends them to the followers. A change counts as saved only when a majority of members have written it down. That majority is called the quorum.
This design means that the cluster keeps working as long as a majority is alive. With three members, the majority is two, so one failure is tolerated. With five members, the majority is three, so two failures are tolerated. Adding an even number does not help: four members still need three to agree, so four tolerate only one failure, just like three.
| Members | Majority needed | Failures tolerated |
|---|---|---|
| 1 | 1 | 0 |
| 2 | 2 | 0 |
| 3 | 2 | 1 |
| 4 | 3 | 1 |
| 5 | 3 | 2 |
| 7 | 4 | 3 |
flowchart LR
C["Client write"] --> L["Leader"]
L --> F1["Follower 1"]
L --> F2["Follower 2"]
F1 -->|"Saved"| L
F2 -->|"Saved"| L
L --> OK["Majority confirmed: write is final"]
A town council of three needs two votes to pass any rule. If one councillor is sick, the other two can still decide. If two are away, the one who remains cannot pass anything, because a single voice is not a majority, and that protects the town from a lone person making unchecked decisions.
When a majority is lost and cannot be brought back, the remaining members will not accept changes. That is when a snapshot restore, or a special forced restart, becomes the way forward.
6Not Every Failure Needs a Snapshot
Using a snapshot when it is not needed throws away recent data, so choose the lightest fix that works.
A snapshot restore takes the cluster back in time to the moment the snapshot was taken. Everything that happened afterwards is lost. That is a heavy price, so it should be a last choice. In many situations, a lighter fix is better.
One member fails, majority is alive
The cluster keeps working. Remove the broken member from the group, prepare a fresh machine, and add a new member. It copies the data from the others automatically. No snapshot is needed.
A member is only slow or restarted
Check disks, network and memory first. A member that has fallen behind will usually catch up by itself once the problem is fixed.
Majority lost but disks are intact
If the machines can be repaired or reattached with their data, bring them back and quorum returns without any restore.
Only one healthy copy remains and others cannot return
You can sometimes restart that single member as a new one-member cluster using a special flag, then grow it again. This keeps the latest data but must be done carefully.
No healthy data, or the data itself is wrong
This is when a snapshot restore is the right tool. You accept going back to the snapshot time in return for a working, consistent cluster.
Restoring from a snapshot at the first sign of trouble. Always check the health and member list of the existing cluster first. A restore that was not needed turns a small incident into a large data loss.
7What a Snapshot Is and How It Works
A snapshot is a simple idea with a few important details.
An etcd snapshot is a single file that contains the full contents of the etcd database at a particular moment. The file is taken from one member through the normal etcd client connection. etcd keeps a version number for every change, called a revision, and a snapshot captures everything up to a certain revision. Because it is a point-in-time copy, it gives a consistent picture of the whole cluster state, with no half-written objects.
The tool for taking one is the command line client etcdctl, with a snapshot save command. The tool for inspecting and restoring one is etcdutl. In older releases, these functions were part of etcdctl, and you may see that in older guides. In newer releases, the offline operations on files were moved to etcdutl.
sequenceDiagram
participant Op as Operator or Job
participant E as etcd member
participant S as Snapshot file
participant R as Remote storage
Op->>E: Request snapshot over TLS
E-->>Op: Stream database contents at one revision
Op->>S: Write file to disk
Op->>S: Verify file status and hash
Op->>R: Copy file to safe offsite storage
Why snapshots are consistent
etcd uses a storage engine that keeps older versions of data for a short time. When a snapshot is requested, etcd reads from a stable view of the database, so the cluster can keep running and accepting changes while the copy is made. The cluster does not need to be stopped. The only cost is a little extra disk and network use while the file is streamed.
Taking a snapshot is like taking a photograph of a busy street. People keep moving, but the picture shows exactly where everyone was at the instant the shutter clicked, with nobody half in and half out of the frame.
Copying the raw database files from the data folder while etcd is running is not a safe backup method. The files may be caught in the middle of a write. Use the snapshot feature instead.
8What a Snapshot Does Not Contain
Many recovery plans fail because people expect a snapshot to hold more than it does.
A snapshot holds the state of the Kubernetes objects. It does not hold everything needed to rebuild a cluster from nothing. A complete disaster recovery plan must also protect the missing pieces.
| Not in the snapshot | Why it matters | How to protect it |
|---|---|---|
| Control plane certificates and keys | The API server and etcd need them to trust each other. The service account signing key is also kept here. | Back up the certificate folder separately and keep it secure |
| Encryption configuration and keys | Without the key, encrypted Secrets in a restored cluster cannot be read | Store the key in a safe place that is separate from the snapshot |
| Application data on disks | Databases and file stores keep their data on volumes, not in etcd | Use volume snapshots, database backups or storage replication |
| Container images | Nodes pull images from registries after the restore | Make sure registries are themselves backed up and reachable |
| Node machines and operating systems | The snapshot does not recreate computers | Use infrastructure as code to rebuild machines |
| External resources | Cloud load balancers, DNS entries and disks live outside the cluster | Document them and keep their definitions in code |
| Control plane configuration files | API server flags and static Pod definitions are files on the machines | Keep copies in source control or in your backup set |
A photograph of the library’s catalog tells you where every book should be, but it does not contain the books, the keys to the building or the staff. To reopen the library you need the catalog, the keys, the books and the people, and each needs its own plan.
A restored cluster whose application volumes are lost will happily recreate Pods that find empty disks. The cluster looks healthy while the data is gone. Always plan data protection for volumes together with etcd backups.
9Taking a Snapshot: The Steps and Prerequisites
The process is short, but each part needs to be right for the file to be useful when you most need it.
Taking a snapshot needs only a few ingredients. You need the etcd client tool, the address of a healthy member, and the credentials to talk to it. etcd normally requires mutual TLS, so you provide the certificate authority file, a client certificate and a client key. On a cluster built with kubeadm, these files are usually under the control plane’s certificate folder, in a subfolder for etcd.
Choose a healthy member
Check the health and member list first. Take the snapshot from a member that is up to date, and talk to one member address at a time so you know exactly which copy you are reading.
Connect with proper credentials
Provide the endpoint, the certificate authority, the client certificate and the client key so the secure connection succeeds.
Save the snapshot to a file
Use the snapshot save feature and give the file a name that includes the date, time and cluster name so that you can tell backups apart later.
Check the file
Read back its status. It reports a hash, the revision, the number of keys and the size. A file that cannot be read back is not a backup.
Move it off the machine
Copy it to storage that lives somewhere else, and only then count it as a real backup.
Take snapshots from a follower rather than the leader when you can. Streaming a large database puts some extra load on the member, and the leader already has the most work to do.
Asking for a snapshot from a load balancer address that spreads requests over several members. Always connect to a specific member, otherwise you cannot be sure which member produced the file.
10Verifying That a Snapshot Is Good
A backup that has never been checked is only a hope.
Verification happens in layers, and each layer catches a different kind of problem. The cheapest layer is checking the file’s status. The status report shows the hash of the content, the revision at which it was taken, the total number of keys and the file size. A file that is empty, too small, or that fails to read has clearly gone wrong.
The next layer is comparing numbers over time. If your snapshots are normally around a certain size and one suddenly shrinks to a tiny fraction of that, something is wrong, perhaps with the cluster itself. If the key count falls sharply, someone may have deleted a lot of objects, and you will want to know before older backups expire.
The strongest layer is a real test: restore the file into a temporary, isolated etcd on a scratch machine, and then read a few known objects back. This proves that the file can actually be restored, which is the only thing that truly matters.
Status check
Read the hash, revision, key count and size from the file right after it is made.
Trend check
Compare size and key count against earlier snapshots to spot sudden drops or jumps.
Transfer check
After copying to remote storage, compare checksums so you know the stored copy matches the original.
Restore test
Periodically restore into a scratch environment and look at real objects. This is the true proof.
A fire extinguisher that has never been tested may be empty. A backup that has never been restored may be empty too. The only way to learn the truth is to try using it while the situation is calm.
11Automating Backups: Schedules and Retention
People forget and machines do not, so snapshots should be taken by a scheduled job rather than by hand.
A manual backup done once a month is very unlikely to satisfy any serious RPO. The job should be automated and should run on a regular schedule that fits your goals. There are several common ways to run it. A Kubernetes CronJob can be pinned to a control plane node, given access to the etcd certificates, and set to run on a schedule. Alternatively, a timer on the control plane operating system can run a script. Some teams use backup operators or tools provided by their distribution.
Advantages of a CronJob
- Lives inside the cluster and is easy to see and manage
- Failures show up as failed Jobs with logs
- Configuration is stored as ordinary objects
Disadvantages / Trade-offs
- If the cluster is down, the job that would back it up is down too
- Needs access to sensitive certificates
- Must be pinned to control plane nodes to reach the files
How often and how long to keep
Frequency should follow your RPO. Many teams take a snapshot every thirty minutes to one hour for production. Retention should follow a layered approach: keep many recent snapshots, fewer older ones and a small number of very old ones. The recent ones help when you need to undo a mistake from this morning. The older ones help when a slow corruption went unnoticed for days.
| Age of backup | Example schedule kept | Why |
|---|---|---|
| Last 24 hours | Every hour | Fine-grained recovery from recent mistakes |
| Last week | One or two per day | Recovery from problems noticed the next day |
| Last month | One per week | Recovery from slow or unnoticed problems |
| Last year | One per month | Audit and compliance needs |
A backup job that fails silently for weeks. Always alert when no new successful snapshot has appeared within the expected time. The absence of a backup is the most dangerous thing a backup system can hide.
12Storing Backups Safely
A snapshot kept next to the thing it protects is a snapshot that will be lost in the same disaster.
The place where you store snapshots matters as much as the snapshots themselves. A snapshot that sits on the same disk as etcd will vanish when that disk fails. A snapshot on the same machine will vanish when the machine is lost. A snapshot in the same cloud account may be reachable by an attacker who has already taken over that account.
Keep copies offsite
Store at least one copy in a different location, such as another zone, region or provider, so one event cannot destroy both.
Make them hard to delete
Use storage features that block deletion or overwriting for a period, so that a mistake or an attacker cannot remove all copies quickly.
Encrypt them
Encrypt files at rest and in transit, because a snapshot may contain every secret in the cluster.
Limit who can read them
Give read access to very few people and log all access. Treat the bucket like a vault.
Separate the credentials
The cluster’s own credentials should be able to add new backups but not delete old ones.
Know where they are
Write down the location and the way to reach it in a place that survives a cluster outage, not only inside the cluster.
Keeping a spare house key under the doormat of the same house is useful against losing your keys, but it does nothing if the house burns down, and it helps a burglar. A spare key with a trusted neighbor in a different street, locked in a box, works far better.
Apply the idea of three copies, on two kinds of storage, with one copy offsite. It is an old and reliable rule that suits Kubernetes backups very well.
13Encryption at Rest and the Key You Must Not Lose
A snapshot can be perfect and still be unusable if one small piece of configuration is missing.
Kubernetes can encrypt chosen resources, usually Secrets, before the API server writes them into etcd. This is called encryption at rest. It is a very good practice, because it means a stolen snapshot or a stolen disk does not directly reveal passwords and tokens. But it creates a dependency that is easy to forget. The snapshot contains encrypted data. The keys that unlock it are not inside etcd. They live in the API server’s encryption configuration, or in an external key management service.
If the cluster is rebuilt from a snapshot but the key is gone, the API server will not be able to read the encrypted Secrets. Applications that depend on them will fail, and no amount of restoring will fix that. The key and the snapshot are like a lock and its key: each is useless without the other.
Imagine locking your valuables in a safe and then storing the safe in a warehouse for protection. If you lose the only key, the warehouse is perfectly safe and also completely useless. The encryption key is that key, and the snapshot is the safe.
Keys in a local configuration file
The file lives on the control plane machines. Back it up securely and separately from the snapshots, and keep it out of the same storage location.
Keys in an external key service
The cluster asks a managed key service to unwrap its data keys. Make sure the key service itself is protected and that your restored cluster will be allowed to reach it.
Old keys after rotation
When keys are rotated, older snapshots may still need the older key. Keep retired keys as long as you keep the snapshots that need them.
Storing the encryption key in the same bucket as the snapshots. Anyone who can read the bucket then holds both the lock and the key, and the protection is gone.
14Quorum Loss: The Classic Disaster
When most of the members are gone, the survivors will not make decisions, and that is by design.
Suppose a cluster has three etcd members and two of them are lost. The survivor knows it is alone and it knows that a majority is two. It will refuse to accept writes because it cannot be sure that the other two are not alive, working and accepting different writes on the other side of a broken network. This refusal is what protects the data from split-brain, where two halves of the cluster make conflicting decisions.
To the outside world, the symptoms look dramatic. The API server answers slowly, or times out, or returns errors about the storage backend. Existing Pods keep running on the nodes, because the kubelets do not need the control plane to keep containers alive. But no new Pods can be scheduled, no changes can be applied, and the cluster cannot heal itself.
flowchart TD
S["Cluster stops accepting changes"] --> Q1{"Can failed members return with their data?"}
Q1 -->|Yes| A["Repair machines and restart them. Quorum returns."]
Q1 -->|No| Q2{"Is at least one healthy member with recent data left?"}
Q2 -->|Yes| B["Consider restarting it as a new single member, then add others"]
Q2 -->|No| C["Restore every member from the latest good snapshot"]
B --> D["Verify and grow the cluster again"]
C --> D
The two real options when members are gone for good
If one healthy copy remains and it holds recent data, there is a special start option that makes a member forget its old peers and start a fresh one-member cluster from its own data. This keeps the most recent state and is often the fastest path. It should be used with care, and only when you are certain that the other members will not return, because bringing back an old member later could cause confusion. If no healthy copy remains, the snapshot is the only way forward.
Before any dramatic step, take a copy of whatever data is left on the survivors. Even a damaged data folder may help later, and copying it costs almost nothing compared with losing it.
15The Big Picture of a Restore
Before diving into the details, here is the whole journey in one view.
Restoring a cluster from a snapshot is a sequence of careful stages. It is not a single command. The reason is that etcd, the API server and the other components all hold assumptions about each other, and those assumptions must be reset in the right order.
Decide and gather
Confirm that a restore is truly needed. Find the right snapshot, the certificates, the encryption key and the configuration files.
Stop the writers
Stop every API server so nothing can talk to etcd while you work. Stop the old etcd members as well.
Restore the data
On each etcd member, build a new data folder from the same snapshot file, giving each member its identity and the list of peers.
Start etcd
Point each member at its new data folder and start them. Check that they find each other and elect a leader.
Start the control plane
Bring back the API servers, then restart the controller manager, the scheduler and the kubelets so they discard stale information.
Verify and reconcile
Check health, nodes, workloads, storage and secrets. Deal with anything that changed after the snapshot time.
Restoring only one member and starting it alongside the old, un-restored members. The members will have different histories, and they will either refuse to cooperate or, worse, mix up their data.
16Preparing for the Restore
Time spent preparing here saves hours later, and prevents making things worse.
Gather what you need
Place everything you need on the control plane machines before you start. This includes the snapshot file, the certificates for etcd, the encryption configuration, the manifests or service definitions for etcd and the API server, and the tools, meaning a recent enough etcd utility that matches your etcd version. Check the snapshot file’s status and checksum again, so you know the file is intact and was not damaged during transfer.
Freeze the cluster
On a cluster built with kubeadm, the control plane components run as static Pods, defined by files in a folder on each control plane machine. The kubelet watches that folder. Moving the API server and etcd definition files out of the folder makes the kubelet stop those Pods. This is the clean way to stop them. Make sure nobody and nothing else, such as automation or a deployment pipeline, is trying to change the cluster while you work.
Snapshot is chosen and verified
You know its time, its hash and the reason it is the right one to use.
Keys and certificates are present
The etcd certificates, the cluster certificates and the encryption key are available on each machine.
Tool versions match
The etcd tool you use should match the version of etcd you are running, to avoid format surprises.
Old data is kept safe
Rename and keep the old data folder rather than deleting it, so you can go back if something goes wrong.
People are informed
Teams that deploy to the cluster know it is frozen, and one person leads the restore while another keeps notes.
Writers are stopped
Every API server is stopped, and automation tools that write to the cluster are paused.
Assign roles during a recovery: one person types the commands, another reads the steps aloud and checks each one, and a third records times and results. Mistakes are far more common when one tired person does everything.
17Restoring the Snapshot into a New Data Folder
The restore does not repair the old database. It builds a brand-new one from the snapshot.
The restore operation reads the snapshot file and writes a fresh data folder. The folder must not already exist, so the tool never overwrites old data by accident. During the restore, the tool checks the file’s integrity hash, unless you tell it to skip that check, which you only do when the snapshot was copied directly from a data folder instead of being taken by the snapshot feature.
A new identity for the cluster
The most important thing about a restore is that it gives the cluster a new identity. The restored data is stamped with a fresh cluster identifier and new member identifiers. Because of this, old members that were not restored cannot accidentally rejoin and bring old history with them. They will be treated as strangers.
For this to work, each member needs to be told, at restore time, three things: its own name, its own peer address, and the full list of members with their peer addresses. A shared token that identifies this new cluster is also supplied. Every member must receive the same list and the same token, and each must have its own name and address.
| Information given at restore | Purpose | Rule |
|---|---|---|
| Snapshot file | The data to restore | The same file for every member |
| New data folder | Where the restored database is written | Must not exist already, and must be on a fast, reliable disk |
| Member name | Identifies this member within the group | Unique for each member |
| Peer address of this member | How other members reach it | Unique for each member, matches the certificates |
| List of all members and peers | Defines the new group | Identical on every member |
| Cluster token | Names the new cluster | Identical on every member, and different from the old one |
When a club is re-founded from old records, it receives a new membership number and a new charter, so that the old, scattered club cards from before the collapse do not cause confusion. Everyone who joins the new club receives the same copy of the member list.
Some newer versions of the restore tool can move the database’s revision counter forward after a restore. This helps programs that cache data from the API server, because they never see the revision numbers go backwards. Check the documentation for the version you run.
18Restoring a Multi-Member Cluster
With several members, the same steps are repeated on each machine, and consistency is everything.
In a cluster with three or five members, every member is restored from the same snapshot file, each into its own new data folder, with its own name and address but with the same list of members and the same cluster token. When all are restored, you start them together. They find each other using the list you gave them, elect a leader, and form a working cluster that starts from the snapshot’s data.
flowchart LR
F["Same snapshot file"] --> M1["Member 1: new data folder"]
F --> M2["Member 2: new data folder"]
F --> M3["Member 3: new data folder"]
M1 --> C["New cluster with new identity"]
M2 --> C
M3 --> C
An alternative: restore one, then grow
Some teams prefer a slower but simpler approach. They restore a single member as a one-member cluster, start it, confirm that the data looks right, and then add the other members one by one as fresh, empty members that copy the data from the first. This reduces the chance of a configuration mistake in the member list, and it lets you test the restored data before scaling out. It takes longer, which matters if your recovery time goal is tight.
Restoring all members at once
- Faster to reach full redundancy
- All members begin with identical data
- Works well when steps are scripted and rehearsed
Restoring one and growing
- Lets you inspect the data before adding more members
- Lower risk of a typing mistake in the member list
- Slower, and you run with no redundancy for a while
Mixing certificates and addresses. Each member’s certificate must match the address you give for it. A mismatch makes members reject each other, and the error messages are often confusing.
19Bringing the Control Plane Back (kubeadm Clusters)
On a typical kubeadm cluster, etcd and the API server are static Pods, and the details of that matter.
On a kubeadm cluster with the usual layout, the definition of the etcd Pod includes a mounted folder where etcd keeps its data. After a restore into a new folder, you must edit that definition so that it points to the new folder. The kubelet notices that the file changed and recreates the etcd Pod using the restored data. You also need to make sure the member name, the peer address, and the member list in the definition match what you used during the restore, because etcd reads them at start.
Stop the Pods
Move the API server and etcd definition files out of the manifests folder. Wait until the containers are really gone.
Restore to a new folder
Run the restore on each member. Keep the old data folder aside under a new name instead of deleting it.
Edit the etcd definition
Change the data folder to the restored one and check the cluster settings, such as the member name and the cluster token.
Return the etcd definition
Put the etcd file back in the manifests folder. The kubelet starts etcd. Check that members connect and a leader is elected.
Return the API server definition
Once etcd is healthy, put the API server file back. It reconnects to etcd and begins to serve the restored data.
Restart the other components
Restart the controller manager, the scheduler and the kubelets so that they drop anything they had remembered from before the restore.
Keep a copy of the original manifests and of the edited ones side by side. If a typo causes a startup problem, a quick comparison finds it faster than staring at a single file.
Other kinds of clusters differ in the details. Clusters where etcd runs as a system service use the service definition rather than a static Pod file. Clusters using external etcd have a separate set of machines for the database, so the restore happens there, and the API servers are then pointed at it. The ideas are the same in each case: stop the writers, restore, start etcd, then start the API servers.
20After the Restore: Living with Time Travel
The cluster now believes it is the moment of the snapshot, but the world has moved on.
The restored cluster remembers the past correctly, but the real world did not rewind. Containers kept running on nodes. Cloud disks were created and deleted. Customers kept using your applications. The difference between what etcd now believes and what is really true is the main challenge after a restore.
Newer objects are gone
Anything created after the snapshot, such as new Deployments, Secrets or ConfigMaps, is missing. Teams must re-apply recent changes from source control.
Deleted objects return
Anything deleted after the snapshot reappears, including old versions of applications or configuration that someone had removed on purpose.
Pods that no longer exist are stopped
The kubelet compares its running containers with what the API server says should run. Containers for Pods that the restored cluster knows nothing about are stopped.
Storage can be out of step
Volumes created after the snapshot exist in the storage system but not in the cluster. Volumes the cluster remembers may have been removed from storage.
Clients may be confused
Programs that cached data or remembered a position in the change stream may see numbers that go backwards. Restarting them clears the confusion.
Nodes re-register
Nodes that joined after the snapshot usually register again by themselves if their certificates are still valid. Nodes that left may linger in the list until removed.
Imagine a hotel that restores its booking system from last night’s copy. It forgets this morning’s check-ins, and it re-lists guests who already left. The front desk then walks the corridors and compares the rooms with the list, fixing each difference by hand. After a restore, controllers and operators do this walk for the cluster.
Automated controllers act on what they see, so a restored cluster may quickly start recreating Pods and attaching volumes. Check the state of critical stateful applications quickly, and consider pausing risky automation until you have looked around.
21The Post-Restore Validation Checklist
Work through the same list every time, so nothing is forgotten when people are tired.
| Area | What to check | What a good answer looks like |
|---|---|---|
| etcd members | Member list and health on every endpoint | All members present, one leader, no errors |
| API server | Health endpoints and a simple read | Fast responses with no storage errors in the logs |
| Nodes | Node list and status | All expected nodes are Ready, stale ones are identified |
| System Pods | DNS, networking and controller components | Running and not restarting repeatedly |
| Workloads | Deployments, StatefulSets and Jobs | Desired and ready counts match |
| Storage | Volume claims and their volumes | Bound, with matching disks in the storage system |
| Secrets | Reading a few known Secrets | Readable, which proves the encryption key works |
| Access control | A few known users and service accounts | Permissions match what is expected |
| Custom resources | Operators and their objects | Operators are running and objects are consistent |
| End users | A real request through the front door | Applications answer correctly |
Record the gap
Write down the time of the snapshot and the time of the failure. That window is the data you lost. Share it with the application teams so they know exactly which changes to re-apply and which data to check. A clear statement of the gap helps people repair their own areas much faster than a general warning.
Keep your application manifests in source control with a pipeline that can re-apply them. After a restore, re-running the pipeline brings back recent changes in minutes instead of hours.
22Partial Recovery: Pulling a Few Objects from a Snapshot
When the cluster is healthy and only some objects were lost, restoring everything is far too heavy.
Suppose a person deletes one namespace by mistake. The rest of the cluster is fine and has changed a lot since last night’s snapshot. If you restore the whole snapshot, you lose all of those changes just to bring back one namespace. A much better approach exists: restore the snapshot into a separate, temporary etcd that is not connected to your real cluster, read the objects you need from it, and re-create them in the live cluster.
Prepare a scratch machine
Use a separate computer or a throwaway virtual machine, completely isolated from the production network.
Restore the snapshot there
Build a one-member etcd from the snapshot file and start it on the scratch machine.
Find the objects
Either read the keys directly from this etcd, or attach a temporary API server to it so you can use the normal tools to list and export the objects.
Clean the exported objects
Remove fields that belong to the old cluster, such as unique identifiers, version numbers, status and owner references that point to objects that no longer exist.
Apply them to the live cluster
Create the objects in the right order: namespaces first, then configuration, then storage claims, then workloads.
If you spill coffee on one page of a notebook, you do not throw away the whole notebook and use last month’s copy. You find the old copy, read the lost page, and write it again in the current notebook.
Connecting the scratch etcd to the real network, or letting it use the same certificates and addresses as production. Keep it isolated so that it can never be mistaken for a member of the real cluster.
23Worked Example One: Two of Three Control Plane Nodes Lost
A story that follows the whole process from alarm to normal operation.
A company runs a production cluster with three control plane machines in three zones. One night, a mistake in an infrastructure script deletes two of the three machines along with their disks. The survivor is still running but the cluster has lost quorum. Alerts fire because the API server is timing out. Applications continue to serve traffic, but nobody can deploy anything and autoscaling has stopped.
sequenceDiagram
participant Ops as On-call engineer
participant Store as Offsite storage
participant N1 as Surviving node
participant N2 as New node 2
participant N3 as New node 3
Ops->>Ops: Confirm quorum is lost and disks are gone
Ops->>Store: Fetch latest verified snapshot
Ops->>N1: Stop API server and etcd
Ops->>N2: Build machine and copy certificates and snapshot
Ops->>N3: Build machine and copy certificates and snapshot
Ops->>N1: Restore snapshot into new data folder
Ops->>N2: Restore snapshot into new data folder
Ops->>N3: Restore snapshot into new data folder
Ops->>N1: Start etcd then API server
Ops->>N2: Start etcd then API server
Ops->>N3: Start etcd then API server
Ops->>Ops: Restart controllers and kubelets then validate
Assess
The engineer checks the member list and sees only one member responding. The disks of the other two are confirmed lost, so those members cannot return.
Choose the path
The surviving member holds data, and the team considers the single-member restart option. But that node’s disk shows errors from the incident, so they choose the safer snapshot restore.
Rebuild machines and gather files
Two new control plane machines are created from code. The certificates, encryption key and the verified snapshot from forty minutes earlier are copied to all three machines.
Restore and start
Each member is restored from the same snapshot with its own name and address and the shared member list. etcd is started first, a leader is elected, and then the API servers start.
Reconcile
The team restarts the other components and tells application owners that changes made in the last forty minutes must be re-applied. The pipeline re-applies them within the hour.
The result: about forty minutes of changes were lost, but running applications never stopped serving traffic. The team writes down what went well and what was slow, and they fix the script that deleted the machines. They also add a stronger approval step for deleting control plane machines.
24Worked Example Two: An Accidentally Deleted Namespace
This time the cluster is perfectly healthy, which makes the full restore the wrong tool.
At eleven in the morning, an engineer meant to clean up a test namespace and deleted the namespace of a payments service instead. The cluster accepted the request. All the Deployments, Services, ConfigMaps, Secrets and volume claims in that namespace began to disappear. Every etcd member faithfully copied the deletion.
Step 1: Stop the damage
The team first checks whether the deletion is still in progress. If some objects are only waiting on finalizers, they may be saved. They pause any automation that could make things worse, and they check the reclaim policy of the storage volumes, because volumes set to delete will be removed along with their claims.
Step 2: Pick the right snapshot
The latest snapshot was taken at ten o’clock, one hour before the mistake. It contains the whole namespace. A full restore would erase all other teams’ changes from the last hour, which is unacceptable for a mistake that affects only one namespace.
Step 3: Use a scratch etcd
The team restores the ten o’clock snapshot into an isolated etcd and reads out the payments namespace objects, cleaning the fields that belong to the old cluster.
Step 4: Recreate in the live cluster
They create the namespace, then configuration and Secrets, then volume claims, and finally the Deployments. The workloads start up again with the settings they had at ten o’clock.
Step 5: Deal with the data
The payment database’s volume had a delete reclaim policy, and the disk was gone. Recreating the claim gives an empty disk. The team restores the data from the most recent volume snapshot and database backup, which is why those backups matter just as much as etcd snapshots.
An etcd snapshot restores definitions, not the contents of disks. Without volume snapshots or database backups, a perfect restore of the namespace would still leave the payments service with an empty database.
Use role-based access control to limit who can delete namespaces, set a retain policy on volumes that hold important data, and add a confirmation step for destructive actions in production.
25Other Layers of Protection: Managed Clusters, Velero and GitOps
etcd snapshots are one layer of a good plan, and they work best alongside other layers.
A single backup method rarely covers every need. A strong disaster recovery plan uses several layers, each covering weaknesses of the others. It is useful to know the main ones and what each does well.
| Layer | What it protects | Strength | Weakness |
|---|---|---|---|
| etcd snapshots | The whole cluster state at one moment | Complete, simple, fast to take | Restoring is all-or-nothing and needs direct access to the control plane |
| GitOps or source control | Desired state of applications as files | Easy to re-apply and review, great for rebuilding | Does not hold data created by hand, Secrets are often kept elsewhere |
| Resource-level backup tools such as Velero | Selected objects and volume snapshots | Can restore single namespaces and move between clusters | Depends on the API server working, and needs setup for each volume type |
| Volume snapshots and database backups | Application data on disks | Protects the data that etcd never holds | Needs application-aware care to be consistent |
| Infrastructure as code | Machines, networks and cloud settings | Rebuilds the foundation quickly and repeatably | Needs discipline so that code matches reality |
| Standby cluster in another region | The whole service | Shortest recovery time | Highest cost and the hardest to keep in step |
Managed Kubernetes services
On managed services from cloud providers, the provider runs the control plane and etcd for you. You usually cannot reach etcd directly, so you cannot take your own etcd snapshots. The provider takes care of the durability of the control plane and often has its own backup practices, but those are not a promise that they can bring back an object you deleted by mistake. For that reason, teams on managed services rely more on source control, resource-level backup tools and volume snapshots. Read your provider’s documentation carefully to learn what they do and do not restore.
Renting an apartment means the landlord looks after the building’s pipes and walls, but you still keep your own insurance for your belongings. In a managed cluster the provider keeps the control plane running, but protecting your objects and data is still your job.
Make it a habit to ask, for every kind of failure, which layer would bring it back and how long that would take. If a failure has no answer, you have found a gap in your plan before the gap finds you.
26etcd Health and Capacity: Keeping Snapshots Small and Reliable
A healthy database is easier to back up and much easier to restore.
The size of your snapshot depends directly on the size of the etcd database, and the health of the database affects how quickly you can recover. There are a few ideas that every operator should understand.
The space quota
etcd has a limit on the size of its database, set by a quota. If the database grows past the quota, etcd raises an alarm and stops accepting writes, except for deletions, until the problem is fixed. The cluster becomes effectively read-only, which looks like an outage. The default limit is a couple of gigabytes, and the project recommends keeping the database comfortably below a fairly small upper bound, because very large databases are slow to snapshot, to restore and to sync to new members.
Compaction and defragmentation
etcd keeps old versions of every key so that clients can watch for changes. If old versions are never removed, the database grows without end. Compaction removes versions older than a chosen point. The Kubernetes API server runs compaction on a regular basis by itself. But compaction only marks space as free inside the file. The file on disk stays large until defragmentation rewrites it into a smaller one. Defragmentation of a member briefly blocks it, so it is done one member at a time, and not on the leader first.
Quota
The maximum database size. Passing it causes a write-blocking alarm, so watch the size well before it gets close.
Compaction
Throws away old versions of keys. It is done automatically by the API server on a short cycle.
Defragmentation
Shrinks the file on disk after compaction. Do it member by member during quiet periods.
Object hygiene
Large numbers of Events, Jobs, ConfigMaps or custom resources are the usual cause of growth. Clean them up regularly.
Think of a notebook where you never erase, you only cross out old lines. Compaction is deciding which crossed-out lines nobody will ever read again. Defragmentation is copying the useful pages into a fresh, thinner notebook so that it fits in your bag.
Raising the quota without finding out why the database grew. A larger limit only postpones the alarm. A runaway controller that creates thousands of objects will fill any quota you set.
Run etcd on fast local solid-state disks. Slow disks cause slow writes, leader changes and sometimes failed snapshots, and they slow every restore as well.
27Monitoring and Alerting for Backups and etcd
You want to hear about a problem when it is small, not when you need the backup.
Monitoring for disaster recovery has two jobs. The first is to watch the health of etcd, so that you catch trouble early. The second is to watch the backup system itself, so that you know a good backup exists at all times.
| What to watch | Typical signal | Why it matters |
|---|---|---|
| Time since last good snapshot | Age of the newest verified file in remote storage | The most important backup alert. If it grows beyond your RPO, you are exposed |
| Snapshot size and key count | Compare to recent history | Sudden drops hint at mass deletion or a broken job |
| Backup job status | Failed or missing runs | Catches a silent failure early |
| Leader presence | Whether a leader exists | No leader means no writes |
| Leader changes | Number of elections over time | Frequent elections point to slow disks or network trouble |
| Disk speed | Time taken to sync the log and commit data | Slow disks are the most common cause of etcd instability |
| Database size | Size compared to the quota | Warns before the write-blocking alarm |
| Failed proposals | Count of rejected changes | Indicates quorum or leadership problems |
| Certificate expiry | Days until etcd and control plane certificates expire | An expired certificate can look just like a disaster |
Alerts that deserve a human
Not every number needs to wake someone up. A good rule is to page a person when the age of the newest good backup exceeds the target, when quorum is at risk, or when the database is close to its quota. Other signals can create tickets or dashboard warnings.
Check the backup age from outside the cluster, using the backup storage itself as the source of truth. If you ask the cluster whether its backups are fine, and the cluster is the thing that is broken, you will not get an honest answer.
28Security of Snapshots and the Recovery Process
A snapshot is a copy of everything, so it deserves the same protection as everything.
Anyone who can read a snapshot, and who has the encryption key if one is used, can read every Secret, every service account setup and every configuration in the cluster. Anyone who can write a snapshot into your recovery process could plant a poisoned cluster state during a restore. Both risks must be handled.
Protect access to etcd
Only the API servers and the backup job should be able to connect, using mutual TLS. No other tool or person should have routine access.
Encrypt backups
Encrypt files in storage and while they travel, and keep the keys in a different place from the files.
Restrict and log access
Keep the list of people who can read or restore snapshots very short, and record every access.
Use immutable storage
Turn on features that prevent deletion or change for a time, which protects against ransomware and mistakes.
Verify before trusting
Check hashes and the source of a snapshot before you restore from it, especially if it came from another person or place.
Rotate secrets after a restore
If a snapshot may have been exposed, change the Secrets inside it. A restore from an exposed snapshot returns the exposed values too.
A bank vault keeps its master list of safe-deposit boxes in a locked room that few people may enter, and keeps a sealed copy at another branch. The copy is just as sensitive as the original, so it is locked, logged and guarded in the same way.
Sending snapshots by email or placing them in a shared folder “just for this restore”. Temporary shortcuts have a habit of becoming permanent exposure. Use the same protected path every time.
29Anti-Patterns to Avoid
These mistakes appear again and again in real incidents, and each has a simple cure.
Problem
Taking snapshots but never testing a restore.
Why It’s Harmful
The first real test happens during an emergency. Missing certificates, a wrong tool version or a corrupted file are discovered when time is most precious.
Correct Approach
Restore into a scratch environment on a regular schedule, read real objects from it, and treat a failed test as an incident.
Problem
Keeping snapshots only on the control plane machines.
Why It’s Harmful
The failure that destroys the machines destroys the backups too. This is exactly the situation in which the backups are needed.
Correct Approach
Copy every snapshot to separate, protected storage in another location right after it is created.
Problem
Forgetting to back up the certificates and the encryption key.
Why It’s Harmful
A restored cluster cannot trust its own components, and encrypted Secrets cannot be read. The snapshot is then of little use.
Correct Approach
Back up the certificate folder and the encryption configuration separately, with strong protection and a documented location.
Problem
Restoring while an API server is still running.
Why It’s Harmful
The API server may write into a half-restored database or keep stale information in memory, which produces mixed and confusing state.
Correct Approach
Stop every API server first, restore all etcd members, start etcd, then start the API servers and restart the other components.
Problem
Believing that three etcd members are a backup.
Why It’s Harmful
Members copy changes to each other immediately, including mistakes and deletions. Replication protects against machine failure, not against bad data.
Correct Approach
Use replication for availability and snapshots for recovery, and understand that they solve different problems.
Problem
Ignoring application data and relying on etcd snapshots alone.
Why It’s Harmful
A restored cluster brings back definitions but not the contents of volumes, so databases may come back empty.
Correct Approach
Plan volume snapshots and database-level backups together with etcd backups, and test them as a set.
30Runbooks, Drills and the Trade-Offs of Snapshots
Technology gets you the file, but practice gets you the recovery.
The best backup system in the world does not help a team that has never practiced. A written runbook is a step-by-step guide for each kind of failure. It should be short, tested and stored somewhere that does not depend on the cluster being alive. A drill, sometimes called a game day, is a planned practice where the team follows the runbook on a test cluster and measures how long each step takes.
Write the runbook
Describe each scenario, how to recognize it, the exact steps and who may approve a restore. Include where every file and key can be found.
Rehearse on a copy
Build a test cluster that resembles production and practice the restore from a real snapshot. Time every stage.
Compare with your goals
Check whether the measured recovery time meets the RTO and whether the snapshot interval meets the RPO.
Fix what was slow or unclear
Automate repeated steps, clarify confusing instructions and add missing items to the checklist.
Repeat regularly and after big changes
Repeat the drill on a schedule and after upgrades, changes of storage, new regions or changes of team.
Advantages of etcd snapshots
- Capture the whole cluster state in one simple file
- Can be taken while the cluster keeps running
- Small compared with application data
- Supported by the etcd project itself
- Allow full rebuilds and partial extraction
Disadvantages / Trade-offs
- Only as fresh as the last snapshot, so some data is always lost
- Restoring is all-or-nothing for the live cluster
- Do not hold application data, certificates or encryption keys
- Contain sensitive data and need careful protection
- Need direct access to etcd, which managed services usually hide
After each drill and each real incident, hold a short review without blame. The aim is to improve the system and the runbook, not to find someone to criticize.
31Troubleshooting Backups and Restores
Most problems fall into a handful of patterns, each with an obvious first check.
| Symptom | Likely cause | What to check first |
|---|---|---|
| Snapshot command fails to connect | Wrong endpoint or missing credentials | Confirm the member address and the certificate authority, client certificate and key files |
| Connection works but is rejected | Client certificate not trusted or expired | Check certificate dates and which authority signed them |
| Snapshot file is tiny or empty | Job ran against the wrong target or was cut off | Check job logs and compare with earlier file sizes |
| Restore says the folder already exists | Restore never overwrites existing data | Choose a new folder and keep the old one aside |
| Restore reports a hash problem | File was damaged or came from a data folder copy | Verify the transfer checksum and use an earlier snapshot if needed |
| Members refuse to join each other | Different tokens, lists or mismatched certificates | Compare the member list and token on every machine |
| etcd starts but API server fails | API server cannot reach etcd or has stale flags | Check endpoints, certificates and the API server logs |
| Secrets cannot be read after restore | Encryption key is missing or wrong | Check the encryption configuration and key service access |
| Controllers behave strangely afterward | Components still hold stale information | Restart controller manager, scheduler and kubelets |
| Writes fail with a space alarm | Database exceeded its quota | Compact, defragment, then clear the alarm and find the source of growth |
A calm way to investigate
Start by writing down exactly what you see, including error messages and times. Check one layer at a time, from the network to certificates, to etcd members, to the API server, to the controllers. Resist the temptation to change many things at once, because then you will not know which change helped. If you are unsure, stop and keep the old data folders so that you can return to a known state.
Deleting the old data folders to “start clean”. If the restore later turns out to be wrong, the old data may have been your better source. Keep it until the new cluster has been validated and used for a while.
32Real-World Situations Where Snapshots Save the Day
The same technique shows up in many kinds of organizations, for different reasons.
An online retailer after a zone outage
A cloud zone fails during a sales event and takes two control plane machines with it. The team rebuilds the control plane in healthy zones from a recent snapshot, while the shop keeps serving customers from the running nodes.
A software company after a bad migration
A storage version migration of a custom resource damages thousands of objects. Rolling back the software does not fix the data. A snapshot taken before the migration lets the team recover the objects they need.
A bank with strict audit rules
Regulators require proof that the platform can be recovered. The bank keeps immutable, encrypted snapshots in a second region and records the results of quarterly restore drills as evidence.
A start-up that deleted a namespace
A tired engineer deletes the wrong namespace. The team restores the previous snapshot to a scratch environment, pulls out the namespace objects and recreates them, avoiding a full restore.
An organization hit by ransomware
Attackers encrypt the data on the control plane disks. Because snapshots were stored in locked, write-once storage, the team rebuilds clean machines and restores a snapshot taken before the attack, then rotates every secret.
A platform team moving clusters
A team needs to move to new hardware. They use a snapshot to create the new cluster with the same objects, then switch traffic over after testing, using the snapshot as a migration tool as well as a safety net.
33Recovery in Different Cluster Layouts
The same snapshot idea works everywhere, but the practical steps change with the shape of the cluster.
Not all Kubernetes clusters are built the same way. Some run etcd on the same machines as the API server. Some run etcd on its own separate machines. Some are tiny single-machine clusters for testing, and some are spread across several regions. Knowing your layout before disaster strikes tells you which steps in the runbook apply to you.
Stacked etcd: the common kubeadm layout
In a stacked layout, each control plane machine runs an API server and also an etcd member. This is simple to set up and uses fewer machines. The downside is that the two are tied together: if you lose a machine, you lose both an API server and an etcd member at the same moment. Recovery steps involve the same machines for both parts, and static Pod files on each machine control both.
External etcd: a separate database tier
In an external layout, etcd runs on its own dedicated machines, and the API servers connect to it across the network. This costs more machines but separates the failure of an API server from the failure of the database. During recovery, you restore etcd on its own machines first, check it is healthy, and then point the API servers at it. This separation makes it easier to rehearse and to reason about, because there are fewer moving parts on each machine.
Stacked etcd
- Fewer machines to buy and look after
- Simple to set up with common tools
- Good fit for small and medium clusters
Disadvantages of stacked etcd
- Losing one machine loses both an API server and a database member
- Heavy API load can compete with etcd for the same resources
- Recovery touches many components on the same machine
External etcd
- Database and API servers fail independently
- Disks and memory can be tuned just for etcd
- Restore can be done and tested on the database tier alone
Disadvantages of external etcd
- More machines, more certificates and more networking to manage
- One more tier to monitor, patch and secure
- Mistakes in addresses between tiers are easy to make
| Layout | Where the snapshot is taken | Where the restore happens | Special care |
|---|---|---|---|
| Stacked, three control plane nodes | From one member on a control plane node | On every control plane node | Stop and start both the API server and etcd static Pods on each node |
| External etcd tier | From one member on the etcd machines | On every etcd machine, then reconnect the API servers | Check that API server endpoints and certificates still match |
| Single control plane node | From the only member | On that node or on a replacement node | No redundancy, so the snapshot is your only protection |
| Multi-region with standby | From the primary region | In the standby region when the primary is lost | Keep certificates, keys and addresses ready for the standby site |
Single-node clusters
Small clusters used for learning, testing or edge sites often have one control plane machine and one etcd member. There is no quorum protection at all, because there is only one voice. If that machine’s disk is lost, the cluster is gone. For these clusters, a regular snapshot sent to another place is not just a nice extra, it is the only protection that exists. Restoring is simpler, since there is only one member, but the cost of forgetting backups is total.
Standby clusters in another region
For services that cannot tolerate long outages, some organizations keep a second cluster in another region, prepared in advance. Snapshots, certificates and keys are copied there regularly. If the primary region is lost, the team restores the latest snapshot into the standby, redirects traffic and carries on. This gives the shortest recovery time, but it is expensive and needs constant care to keep the two sides in step, including the application data that lives outside etcd.
A family keeps one spare house key under the flowerpot, which is cheap and quick but risky. A bigger family may keep a spare key with a neighbor, another with a relative in another city, and a copy in a bank box. The more important the house, the more spread out the spare keys should be.
Copying a runbook from a different kind of cluster without adjusting it. Steps that fit a stacked layout can be wrong for an external one, and the difference often only appears when you are in the middle of an incident.
Keep a short diagram of your cluster layout next to the runbook, showing which machines run which components and where each certificate lives. A clear picture speeds up every decision during recovery.
34Snapshots Around Upgrades and Big Changes
Many disasters begin as planned changes, so the safest time to take a snapshot is right before one.
Upgrades of Kubernetes and of etcd are among the riskiest routine tasks. Newer versions may change how data is stored, add new fields, or migrate objects from one stored version to another. Once that happens, rolling the software back may not undo the data change. A snapshot taken just before the change gives you a clean way back, even if the software cannot go backward by itself.
Check health first
Confirm that all etcd members are healthy, that a leader exists and that nothing is already failing. Never begin an upgrade on an unhealthy cluster.
Take a fresh snapshot
Make a new snapshot immediately before the change, verify it and copy it to offsite storage. Do not rely on the one from this morning.
Save the configuration
Copy the control plane manifests, certificates and encryption configuration, so you know exactly what the cluster looked like before.
Upgrade one step at a time
Move through one control plane node at a time, checking health after each. Follow the supported order and version steps and do not skip versions.
Verify and keep the snapshot
When everything is healthy, keep the pre-upgrade snapshot for a good while, because some problems only show up days later.
flowchart LR
H["Healthy cluster"] --> S["Pre-change snapshot"]
S --> U["Upgrade or big change"]
U --> Q{"Problems?"}
Q -->|No| K["Keep snapshot for some time"]
Q -->|"Yes, fixable"| F["Fix forward"]
Q -->|"Yes, severe"| R["Restore from pre-change snapshot"]
Matching versions
The tool that restores a snapshot should be compatible with the version of etcd that wrote it. Using a very different version of the tool can lead to surprises. It is also wise to restore using an etcd version that is the same as, or a supported neighbor of, the one the snapshot came from. Keep note of which Kubernetes and etcd versions were running when each snapshot was made, for example in the file name or in a small text file stored next to it. That note can save a lot of guessing months later.
Other big changes
Upgrades are not the only risky operations. A bulk deletion of old objects, a change of the encryption setup, the installation of a new operator that rewrites custom resources, a storage migration or the replacement of control plane machines all deserve a snapshot first. A good habit is to make taking a snapshot the first line of every change checklist for production.
Control plane upgrades
Take and verify a snapshot, and keep it until the new version has run safely for a while.
Encryption changes
When rotating or changing keys, snapshot first and keep both old and new keys until you are sure of the result.
Bulk cleanups
Before deleting many objects, snapshot, so a wrong filter does not become a permanent loss.
Operator or CRD changes
New versions of operators can rewrite their objects. A snapshot lets you undo a bad rewrite.
Before a mountaineer crosses a risky ridge, the team leaves a marked camp behind with food and supplies. If the crossing goes badly, they know where to return. A pre-change snapshot is that camp, and it is cheap to build compared with the trouble it can prevent.
Assuming that you can always downgrade the software to undo an upgrade. Data formats and stored versions may have changed, so going back can be unsupported or unsafe. The snapshot is what gives you a real return path.
Practice the upgrade and the rollback on a non-production copy built from a real snapshot. This tests both your upgrade steps and your backups in a single exercise.
35Building Your Own Recovery Plan, Step by Step
All the ideas in this guide come together in one short document that your team can actually use.
Knowing the theory is useful, but when an incident begins, people need a plan they can follow without thinking too hard. A recovery plan turns everything above into a small set of decisions, owners and steps. You can build one in an afternoon and improve it over time. The pieces below are a good order to work in.
Step one: list what you must protect
Start with a plain inventory. Write down every cluster, what it is used for, who owns it and how important it is. For each one, write down which data lives in etcd, which lives on volumes, and which lives outside the cluster altogether, such as in managed databases or object storage. This list quickly shows which clusters need the strongest protection and which can be rebuilt from code with little loss.
Step two: agree on goals
For each cluster, agree on the recovery point goal and the recovery time goal with the people who depend on it. Write them next to the inventory. These two numbers drive almost every other choice, from how often to snapshot to how much to spend on a standby site.
Step three: choose the layers
Decide which layers of protection each cluster gets. Some may need only etcd snapshots and source control. Others may need volume snapshots, database backups, immutable offsite copies and a standby cluster. Write down who is responsible for each layer, because a layer that belongs to everyone usually belongs to no one.
Step four: automate and monitor
Set up scheduled snapshots, automatic copies to remote storage, automatic checks of the files, and alerts when anything is late or missing. Make the system loud when it fails and quiet when it works.
Step five: write the runbooks
Write short runbooks for the main situations: one member lost, quorum lost, whole control plane lost, data corrupted, and a single namespace deleted. Each should say how to recognize the situation, who decides, and the exact steps. Keep them in a place that does not depend on the cluster being up.
Step six: practice and improve
Schedule drills, measure the results against your goals, and fix what you find. Review each real incident the same way. Over time, the plan becomes shorter, clearer and more reliable.
| Role during an incident | Main job | Why it helps |
|---|---|---|
| Incident lead | Makes decisions, decides when to restore, talks to management | One clear voice prevents confusion and conflicting actions |
| Operator | Runs the commands on the machines | Keeps hands on the keyboard focused on the technical work |
| Reviewer | Reads each step aloud and checks it against the runbook | Catches typing mistakes before they cause damage |
| Scribe | Records times, commands and results | Creates the record needed for the review afterward |
| Communicator | Updates teams and customers | Frees the others from interruptions and keeps people informed |
Inventory and goals
Which clusters exist, who owns them, and what recovery point and recovery time each one needs.
Location sheet
Where snapshots, certificates, keys and tools are kept, and who may open them.
Runbooks
Step-by-step guides for each failure situation, tested in drills and stored outside the cluster.
Contact list
Who to call for storage, networking, security, application owners and management, with backups for each person.
Drill log
Dates and results of past practice runs, with the measured recovery times and the fixes that followed.
Review notes
Short, blame-free summaries of real incidents with the changes that came out of them.
A final readiness check
Once the plan exists, test it with a few blunt questions. Ask each of them out loud, and be honest about the answers. If any answer is “I am not sure”, that is the next item on your work list.
Can we find the newest snapshot in under five minutes?
If people must search through several buckets and folders, the first minutes of a real incident will be wasted. The location sheet should lead straight to the newest verified file.
Do we hold every key needed to read it?
Check that the certificates, the encryption configuration and any key service access are available outside the cluster, and that the people who can reach them are available at night and on holidays.
Has someone restored it recently?
A restore done within the last few months, with the date written in the drill log, is worth far more than a hundred snapshots that were never opened.
Do application owners know what they must re-apply?
Teams should know that changes made after the snapshot time will be gone, and they should know where their manifests and data backups live so that they can repair their own areas quickly.
Would we notice if backups stopped tonight?
An alert on the age of the newest good snapshot answers this. If nothing would tell you, the system is relying on luck, and luck is not a recovery strategy.
Does the plan survive the loss of its author?
A runbook that only one person understands is a single point of failure. Ask a colleague who did not write it to follow it during a drill, and note every place where they hesitate or ask a question.
Is the recovery budget realistic?
Rebuilding machines, copying large files and restoring volumes all take real time. Compare the measured duration of each step in your last drill with your recovery time goal, and decide honestly whether the goal or the plan must change.
A ship’s captain keeps a clear emergency plan that says who goes to which lifeboat, where the flares are and who gives the orders. Nobody reads it for the first time while the ship is sinking, because the crew has practiced it many times. A recovery plan does the same job for a cluster.
Keep a printed or offline copy of the location sheet and the main runbook. If the cluster, the network and the wiki are all down, the paper copy is still readable.
Writing a perfect plan once and never looking at it again. People change jobs, machines are replaced and versions move forward. A plan that is not reviewed at least twice a year slowly becomes a story about a cluster that no longer exists.
36Frequently Asked Questions
Short answers to questions that beginners often ask.
No. A snapshot is taken from a running member and gives a consistent picture of a single moment. The cluster keeps working while it is made, with only a small extra load on that member.
Often enough to meet your recovery point goal. Many production teams take one every thirty minutes to one hour. Less critical clusters may be fine with one a day.
Not necessarily. Containers on the nodes usually keep running while the control plane is down. But nothing can be changed or scaled, and after the restore the kubelets may stop Pods that the restored state does not know about.
No. It holds Kubernetes objects only. Data on volumes needs its own backups, such as volume snapshots or database backups.
They are not stored in etcd. Without the certificates the control plane components cannot trust each other, and without the encryption key the encrypted Secrets cannot be read after a restore.
Yes. A restore builds a new etcd with a new identity, and you can place it on new machines as long as addresses, certificates and configuration are set up consistently.
A snapshot is made by etcd itself and is consistent and verifiable. Copying files from a running member may capture them in the middle of a write and produce a file that cannot be trusted.
Yes. Restore the snapshot into a separate scratch etcd, read the objects you need, clean the fields that belong to the old cluster, and create them in the live cluster.
They protect against the loss of one machine. They do not protect against mistakes, corruption or the loss of several machines, because every member copies every change. Snapshots cover those cases.
Usually not, because the provider hides etcd. In that case, rely on source control, resource-level backup tools and volume snapshots, and read the provider’s documentation about what they restore.
Check the file’s status right away, compare its size with earlier ones, verify the copy in remote storage, and most importantly, restore it to a scratch environment on a regular schedule.
Stay calm and check the health and member list of etcd. Many problems can be solved by replacing one member or repairing a machine, without any restore at all.
37Summary and Key Takeaways
etcd is the memory of a Kubernetes cluster. If it is lost or damaged, the cluster forgets what it was running. Replication across members protects against the failure of a machine, but only snapshots protect against corruption, mistakes and the loss of a majority of members. A good plan sets recovery goals first, takes snapshots automatically from a healthy member, verifies them, stores them safely in another place, and keeps the certificates and encryption key alongside, but apart from, the files. When disaster comes, the team chooses the lightest fix that works, stops the writers, restores every member from the same snapshot into a new data folder, starts etcd and then the control plane, restarts the other components, and validates the result carefully. Regular drills turn all of this from a hopeful idea into a dependable skill.
Key Takeaways
- etcd holds the cluster’s memory — losing it means losing the desired state of everything, even while containers keep running.
- Replication is not backup — members copy mistakes and deletions instantly, so you need snapshots to go back in time.
- Choose the lightest fix — replace a failed member or repair machines when quorum can return, and use a snapshot only when the data is truly lost or wrong.
- Back up the missing pieces — snapshots do not hold certificates, encryption keys, application volumes or machine configuration.
- Store safely and verify — keep encrypted, immutable copies offsite, check every file, and prove restores work by testing them.
- Restore as a group — stop all API servers, restore every member from the same snapshot into new data folders, start etcd, then the control plane, and restart the other components.
- Practice makes recovery calm — set RPO and RTO, write runbooks, run drills, and measure so that the real day feels familiar.