Appearance

Snapshots and storage recovery

Capture a storage recovery point, restore it to a fresh claim, and verify the recovered data.

What you will understand

  • Trace a VolumeSnapshot from a source claim through the snapshot controller and driver.
  • Explain what a snapshot captures when an application is still writing.
  • Decide whether a restored claim contains usable data based on direct verification.

Builds on: Dynamic provisioning and CSI

What a volume snapshot captures

A report service is about to change its data format. You want a copy of the disk from before the change so you can inspect the old data if needed. A VolumeSnapshot is a Kubernetes request for a point-in-time copy of volume data. It names the source PVC and a snapshot class. A snapshot controller and a compatible CSI driver arrange the copy, and a VolumeSnapshotContent object represents the snapshot in the cluster. Check that the cluster has the snapshot APIs, a controller, and a driver with snapshot support before running these examples.

A snapshot captures what the storage system can see. If the report process is halfway through writing, the volume might contain a partial result. A database may need its own backup or checkpoint procedure to recover consistently. Choose the moment to capture based on what the application guarantees, then use the scene to walk from the source claim to a ready snapshot.

What makes a snapshot ready to restore?

A snapshot request refers to a source claim. A compatible controller and driver create the recovery point, then report its availability.

  1. Choose a meaningful recovery point

    The application decides whether to checkpoint or quiesce. Storage alone cannot infer transaction completion across memory and disks.

  2. Submit the snapshot request

    VolumeSnapshot references the source PVC and a compatible class; the class identifies the driver and lifecycle policy.

  3. Create and bind the snapshot

    The controller and driver create a snapshot handle represented by SnapshotContent and bind it to the request.

  4. Check readyToUse

    Readiness confirms the snapshot operation checkpoint, while application consistency still depends on the chosen capture procedure.

A snapshot-capable CSI driver and snapshot CRDs/controller are installed; one source volume only.

Inspect YAML or commands

Observe readyToUse

kubectl get volumesnapshot app-before-change -o yaml
Explore another case

Take a snapshot at a known point

Save the example as app-before-change.yaml. Replace lab-snapshots with a real snapshot class for the PVC’s driver and verify that app-data exists in the same namespace. Before taking a test snapshot, write a known value and record its checksum. If the application has more than one volume, determine how it makes its data consistent across those volumes before treating individual snapshots as one recovery point.

apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
  name: app-before-change
spec:
  volumeSnapshotClassName: lab-snapshots
  source:
    persistentVolumeClaimName: app-data
kubectl get volumesnapshotclass
kubectl get csidrivers
kubectl apply -f app-before-change.yaml
kubectl get volumesnapshot app-before-change -o yaml
kubectl describe volumesnapshot app-before-change

Look for readyToUse and the restore size in status. That status tells you the storage system has prepared a copy you can request for a restore.

Restore to a fresh claim and verify its contents

Create the restored volume from a separate PVC. The dataSource points to the snapshot. Choose a compatible StorageClass and a request at least as large as the required restore size. Mount the fresh claim in a temporary Pod, then compare the saved checksum or run a read-only application check. Keeping the source claim untouched makes it easier to validate both copies.

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: app-restored
spec:
  storageClassName: standard  # Must be compatible with the snapshot driver.
  dataSource:
    name: app-before-change
    kind: VolumeSnapshot
    apiGroup: snapshot.storage.k8s.io
  accessModes: [ReadWriteOnce]
  resources:
    requests:
      storage: 2Gi             # At least the required restore size.

Restore a snapshot into a fresh claim

Create a separate claim from the ready snapshot, mount it in a test Pod, and verify the expected data.

  1. New PVCReference the ready snapshot
    CSI provisionerThe original claim remains available for comparison.
  2. CSI driverCreate storage from the snapshot
    Restored volumeThe new PVC binds to storage prepared from the saved copy.
  3. Verification PodMount the restored claim
    Restored filesThe app or a test process can check the recovered contents.
Follow the sequence

Create a separate claim from the ready snapshot, mount it in a test Pod, and verify the expected data.

A compatible StorageClass supports restoring the ready snapshot and the requested size is sufficient.

The persistent storage lab supplies a file-based persistence baseline. The CSI snapshot exercise requires snapshot support. You can practice the content-verification step in either environment by comparing the expected file with what the replacement or restored Pod reads.

Check what failures your backup can survive

Snapshots can share a storage system, account, or location with the source volume. Check which failures the copy survives before planning to rely on it. A bound restored claim shows that Kubernetes can supply a volume. It takes a content and application check to establish that the restore actually met the recovery goal.

Check your understanding

The restored Pod starts but the report is missing its final records. Which part of your process could account for that?

The snapshot may have been taken before the app committed the last records. Compare the expected recovery point with the application’s flush or checkpoint time. A successful mount and a ready snapshot cannot supply records that had yet to reach the captured volume.

Primary documentation

Go to the source

Reviewed 2026-10-27 · Kubernetes 1.37 · Related local exercise

Search the book

Search loads when you open it.

Keyboard shortcuts

Ctrl + K / ⌘ + K
Search the book
?
Open this guide
Tab / Shift + Tab
Move between controls
Enter / Space
Activate a focused button or disclosure
← / →
Focused visual timeline · previous or next step
Home / End
Focused visual timeline · first or last point
Esc
Close the open dialog or menu