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>.
5.1. Creating volume snapshots in single node openshift Copy linkLink copied to clipboard!
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
Save the following YAML to a file with a name such as
odf-lvm-vol-snapshot.yamlto create a policy for volume snapshot.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the policy by running the following command:
oc create -f odf-lvm-vol-snapshot.yaml -ns lvm-policy-ns
# oc create -f odf-lvm-vol-snapshot.yaml -ns lvm-policy-nsCopy to Clipboard Copied! Toggle word wrap Toggle overflow A read only copy of the PVC is created as a volume snapshot.
5.2. Restoring volume snapshots in single node openshift Copy linkLink copied to clipboard!
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
- Identify the storage class name of the source PVC and volume snapshot name.
Save the following YAML to a file with a name such as
odf-lvm-vol-restore.yamlto restore the snapshot.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the policy by running the following command:
oc create -f odf-lvm-vol-restore.yaml -ns lvm-policy-ns
# oc create -f odf-lvm-vol-restore.yaml -ns lvm-policy-nsCopy to Clipboard Copied! Toggle word wrap Toggle overflow
5.3. Deleting volume snapshots in single node openshift Copy linkLink copied to clipboard!
Procedure
To delete the volume snapshot, delete the volume snapshot resource.
oc delete volumesnapshot <volume-snapshot-name> -n <namespace>
oc delete volumesnapshot <volume-snapshot-name> -n <namespace>Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteWhen 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>
oc delete pvc <pvc-name> -n <namespace>