KubernetesXCVI · Workload BackupWorkload backup
PVC, PV, and snapshot relationships — what to back up and in what order
What you'll learn
- Identify the dependency graph from PVC to backup object
- Order the deletion of PVC, PV, VolumeSnapshot, and VolumeSnapshotContent correctly
- Order the restoration sequence from primitives to workloads
- Apply the operational discipline of treating restore ordering as a runbook
Prerequisites
Verified against Kubernetes 1.34.x · kubeadm 1.34.x · kubectl 1.34.x · etcd 3.6.x · CoreDNS 1.11.x · containerd 1.7.x / 2.x · 2026-08-16
A Kubernetes backup program that ignores the dependency graph between PVC, PV, VolumeSnapshot, and VolumeSnapshotContent will either fail to capture what it should or fail to clean up what it did. This lesson walks the dependency graph, the deletion order, the restore order, and the operational discipline of treating ordering as a runbook rather than a guess.
The dependency graph
flowchart LR
A[StorageClass] --> B[PV]
B --> C[PVC]
C --> D[Pod]
E[VolumeSnapshotClass] --> F[VolumeSnapshotContent]
F --> G[VolumeSnapshot]
G -->|references| C
H[Restore PVC] -->|dataSource| G
The forward dependencies:
- A
StorageClassdefines how aPVis provisioned (which CSI driver, which parameters, which reclaimPolicy). - A
PVis the cluster-scoped materialisation of a volume; thePVCclaims it. - A
PVCis mounted by aPodand provides the volume inside the container. - A
VolumeSnapshotClassdefines how aVolumeSnapshotContentis provisioned. - A
VolumeSnapshotContentis the cluster-scoped materialisation of a snapshot. - A
VolumeSnapshotreferences the sourcePVC(or anotherVolumeSnapshot) and is bound to aVolumeSnapshotContent. - A restore
PVCreferences aVolumeSnapshotviadataSourceto provision a new volume from the snapshot.
The deletion order
flowchart TD
A[1. VolumeSnapshot] --> B[2. VolumeSnapshotContent]
B --> C[3. Restore PVC]
C --> D[4. PVC]
D --> E[5. PV]
E --> F[6. StorageClass]
When tearing down a backup’s infrastructure, the order is the reverse of the dependency:
- VolumeSnapshot first. This triggers the external-snapshotter sidecar to call CSI DeleteSnapshot. The cloud-side snapshot is removed.
- VolumeSnapshotContent (if still bound). The sidecar deletes this after the CSI call returns. You rarely need to delete this manually.
- Restore PVC. Only if it was created from the snapshot and is no longer needed.
- PVC. Deleting a PVC triggers the CSI DeleteVolume on the underlying volume (if the reclaimPolicy is Delete). With Retain, the PV stays.
- PV. Only if reclaimPolicy was Delete and the PV is orphaned, or if you want to force the cleanup.
- StorageClass. Almost never deleted; it is part of the cluster’s infrastructure.
The restore order
When restoring a workload after a cluster loss, the order is the forward dependency order:
flowchart TD
A[1. CRDs] --> B[2. StorageClass and CSI driver]
B --> C[3. ConfigMaps and Secrets]
C --> D[4. VolumeSnapshot]
D --> E[5. PVC referencing VolumeSnapshot]
E --> F[6. Workloads and Services]
F --> G["7. Ingress, NetworkPolicy, RBAC"]
G --> H[8. Validate]
- CRDs first. If a workload uses a CRD (cert-manager, ingress-nginx, Argo CD), the CRD definitions must exist before any object of that kind is restored. Restoring a Certificate before the CRD exists causes the API to reject it.
- StorageClass and CSI driver. A restore PVC references a StorageClass. The CSI driver must be running and the StorageClass must be defined before the PVC can be provisioned.
- ConfigMaps and Secrets. Workloads often mount configuration. Restore the data plane config first so the workload can read its config when it starts.
- VolumeSnapshots. The cloud-side snapshots must exist (either recreated by Velero or by the restore tool) before any restore PVC can reference them.
- PVCs referencing the snapshots. The PVC’s
dataSourcepoints to the VolumeSnapshot; the CSI driver clones the snapshot into a new volume. - Workloads and Services. Once the PVCs are bound, the StatefulSet/Deployment can start and the Services can route traffic.
- Ingress, NetworkPolicy, RBAC. The routing and access controls come last so they do not block the workload from starting.
- Validate. End-to-end tests against the live workloads.
The validation cadence
The restore order is part of the runbook; the validation cadence proves it works:
| Test | Frequency | Scope |
|---|---|---|
| Single PVC restore | weekly | one PVC, one workload |
| Namespace restore | monthly | all PVCs and workloads in a namespace |
| Full cluster restore | quarterly | every workload, every PVC, every CRD |
| Cross-region restore | annually | restore to a different region from a remote backup |
Each test exercises a different scope. Skipping any one leaves a gap. The full cluster restore is the only test that exercises the complete ordering chain.
The operational failure modes
Restoration fails in production for predictable reasons:
- CRDs missing. The restore tool creates objects of a kind whose CRD does not exist. The API server rejects with “no matches for kind”.
- StorageClass missing. The restore PVC references a StorageClass that does not exist. The PVC stays Pending.
- VolumeSnapshot not found. The restore PVC’s dataSource points to a VolumeSnapshot that was not restored. The PVC stays Pending with FailedBinding.
- CSI driver not running. The PV cannot be provisioned because no driver handles the StorageClass. The PVC stays Pending.
- NetworkPolicy restored before workloads. The workload starts but cannot reach its dependencies because the NetworkPolicy has not yet been reconciled. In practice this is rare but happens when NetworkPolicies are restored before the namespaces they target.
- RBAC missing. The workload’s ServiceAccount lacks the RoleBindings. The Pod starts but cannot read ConfigMaps, Secrets, or the API server.
Quiz
Knowledge check · 4 questions
Q1. What is the correct order for restoring a workload after a cluster loss?
Q2. Deleting a PV before its VolumeSnapshot orphans the cloud-side snapshot.
Q3. A restore is in progress. The CRDs are restored, the StorageClasses are restored, but the restore PVCs stay Pending with 'FailedBinding'. Diagnosis?
The restore tool re-created the VolumeSnapshots successfully. The PVCs reference them via dataSource. But every PVC is Pending with the message 'FailedBinding: cannot find VolumeSnapshot'. The VolumeSnapshots exist; the operator's kubectl get volumesnapshot -A shows them all Ready.
Q4. Name two reasons the deletion order of PVC, PV, VolumeSnapshot, and VolumeSnapshotContent matters.
Passing score: 75%. Answers are checked in this browser.
Production discipline
The dependency graph in production rests on five non-negotiable elements:
- Document the deletion order. The runbook lists the order in which to tear down backup infrastructure, namespace by namespace.
- Document the restore order. The runbook lists the forward dependency order, with explicit pauses for reconciliation between phases.
- Validate the orders quarterly. A runbook that has never been executed is a hope. The full cluster restore test exercises both.
- Use the same tool for backup and restore. Mixing Velero for backup with hand-rolled restore scripts is a recipe for ordering bugs. The same tool that captured the data knows the order to restore it.
- Capture ordering in the tool, not in human memory. Velero’s restore order is encoded in its controller logic. Hand-rolled scripts require the operator to remember the order. The tool is more reliable than the human.
Restore ordering is part of the backup program. A backup program without an ordering runbook is a collection of objects waiting to be corrupted.