Stateful Kubernetes Backup and Restore

Stateless services on Kubernetes are easy to recover: redeploy from Git and they are back. Stateful workloads — databases, message brokers, search indexes, file stores running on persistent volumes — are different. Their value is the data, and a backup is only useful if it captures that data consistently and can be restored into a working application within your recovery objectives. Many teams discover during an incident that their nightly volume snapshots contain a database caught mid-write, that restored pods cannot find their volumes, or that nobody knows how long a restore takes.

This page covers what to back up, the difference between crash-consistent and application-consistent backups, the main tools, and how to prove restores work.

TL;DR

Quick Example

Nightly Velero backups of a namespace, including volume snapshots, kept for 30 days — and a restore drill into a different namespace:

Backup hooks make a simple file-based application consistent by freezing its filesystem during the snapshot:

Core Concepts

What to Protect

Consistency Levels

Multi-volume applications — for example a database with separate data and log volumes — need coordinated snapshots or native backups; independent snapshots may capture each volume at a different moment.

Tools

Restore Considerations

See Database Restore Drills and Recovery Targets.

Best Practices

Use Native Backups for Databases

Physical backups with log archiving give point-in-time recovery and consistency guarantees that volume snapshots cannot. Use snapshots as an additional layer, not the only one.

Store Backups Off-Cluster and Immutable

Write backups to object storage in another account or region with object lock or equivalent immutability, so a cluster compromise or accidental deletion cannot remove them. See Immutable Backups and Restore Verification.

Drill Restores on a Schedule

Restore into an isolated namespace or cluster regularly, run application checks against the restored data, and record how long it took.

Monitor Backup Health

Alert on failed or missing backups, partially failed volume snapshots, and backups older than your recovery point objective.

Common Mistakes

Snapshots of a Busy Database

Backups in the Same Blast Radius

Never Testing a Restore

FAQ

How do I back up a Kubernetes cluster?

Keep workload definitions in Git, back up cluster resources and persistent volumes with a tool such as Velero, use native backups for databases, back up etcd for self-managed clusters, and store everything off-cluster with immutability.

Are volume snapshots enough to back up a database?

Usually not on their own. Snapshots are crash-consistent and may not capture multi-volume databases consistently. Native database backups with log archiving provide reliable, point-in-time recovery; snapshots are a useful additional layer.

What does Velero back up?

Kubernetes resources from the API server, stored in object storage, and persistent volume data through CSI snapshots or file-system backups. It supports schedules, retention, hooks, and restores into different namespaces or clusters.

How do I restore to a different namespace or cluster?

With Velero, use namespace mappings on restore, or install Velero in the target cluster pointing at the same backup storage. Make sure storage classes, zones, secrets, and external dependencies are compatible.

How often should I test restores?

Regularly — at least quarterly for critical systems, and after significant platform changes. Each drill should measure restore time and verify data with application-level checks.

Related Topics

References