A Backup Bundle Packs Everything One Restore Needs into a Single File
A bundle is one archive file that holds the data you back up and everything a restore needs around it. The data alone often isn't enough. An etcd snapshot without the cluster's keys gives back the API objects but none of the trust between components (see An etcd Snapshot Alone Can't Rebuild a kubeadm Control Plane, So Back Up the PKI with It). So each backup run writes all the pieces into one file, and every later step (checksum, copy, retention, restore) handles that file as a unit.
What My etcd Bundle Holds
File name: etcd-<host>-20261123T171508Z.tar.zst, about 670 KB.
| Inside | What it is | Why a restore needs it |
|---|---|---|
snapshot.db |
The etcd snapshot: every Kubernetes object at one revision (see An etcd Snapshot Rolls the Whole Cluster Back, So Restore Only When Re-Applying Can't Fix It) | It's the cluster state itself |
snapshot-status.json |
etcdutl snapshot status output: hash, revision, key count, size |
To check later what the snapshot contained, without restoring it |
etc/kubernetes/pki/ |
Cluster CA, etcd CA, ServiceAccount signing keys, component certificates (see A Certificate Authority Is the Key Everyone Trusts, So a New One Invalidates Every Certificate It Signed) | Without them, a rebuilt node trusts none of the existing nodes, kubeconfigs or pod tokens |
etc/kubernetes/manifests/ |
The static pod manifests: etcd, API server, controller manager, scheduler, kube-vip | The member name, peer URLs and flags the restore must match |
Next to each bundle sits <bundle>.sha256, its checksum (see A Checksum Proves a Copy Is Identical, Not That the Backup Restores).
Why One File Instead of a Folder of Files
- Consistency: the snapshot and the keys come from the same run. Two separate backups could pair a snapshot with keys from before a certificate change.
- One checksum: a single hash covers every piece. A missing or truncated piece changes the hash.
- One permission: the bundle is
0600, root only, because it contains the CA private keys (see Unix Permissions Grant Read, Write and Execute Separately to the Owner, the Group and Everyone Else). One file is easier to keep secret than a tree. - One unit to copy and count: "keep the newest 56" means 56 complete restore points, never 56 snapshots with some of their keys pruned.
How It's Built
tarpacks many files into one stream and keeps their paths, owners and permissions (-C /storesetc/kubernetes/pkiwithout the leading/, so extracting in/root/restoredoesn't overwrite the live files).zstdcompresses that stream. Hence.tar.zst:tar --zstd -cfwrites it,tar --zstd -xfunpacks it. The 6.7 MB snapshot shrinks to about 670 KB, because an etcd database file is mostly free pages.- Built aside, then moved into place: the script writes in a temporary
.work.XXXXXXfolder on the same filesystem and finishes withmv. A rename within one filesystem is atomic, so a half-written bundle never appears under its final name. On the NAS it copies to.<name>.partand renames for the same reason.
Naming
etcd-<host>-<UTC timestamp>.tar.zst, with the timestamp in ISO 8601 basic format (20261123T171508Z):
- Sorting by name is sorting by time, so pruning is
sort -r | tail -n +57, with no date parsing. - UTC (
Z) has no daylight-saving gaps or repeated hours, and it's the same on every machine. The node's clock reads 18:15 CET for that bundle. - The host name keeps bundles from future control planes apart.
- A
latest.tar.zstsymlink points to the newest one, for scripts likemake etcd-pull.
Where the Copies Live
The 3-2-1 rule: three copies, on two kinds of storage, one of them elsewhere.
| Copy | Place | Kept | Protects against |
|---|---|---|---|
| 1 | The control plane node's own disk | 2 days | etcd data corruption, a bad change |
| 2 | The NAS | 14 days | the node's disk dying |
| 3 | A separate machine | 3.5 days | the NAS failing |
All three are in the same house, so a fire or a burglary takes them all. The "1 off-site" part is still missing.
References
- GNU tar manual: Creating and reading compressed archives -
--zstdand the other compression options. - zstd - the compressor, its speed and ratio trade-offs.
- rename(2) - why a rename within one filesystem is atomic.
- Homelab repo,
scripts/etcd-backup.shanddocs/runbooks/etcd-backup-and-restore.md- the script that builds these bundles and the runbook. - Back Up and Restore etcd on a kubeadm Cluster - the procedure.
Review cards
Flashcard Why does the etcd backup put the snapshot and `/etc/kubernetes/pki` in one bundle instead of backing them up separately?
So every restore point has a snapshot and the keys from the same run, covered by one checksum and one permission, and pruning can never keep a snapshot while deleting its keys.
Flashcard Why does the backup script build the bundle in a temporary folder and finish with `mv`?
A rename within one filesystem is atomic, so a half-written bundle never appears under its final name, even if the job dies mid-write.
Quiz Why are bundle names stamped like `20261123T171508Z`?
- It's the only format
taraccepts - Names then sort in time order, and UTC has no daylight-saving gaps or repeats
- It matches the node's local clock
- etcd requires it to restore
ISO 8601 basic format in UTC sorts lexically in time order, so pruning needs no date parsing.