---
# System prepended metadata

title: Backup/Restore Using CSI snapshots
tags: [Documentation]

---

# Backup/Restore Using CSI snapshots
###### tags: `Documentation`

## Prerequisites
1. Make sure the OADP operator is installed:
```
make deploy
```
1. Create a credentials secret for AWS:
```
oc create secret generic cloud-credentials --namespace openshift-adp --from-file cloud=<CREDENTIALS_FILE_PATH>
```
3. Make sure your Velero CR is similar to this:
```
kind: Velero
apiVersion: oadp.openshift.io/v1alpha1
metadata:
 name: example-velero
 namespace: openshift-adp
spec:
 olmManaged: false
 backupStorageLocations:
   - config:
       profile: default
       region: us-west-2
     name: default
     objectStorage:
       bucket: my-bucket
       prefix: velero
     provider: aws
     default: true
 defaultVeleroPlugins:
   - aws
   - csi
   - openshift
 veleroFeatureFlags:
   - EnableCSI
 volumeSnapshotLocations:
   - config:
       profile: default
       region: us-west-2
     name: default
     provider: aws
```

    (Note:  Your BSL region should be the same as your s3 bucket, and your VSL region should be your cluster's region.)

4. Install Velero:
```
oc create -n openshift-adp -f config/samples/oadp_v1alpha1_velero.yaml
```
5. Create VolumeSanpshot Class:

    ![](https://hackmd.io/_uploads/rkLGaTBUF.png)
    Click on volume snapshotClass and update the input as below
```
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
metadata:
 name: example-snapclass
 labels:
   velero.io/csi-volumesnapshot-class: 'true'
driver: ebs.csi.aws.com
deletionPolicy: Retain
```
## Create the Mssql deployment config:
```
oc create -f docs/examples/manifests/mssql-template.yaml
```
(Note: Update Persistent volume claim with storageClassName: gp2-csi instead default gp2)

This example will create the following resources:
* Namespace
* Secret
* Service
* Route
* PersistentVolumeClaim
* Deployment

## Verify application resources:
```
oc get all -n mssql-persistent
```
## Create application backup
```
velero backup  create csi-testing --include-namespaces mssql-persistent -n openshift-adp
 ```
## Verify the backup is completed
```
velero backup describe csi-testing -n openshift-adp
 ```
should result in Completed

## Delete the application
Once we have ensured the backup is completed, we want to test the restore process. First, delete the mssql-persistent project:
```
oc delete namespace mssql-persistent
```
## Create the restore for the application
```
velero restore create --from-backup csi-testing -n openshift-adp
```

## Verify the restore is completed
```
velero restore describe <restore-name-generated-in-previous-step>  -n openshift-adp
 ```
should result in Completed

## Verify all resources have been recreated in the restore process
```
oc get all -n mssql-persistent
```

