Backing up and restoring CSI snapshots

You can back up and restore persistent volumes by using the OADP 1.3 Data Mover.

Backing up persistent volumes with CSI snapshots

You can use the OADP Data Mover to back up Container Storage Interface (CSI) volume snapshots to a remote object store.

Prerequisites

  • You have access to the cluster with the cluster-admin role.

  • You have installed the OADP Operator.

  • You have included the CSI plugin and enabled the node agent in the DataProtectionApplication custom resource (CR).

  • You have an application with persistent volumes running in a separate namespace.

  • You have added the metadata.labels.velero.io/csi-volumesnapshot-class: "true" key-value pair to the VolumeSnapshotClass CR.

Procedure

  1. Create a YAML file for the Backup object, as in the following example:

    Example Backup CR

    1. kind: Backup
    2. apiVersion: velero.io/v1
    3. metadata:
    4. name: backup
    5. namespace: openshift-adp
    6. spec:
    7. csiSnapshotTimeout: 10m0s
    8. defaultVolumesToFsBackup: false
    9. includedNamespaces:
    10. - mysql-persistent
    11. itemOperationTimeout: 4h0m0s
    12. snapshotMoveData: true (1)
    13. storageLocation: default
    14. ttl: 720h0m0s
    15. volumeSnapshotLocations:
    16. - dpa-sample-1
    17. # ...
    1Set to true to enable movement of CSI snapshots to remote object storage.
  2. Apply the manifest:

    1. $ oc create -f backup.yaml

    A DataUpload CR is created after the snapshot creation is complete.

Verification

  • Verify that the snapshot data is successfully transferred to the remote object store by monitoring the status.phase field of the DataUpload CR. Possible values are In Progress, Completed, Failed, or Canceled. The object store is configured in the backupLocations stanza of the DataProtectionApplication CR.

    • Run the following command to get a list of all DataUpload objects:

      1. $ oc get datauploads -A

      Example output

      1. NAMESPACE NAME STATUS STARTED BYTES DONE TOTAL BYTES STORAGE LOCATION AGE NODE
      2. openshift-adp backup-test-1-sw76b Completed 9m47s 108104082 108104082 dpa-sample-1 9m47s ip-10-0-150-57.us-west-2.compute.internal
      3. openshift-adp mongo-block-7dtpf Completed 14m 1073741824 1073741824 dpa-sample-1 14m ip-10-0-150-57.us-west-2.compute.internal
    • Check the value of the status.phase field of the specific DataUpload object by running the following command:

      1. $ oc get datauploads <dataupload_name> -o yaml

      Example output

      1. apiVersion: velero.io/v2alpha1
      2. kind: DataUpload
      3. metadata:
      4. name: backup-test-1-sw76b
      5. namespace: openshift-adp
      6. spec:
      7. backupStorageLocation: dpa-sample-1
      8. csiSnapshot:
      9. snapshotClass: ""
      10. storageClass: gp3-csi
      11. volumeSnapshot: velero-mysql-fq8sl
      12. operationTimeout: 10m0s
      13. snapshotType: CSI
      14. sourceNamespace: mysql-persistent
      15. sourcePVC: mysql
      16. status:
      17. completionTimestamp: "2023-11-02T16:57:02Z"
      18. node: ip-10-0-150-57.us-west-2.compute.internal
      19. path: /host_pods/15116bac-cc01-4d9b-8ee7-609c3bef6bde/volumes/kubernetes.io~csi/pvc-eead8167-556b-461a-b3ec-441749e291c4/mount
      20. phase: Completed (1)
      21. progress:
      22. bytesDone: 108104082
      23. totalBytes: 108104082
      24. snapshotID: 8da1c5febf25225f4577ada2aeb9f899
      25. startTimestamp: "2023-11-02T16:56:22Z"
      1Indicates that snapshot data is successfully transferred to the remote object store.

Restoring CSI volume snapshots

You can restore a volume snapshot by creating a Restore CR.

You cannot restore Volsync backups from OADP 1.2 with the OAPD 1.3 built-in Data Mover. It is recommended to do a file system backup of all of your workloads with Restic prior to upgrading to OADP 1.3.

Prerequisites

  • You have access to the cluster with the cluster-admin role.

  • You have an OADP Backup CR from which to restore the data.

Procedure

  1. Create a YAML file for the Restore CR, as in the following example:

    Example Restore CR

    1. apiVersion: velero.io/v1
    2. kind: Restore
    3. metadata:
    4. name: restore
    5. namespace: openshift-adp
    6. spec:
    7. backupName: <backup>
    8. # ...
  2. Apply the manifest:

    1. $ oc create -f restore.yaml

    A DataDownload CR is created when the restore starts.

Verification

  • You can monitor the status of the restore process by checking the status.phase field of the DataDownload CR. Possible values are In Progress, Completed, Failed, or Canceled.

    • To get a list of all DataDownload objects, run the following command:

      1. $ oc get datadownloads -A

      Example output

      1. NAMESPACE NAME STATUS STARTED BYTES DONE TOTAL BYTES STORAGE LOCATION AGE NODE
      2. openshift-adp restore-test-1-sk7lg Completed 7m11s 108104082 108104082 dpa-sample-1 7m11s ip-10-0-150-57.us-west-2.compute.internal
    • Enter the following command to check the value of the status.phase field of the specific DataDownload object:

      1. $ oc get datadownloads <datadownload_name> -o yaml

      Example output

      1. apiVersion: velero.io/v2alpha1
      2. kind: DataDownload
      3. metadata:
      4. name: restore-test-1-sk7lg
      5. namespace: openshift-adp
      6. spec:
      7. backupStorageLocation: dpa-sample-1
      8. operationTimeout: 10m0s
      9. snapshotID: 8da1c5febf25225f4577ada2aeb9f899
      10. sourceNamespace: mysql-persistent
      11. targetVolume:
      12. namespace: mysql-persistent
      13. pv: ""
      14. pvc: mysql
      15. status:
      16. completionTimestamp: "2023-11-02T17:01:24Z"
      17. node: ip-10-0-150-57.us-west-2.compute.internal
      18. phase: Completed (1)
      19. progress:
      20. bytesDone: 108104082
      21. totalBytes: 108104082
      22. startTimestamp: "2023-11-02T17:00:52Z"
      1Indicates that the CSI snapshot data is successfully restored.