What is Kubernetes backup?

Kubernetes backup is the protection of applications running on a Kubernetes cluster by capturing two things together: the resource definitions that describe each application and the data in its persistent volumes. The aim is to be able to recreate an application, with its data, on the same cluster or a different one.

What does a Kubernetes backup contain?

An application on Kubernetes is a set of objects stored in the cluster's API, such as deployments, services, configuration maps and secrets, plus any data held in persistent volumes. Container images are normally not backed up, because they are pulled again from a registry.

ComponentWhat it isHow it is captured
Resource definitionsObjects describing the applicationExported from the Kubernetes API
Persistent volume dataDatabases, queues, uploaded filesStorage snapshot exported, or file-level copy
Cluster state (etcd)Configuration of the whole clusterSeparate etcd snapshot, for rebuilding the cluster itself
Container imagesApplication codeKept in a registry, not usually in the backup

How does it differ from virtual machine backup?

Virtual machine backup captures a disk image of a long-lived machine. Kubernetes workloads are spread across short-lived containers that are scheduled wherever there is capacity, so there is no single disk that represents the application. Backup tools therefore work at the level of the application or namespace, select what to protect through labels, and call hooks inside containers to bring databases to a consistent state before a snapshot, the Kubernetes counterpart of application-aware backup.

Why do Kubernetes backups go to object storage?

Nearly all Kubernetes backup tools write to S3-compatible object storage. It is reachable over HTTP from any cluster, it scales without pre-allocated volumes and it sits outside the cluster, which is essential, since a backup stored on the cluster it protects is lost with it. The same store can serve several clusters, which also makes it the vehicle for moving applications between them. Where the store supports S3 Object Lock, the backups can be made immutable.

What affects sizing and recovery?

Capacity is driven by persistent volume data, its change rate and the retention schedule, not by the number of containers. Backups also produce many small objects, so the object store has to handle high object counts and frequent listing. On the recovery side, the questions are how long it takes to restore the largest stateful application and whether a full restore to a new, empty cluster has been tried. Kubernetes backup retention and S3 sizing works through the numbers.

Frequently asked questions

Is etcd backup enough to protect Kubernetes applications?

No. An etcd snapshot restores cluster configuration. It does not include the data in persistent volumes.

Are stateless applications worth backing up?

Their definitions are, unless they can be redeployed entirely from a source repository. They hold no data of their own.

Can a Kubernetes backup be restored to a different cluster?

Yes. That is a main use of it, for migration, upgrades and disaster recovery, provided storage classes and versions are compatible.