etcd Backup and Restore in Kubernetes

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.

Everyday Analogy

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"]
    
Figure 1: Everything goes through the API server, and only the API server touches etcd.

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.

i
Remember This

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.

Inside

Workload objects

Deployments, StatefulSets, DaemonSets, Jobs and Pods. These describe what should be running.

Inside

Configuration

ConfigMaps, Secrets, Services and Ingress rules that tell applications how to behave and how to be reached.

Inside

Access rules

Roles, bindings and service accounts. Without these, nobody can log in or do anything.

Inside

Extensions

Custom Resource Definitions and every custom resource made from them, which operators depend on.

Outside

Container images

These live in registries and on node disks, not in etcd.

Outside

Volume data

Your databases, uploaded files and anything on persistent disks. etcd stores only the record that a volume exists.

Everyday Analogy

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.

1
Component allowed to talk to etcd directly: the API server
2 GiB
Default storage size limit of an etcd database
~8 GiB
Practical upper size suggested by the etcd project
!
Not a Full Disaster Plan

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.

Everyday Analogy

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
    
Figure 2: A write is confirmed only after a majority of members have saved it.

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.

i
Why This Matters for Backups

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.

Everyday Analogy

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 wrongDoes replication help?What you need
One member machine diesYes, the others carry onReplace the member; no restore needed
A minority of members lostYes, quorum remainsReplace members one by one
A majority of members lostNo, writes stopRestore from a snapshot
All members lost, for example a whole zone or site outageNoRestore from an off-site snapshot
Disk corruption or a software bugMaybe notA clean earlier snapshot
Human error, such as deleting a namespaceNo, it replicates the deletionA recent snapshot taken before the mistake
Bad upgrade or migrationNoA snapshot taken just before the change
Malicious attack or ransomwareNoA 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.

!
A Costly Mix-up

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.

Everyday Analogy

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.

1

List what you must recover

Write down which clusters matter, which are production, and which could simply be rebuilt from code.

2

Set RPO and RTO per cluster

Agree on numbers with the business owners, not just the platform team. Different clusters can have different goals.

3

Pick frequency and retention

Choose a schedule that meets the RPO, and a retention ladder that covers late-noticed mistakes.

4

Choose where copies live

At least one copy must live outside the cluster, outside the machine and ideally outside the region.

5

Write and rehearse the restore steps

An untested restore plan is only a hope. Schedule practice runs and time them against the RTO.

i
Always Snapshot Before Change

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.

Everyday Analogy

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 etcdctl that 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.

!
A Common Trap

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.

Everyday Analogy

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.

Protect

Versioning

Keeps old copies when a file is overwritten or deleted, so one wrong command cannot erase your history.

Protect

Encryption with KMS

Encrypts every file with a key you control. Snapshots contain Secrets, so this is not optional for production.

Protect

Object Lock

Makes files unchangeable for a set time, which defends against attackers and accidents that try to delete backups.

Spread

Cross-region replication

Copies files to another region automatically, so a regional outage cannot take both the cluster and the backup.

Tidy

Lifecycle rules

Moves old files to cheaper storage and deletes them after the retention period you chose.

Limit

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.

i
A Simple Rule

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"]
    
Figure 3: A backup pipeline that checks, copies and reports at every step.

Common ways to schedule it

Kubernetes

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.

Node level

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.

Platform

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.

Enterprise

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.

Everyday Analogy

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.

i
Alert on Silence

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?”

SituationBest action
One member is down; the others are healthyReplace that member; do not restore
Quorum is intact but a member has a corrupt diskRemove it and add a fresh member
Quorum is lost and cannot be recoveredRestore the cluster from a snapshot
All members are goneRestore into new machines from an off-site snapshot
A namespace or a few objects were deletedPrefer an object-level restore tool or Git; use a snapshot only if nothing else is possible
Data is wrong but the cluster is upPick the last snapshot taken before the problem

The pre-restore checklist

1

Confirm the real problem

Check member health and quorum before you decide. A network problem can look like a data loss and fix itself.

2

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.

3

Stop writers

Pause anything that writes to the cluster: automation, deployment pipelines and operators. Tell the team the cluster is in recovery.

4

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.

5

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.

6

Gather the companions

Have the certificates, encryption configuration and control plane manifests at hand before you begin.

Everyday Analogy

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"]
    
Figure 4: The restore flow, from stopping writers to verifying workloads.
1

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.

2

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.

3

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.

4

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.

5

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.

6

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.

7

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.

8

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.

!
Do Not Skip the Full Member List

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.

i
If the Copy Came From a Raw File

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.

Everyday Analogy

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

1

Control plane returns

The API server starts, reads the restored state, and controllers begin to reconcile.

2

Nodes report in

Kubelets reconnect, refresh their heartbeats and compare running containers to the restored list of Pods.

3

Workloads converge

Missing Pods are recreated and unwanted ones are stopped, until the actual state matches the restored desired state.

4

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.

Everyday Analogy

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.

Do

Keep manifests in Git

Apply them with GitOps tools so the cluster can be rebuilt from code at any time.

Do

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.

Do

Snapshot your volumes

Use cloud disk snapshots for stateful data, scheduled and retained like your other backups.

Do

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.

i
Plan Rebuild, Not Restore

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.

Network

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.

Identity

Mutual TLS everywhere

Both clients and members should prove who they are with certificates. Keep the etcd certificate authority separate from other uses.

Data

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.

Storage

Encrypted backup storage

Encrypt snapshot files in storage with a managed key, and restrict who can use that key.

Access

Separate roles

The backup job needs write access only. A small, audited group should hold the right to read snapshots or run a restore.

Integrity

Immutable copies

Use write-once storage settings for at least one copy so that an attacker, or a tired operator, cannot erase your history.

Everyday Analogy

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.

!
Restores Are Powerful

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.

Everyday Analogy

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.

TopicWhy it matters for backup and restoreWhat to do
Database sizeBigger databases mean bigger snapshots, slower uploads and longer restoresKeep objects small; clean up unused objects; watch growth
DefragmentationBlocks a member while it runs and reclaims spaceDo one member at a time, off-peak, followers before the leader
ChurnVery frequent updates, for example constant status writes or many short-lived objects, grow history fastReduce needless updates; review noisy operators
Snapshot timingStreaming a large file reads the disk heavilySnapshot from a follower; avoid the busiest times when possible
Restore timeDepends on file size and disk speedTime 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.

MembersQuorumFailures tolerated
110, no protection at all
321
431
532
743

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
    
Figure 5: Stacked and external etcd topologies.
Everyday Analogy

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.

!
Remove the Dead Member First

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

Health

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.

Health

Leader changes

The counter etcd_server_leader_changes_seen_total rising often points to unstable networks or overloaded disks.

Disk

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.

Size

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.

Writes

Failed proposals

The counter etcd_server_proposals_failed_total grows when writes cannot reach agreement, often during leader trouble.

Network

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.
Everyday Analogy

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.

Everyday Analogy

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.

1

Pick a recent production snapshot

Fetch it from the real backup storage, using the real permissions, so the access path gets tested too.

2

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.

3

Follow the written runbook exactly

Do not use memory. If the runbook is wrong or unclear, fix it right away. Start a timer.

4

Check the results

Confirm the API server starts, key namespaces and Secrets exist, custom resources are present, and a sample workload runs.

5

Compare to your RTO

Record how long each step took. If the total is longer than your RTO, simplify, automate or practise more.

6

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.
i
Make It Routine

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.

MethodBest atNot good at
etcd snapshotWhole-cluster disaster recovery; exact state of every objectRestoring one namespace; saving volume data; managed clusters
Object-level backup toolNamespace restores, migrations, cloud and managed clustersReplacing the control plane’s internal state exactly
GitOps repositoryRebuilding intended workloads, audit historyCapturing runtime-created objects, Secrets and status
Volume snapshotsProtecting application data on disksProtecting cluster definitions
Infrastructure as codeRecreating clusters, networks and nodes quicklyAnything 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.
A backup plan is not one tool. It is a small set of tools that cover each other’s blind spots.

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

Pattern

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.

Pattern

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.

Pattern

Snapshot before change

Make a fresh snapshot a required step in every upgrade or risky change checklist.

Pattern

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.

Pattern

Restore into a clean room

Practise restores into isolated machines. In a real disaster, restore into fresh machines too, rather than repairing damaged ones.

Pattern

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

ANTI-PATTERN 01Avoid
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.

ANTI-PATTERN 02Avoid
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.

ANTI-PATTERN 03Avoid
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.

ANTI-PATTERN 04Avoid
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

1

Automate and alert

Schedule snapshots, verify each one, upload off-site, and alert if the newest is too old.

2

Protect the companions

Back up the PKI folder, encryption configuration and control plane manifests, and store them apart from the snapshots.

3

Write the runbook before you need it

Include exact steps, who decides, who approves, and how to talk to users during recovery.

4

Drill regularly

Restore into an isolated environment on a calendar and record the time taken.

5

Watch size and disk speed

Alert on database size, disk sync latency and leader stability to avoid emergencies in the first place.

6

Keep versions aligned

Record the etcd version in each backup’s name or notes, and keep a matching tool version available.

7

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.
i
A One-Line Test

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.

Q1Does taking a snapshot stop or slow my cluster?
It does not stop anything. It reads from the disk of one member, so there is some extra load, which is usually small. Taking it from a follower and outside peak hours keeps it gentle.
Q2How often should I back up etcd?
As often as your RPO demands. Many production clusters use every fifteen to thirty minutes, and everyone should take one right before any upgrade or risky change.
Q3Do I need to snapshot every member?
No. A snapshot from one healthy member represents the whole cluster at that moment. Taking it from more than one member just creates near-duplicates.
Q4Does a snapshot include my application data?
No. It includes the Kubernetes objects that describe your applications and volumes. The data on the volumes needs its own backup.
Q5Can I restore a snapshot into a different cluster or new machines?
Yes. That is the normal disaster recovery path. Restore builds a new cluster identity from the file. Take care that the new cluster has matching certificates, encryption keys and network settings.
Q6Can I restore just one namespace from an etcd snapshot?
Not directly. A snapshot restores the whole cluster state. For single namespaces, use an object-level backup tool or your Git history, or restore the snapshot into a scratch cluster and export the needed objects from there.
Q7What happens to running Pods during a restore?
Containers on nodes usually keep running while the control plane is down. After the restore, kubelets compare them with the restored state and stop or start containers to match it.
Q8What if I lose the encryption key for Secrets?
Secrets stored encrypted in the snapshot cannot be read, and the API server may fail to start or return errors for them. This is why the key must be backed up separately and carefully.
Q9Is it safe to store snapshots in a public cloud bucket?
Yes, if the bucket is private, encrypted, versioned and tightly controlled. Snapshots contain Secrets, so access must be restricted and logged.
Q10My etcd says the database space is exceeded. What now?
The quota alarm has fired and the cluster is read-only. Compact old revisions, defragment the members one at a time, then clear the alarm. Afterwards, find what caused the growth, and add monitoring so you hear about it earlier next time.
Q11How is a snapshot different from copying the data folder?
A snapshot is produced through etcd, so it is consistent and carries an integrity hash. A file copy can catch the database in the middle of a change and lacks that safety check.
Q12Do I still need etcd backups if I use GitOps?
GitOps lets you rebuild intended workloads, but it does not capture everything: runtime-created objects, Secrets created by hand, custom resource status and recent changes. Many teams use both.

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.