Restore a Block Volume from a Snapshot

Prev Next

To restore a PVC from an existing snapshot, attach the snapshot to another PVC.

You can choose to provide read-only or read/write access to the restored block volume using accessModes options in the YAML configuration file.

  • If attached in read-only mode (ReadOnlyMany), the restored volume is mounted to the snapshot's source folder (<snapshot path>/.snapshot/<snapshot name>). It does not have a view or a quota on the VAST cluster, not can it be expanded through Kubernetes volume expansion.

  • If attached in read/write mode (ReadWriteMany), a view and a quota is created automatically for it on the VAST cluster, and the restored volume is mounted to the view's directory. The restored volume can be expanded like any other regular volume.

To restore a volume:

  1. Create a YAML configuration file to attach the snapshot to a PVC. In the file (see the example below for correct indentation and line breaks when specifying the keywords):

    • In metadata:

      • name is the Persistent Volume Claim (PVC) name for the volume that will contain the restored data.

    • In spec:

      • In accessModes, specify the access mode for the restored volume:  

        • ReadWriteMany for read/write

        • ReadOnlyMany for read-only

      • storageClassName is the name of the storage class used for the PVC.

      • In dataSource:

        • name is the PVC name of the volume that stores the snapshot.

    For example:

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: pvc-restore
    spec:
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 10Gi
      storageClassName: vastdata-filesystem
      dataSource:
        name: snapshot-pvc-1
        kind: VolumeSnapshot
        apiGroup: snapshot.storage.k8s.io
  2. Deploy the YAML configuration file:

    kubectl apply -f vast-csi-deployment.yaml

    The output is similar to the following:

    persistentvolumeclaim/pvc-restore created
  3. Verify that the restored PVC can be displayed:

    kubectl get pvc

    The output is similar to the following:

    NAME        STATUS VOLUME                                   CAPACITY ACCESS MODES STORAGECLASS        AGE
    pvc-restore Bound  pvc-c212dc9e-1b72-49da-8a58-8c1ceb97b9e3 1Gi      RO           vastdata-filesystem 7s