Chapter 5. Volume snapshots for single node OpenShift


You can take volume snapshots of persistent volumes (PVs) that are provisioned by the OpenShift Data Foundation Logical Volume Manager Operator. You can also create volume snapshots of the cloned volumes. Volume snapshots help you to:

  • Back up your application data (volume snapshots are not backups)
  • Revert to a state at which the volume snapshot was taken

You can create volume snapshots based on the available capacity of the thin pool and overprovisioning limits. The Red Hat OpenShift Data Foundation Logical Volume Manager Operator creates a VolumeSnapshotClass with the name odf-lvm-<deviceclass-name>.

Prerequisites

  • For a consistent snapshot, ensure that the PVC is in Bound state. Also, ensure that all the I/O to the PVC is stopped before taking the snapshot.

Procedure

  1. Save the following YAML to a file with a name such as odf-lvm-vol-snapshot.yaml to create a policy for volume snapshot.

    # Sample YAML to create a volume snapshot
    
    apiVersion: snapshot.storage.k8s.io/v1
    kind: VolumeSnapshot
    metadata:
        name: lvm-block-1-snap
     spec:
         volumeSnapshotClassName: odf-lvm-vg1
         source:
            persistentVolumeClaimName: lvm-block-1
    Copy to Clipboard Toggle word wrap
  2. Create the policy by running the following command:

    # oc create -f odf-lvm-vol-snapshot.yaml -ns lvm-policy-ns
    Copy to Clipboard Toggle word wrap

    A read only copy of the PVC is created as a volume snapshot.

When you restore a volume snapshot, a new Persistent Volume Claim (PVC) gets created. The restored PVC is independent of the volume snapshot and the source PVC.

Prerequisites

  • The storage class must be the same as that of the source PVC.
  • The size of the requested PVC must be the same as that of the source volume of the snapshot.

Procedure

  1. Identify the storage class name of the source PVC and volume snapshot name.
  2. Save the following YAML to a file with a name such as odf-lvm-vol-restore.yaml to restore the snapshot.

    # Sample YAML to restore a PVC.
    
    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      name: lvm-block-1-restore
    spec:
      accessModes:
     - ReadWriteOnce
      volumeMode: Block
      Resources:
        Requests:
          storage: 2Gi
      storageClassName: odf-lvm-vg1
      dataSource:
        name: lvm-block-1-snap
        kind: VolumeSnapshot
        apiGroup: snapshot.storage.k8s.io
    Copy to Clipboard Toggle word wrap
  3. Create the policy by running the following command:

    # oc create -f odf-lvm-vol-restore.yaml -ns lvm-policy-ns
    Copy to Clipboard Toggle word wrap

Procedure

  • To delete the volume snapshot, delete the volume snapshot resource.

    oc delete volumesnapshot <volume-snapshot-name> -n <namespace>
    Copy to Clipboard Toggle word wrap
    Note

    When you delete a persistent volume claim (PVC), the snapshots of the PVC are not deleted.

  • To delete the restored volume snapshot, delete the PVC that was created to restore the volume snapshot.
oc delete pvc <pvc-name> -n <namespace>
Copy to Clipboard Toggle word wrap
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2026 Red Hat
Back to top