Backing up a volume snapshot

Snapshots of data from applications running on a MicroShift node are created as read-only logical volumes (LVs) located on the same devices as the original data. You must manually mount local volumes before they can be copied as persistent volumes (PVs) and used as backup copies. To use a snapshot of a MicroShift storage volume as a backup, find it on the local host and then move it to a secure location.

Prerequisites
  • You have root access to the host machine.

  • You have an existing volume snapshot.

Procedure
  1. Get the name of the volume snapshot by running the following command:

    $ oc get volumesnapshot -n <namespace> <snapshot_name> -o 'jsonpath={.status.volumeSnapshotContentName}'
    • Replace <namespace> and <snapshot_name> with the namespace and snapshot name you used.

  2. Get the unique identity of the volume created on the storage backend by using the following command and inserting the name retrieved in the previous step:

    $ oc get volumesnapshotcontent snapcontent-<retrieved_volume_identity> -o 'jsonpath={.status.snapshotHandle}'
    • Replace <retrieved_volume_identity> with the volume identity.

  3. Display the snapshots by using the unique identity of the volume you retrieved in the previous step to determine which one you want to backup by running the following command:

    $ sudo lvdisplay <retrieved_volume_identity>
    • Replace <retrieved_volume_identity> with the volume identity.

      Example output
      --- Logical volume ---
      LV Path                /dev/rhel/732e45ff-f220-49ce-859e-87ccca26b14c
      LV Name                732e45ff-f220-49ce-859e-87ccca26b14c
      VG Name                rhel
      LV UUID                6Ojwc0-YTfp-nKJ3-F9FO-PvMR-Ic7b-LzNGSx
      LV Write Access        read only
      LV Creation host, time rhel-92.lab.local, 2023-08-07 14:45:26 -0500
      LV Pool name           thinpool
      LV Thin origin name    a2d2dcdc-747e-4572-8c83-56cd873d3b07
      LV Status              available
      # open                 0
      LV Size                1.00 GiB
      Mapped size            1.04%
      Current LE             256
      Segments               1
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     256
      Block device           253:11
  4. Create a directory to use for mounting the LV by running the following command:

    $ sudo mkdir /mnt/snapshot
  5. Mount the LV using the device name for the retrieved snapshot handle by running the following command:

    $ sudo mount /dev/<retrieved_snapshot_handle> /mnt/snapshot
    • Replace <retrieved_snapshot_handle> with the device name.

  6. Copy the files from the mounted location and store them in a secure location by running the following command:

    $ sudo cp -r /mnt/snapshot <destination>
    • Replace <destination> with the path to the secure location.