Create a Snapshot
A snapshot is the state of a Kubernetes volume at any given moment in time.
To create a snapshot of an existing cluster, follow these steps:
Once the snapshot is created, you will see it in the list of snapshots for the volume before the Volume Head.
This section demonstrates how to create, list, restore, and delete Longhorn snapshots directly via kubectl using Longhorn’s Custom Resources (CRs).
Note: Longhorn uses its own
SnapshotCRD under thelonghorn.ioAPI group (for example,v1beta2), not the generic KubernetesVolumeSnapshotfromsnapshot.storage.k8s.io.
Prepare the manifest: Create a file named longhorn-snapshot.yaml:
apiVersion: longhorn.io/v1beta2
kind: Snapshot
metadata:
name: longhorn-test-snapshot
namespace: longhorn-system
spec:
volume: pvc-840804d8-6f11-49fd-afae-54bc5be639de # replace with your actual Longhorn volume name
createSnapshot: true
Apply the manifest:
kubectl apply -f longhorn-snapshot.yaml
Expected output:
snapshot.longhorn.io/longhorn-test-snapshot created
Note: If the volume is detached, you will see a brief warning about the engine not running. Longhorn automatically retries, and the snapshot will complete once the volume is attached.
kubectl get snapshots.longhorn.io -l longhornvolume=pvc-840804d8-6f11-49fd-afae-54bc5be639de -n longhorn-system
kubectl delete snapshot.longhorn.io longhorn-test-snapshot -n longhorn-system
Expected output:
snapshot.longhorn.io "longhorn-test-snapshot" deleted
Note: Longhorn automatically handles the cleanup of the underlying data.
© 2019-2025 Longhorn Authors | Documentation Distributed under CC-BY-4.0
© 2025 The Linux Foundation. All rights reserved. The Linux Foundation has registered trademarks and uses trademarks. For a list of trademarks of The Linux Foundation, please see our Trademark Usage page.