|  | 
|  | 1 | +--- | 
|  | 2 | +id: velerobrfs | 
|  | 3 | +title: Velero Backup and Restore using Replicated PV Mayastor Snapshots - FileSystem | 
|  | 4 | +keywords:  | 
|  | 5 | +  - Velero Backup and Restore using Replicated PV Mayastor Snapshots - FileSystem | 
|  | 6 | +  - Velero Backup and Restore | 
|  | 7 | +  - FileSystem | 
|  | 8 | +  - OpenEBS | 
|  | 9 | +description: In this document, you learn about Velero Backup and Restore using Replicated PV Mayastor Snapshots - FileSystem. | 
|  | 10 | +--- | 
|  | 11 | + | 
|  | 12 | +# Velero Backup and Restore using Replicated PV Mayastor Snapshots - FileSystem | 
|  | 13 | + | 
|  | 14 | +Using Velero for backup and restore operations with Replicated PV Mayastor snapshots combines the strengths of both tools, providing a robust, efficient, and easy-to-manage solution for protecting your Kubernetes applications and data. The integration leverages the high performance and efficiency of Replicated PV Mayastor snapshots with the comprehensive backup capabilities of Velero, ensuring your data is always protected and recoverable. | 
|  | 15 | + | 
|  | 16 | +Velero can support any volume provider that has a Container Storage Interface (CSI) driver with snapshotting capability. | 
|  | 17 | + | 
|  | 18 | +In this guide, we will utilize Velero to create a backup of a sample Nginx application with a Replicated PV Mayastor from a cluster, transfer the backup to an object store, and restore it on a different cluster. | 
|  | 19 | + | 
|  | 20 | +## Requirements | 
|  | 21 | + | 
|  | 22 | +### Replicated PV Mayastor | 
|  | 23 | + | 
|  | 24 | +Replicated PV Mayastor CSI supports volume snapshots, which are essential for backup and recovery operations. By using Velero with Replicated PV Mayastor CSI, you can take advantage of Velero's robust backup and restore capabilities to create point-in-time snapshots of your volumes. This is critical for disaster recovery and data protection strategies. | 
|  | 25 | + | 
|  | 26 | +Make sure that Replicated PV Mayastor has been installed, pools have been configured, and applications have been deployed before proceeding to the next step. Refer to the [OpenEBS Installation Documentation](../../quickstart-guide/installation.md#installation-via-helm) for more details. | 
|  | 27 | + | 
|  | 28 | +### Velero with CSI Snapshot Support | 
|  | 29 | + | 
|  | 30 | +Velero is an open-source tool used for backup, restore, and migration of Kubernetes cluster resources and persistent volumes. It allows users to schedule regular backups of their Kubernetes resources and persistent volumes, and to restore those resources when needed. | 
|  | 31 | + | 
|  | 32 | +When CSI snapshots are enabled, Velero leverages the Kubernetes CSI driver to create snapshots of persistent volumes. These snapshots can be used to restore data to the same or different Kubernetes clusters. | 
|  | 33 | + | 
|  | 34 | +## Details of Setup | 
|  | 35 | + | 
|  | 36 | +### Install Velero with CSI Snapshot Support Enabled | 
|  | 37 | + | 
|  | 38 | +Install Velero (V1.13.2) with the `velero-plugin-for-csi` and with any S3 object storage. In this example, we are using the Google cloud bucket as our BackupStorageLocation. Refer to [Velero Documentation](https://velero.io/plugins/) for instructions on setting up the BackupStorageLocation. | 
|  | 39 | + | 
|  | 40 | +As an example we will be using Google Cloud Platform (GCP) and OpenEBS. | 
|  | 41 | + | 
|  | 42 | +1. Install Velero. | 
|  | 43 | + | 
|  | 44 | +``` | 
|  | 45 | +velero install --provider gcp --plugins velero/velero-plugin-for-gcp:v1.10.0,velero/velero-plugin-for-csi:v0.7.0  --use-node-agent --bucket velero-openebs --secret-file ./credentials-velero --use-volume-snapshots=true --features=EnableCSI | 
|  | 46 | +``` | 
|  | 47 | + | 
|  | 48 | +2. Once you have installed Velero, verify that Velero has installed correctly. | 
|  | 49 | + | 
|  | 50 | +**Command** | 
|  | 51 | + | 
|  | 52 | +``` | 
|  | 53 | +kubectl get pods -n velero | 
|  | 54 | +``` | 
|  | 55 | + | 
|  | 56 | +**Output** | 
|  | 57 | + | 
|  | 58 | +``` | 
|  | 59 | +NAME                      READY   STATUS    RESTARTS   AGE | 
|  | 60 | +node-agent-9b9gz          1/1     Running   0          175m | 
|  | 61 | +node-agent-dlrzt          1/1     Running   0          175m | 
|  | 62 | +node-agent-q47cq          1/1     Running   0          175m | 
|  | 63 | +velero-6b9b99494b-rkppw   1/1     Running   0          20h | 
|  | 64 | +``` | 
|  | 65 | + | 
|  | 66 | +3. Verify the backup and snapshot storage location. | 
|  | 67 | + | 
|  | 68 | +  - Use the following command to verify the backup: | 
|  | 69 | + | 
|  | 70 | +  **Command** | 
|  | 71 | + | 
|  | 72 | +  ``` | 
|  | 73 | +  kubectl get backupstoragelocation -n velero | 
|  | 74 | +  ``` | 
|  | 75 | + | 
|  | 76 | +  **Output** | 
|  | 77 | + | 
|  | 78 | +  ``` | 
|  | 79 | +  NAME      PHASE       LAST VALIDATED   AGE   DEFAULT | 
|  | 80 | +  default   Available   34s              20h   true | 
|  | 81 | +  ``` | 
|  | 82 | + | 
|  | 83 | +  - Use the following command to verify the snapshot storage location: | 
|  | 84 | + | 
|  | 85 | +  **Command** | 
|  | 86 | + | 
|  | 87 | +  ``` | 
|  | 88 | +  velero snapshot-location get | 
|  | 89 | +  ``` | 
|  | 90 | + | 
|  | 91 | +  **Output** | 
|  | 92 | + | 
|  | 93 | +  ``` | 
|  | 94 | +  NAME      PROVIDER | 
|  | 95 | +  default   gcp | 
|  | 96 | +  ``` | 
|  | 97 | + | 
|  | 98 | +### Deploy the Application with CSI Backed Volumes | 
|  | 99 | + | 
|  | 100 | +Before installing the application with CSI backed volumes, install the storage class and the volume snapshot class for the OpenEBS CSI driver by applying the below yaml to your cluster. Refer to the [Replicated PV Mayastor Configuration Documentation](../../user-guides/replicated-storage-user-guide/replicated-pv-mayastor/configuration/rs-create-storageclass.md#create-storageclasss) for more details. | 
|  | 101 | + | 
|  | 102 | +:::info | 
|  | 103 | +Volume snapshots for multi-replicas volume is supported only from OpenEBS v4.1. The annotation `velero.io/csi-volumesnapshot-class: "true"` must be added to the volume snapshot class or the Velero backup will fail. | 
|  | 104 | +::: | 
|  | 105 | + | 
|  | 106 | +**YAML** | 
|  | 107 | + | 
|  | 108 | +``` | 
|  | 109 | +--- | 
|  | 110 | +kind: VolumeSnapshotClass | 
|  | 111 | +apiVersion: snapshot.storage.k8s.io/v1 | 
|  | 112 | +metadata: | 
|  | 113 | +  name: csi-mayastor-snapshotclass | 
|  | 114 | +  annotations: | 
|  | 115 | +    velero.io/csi-volumesnapshot-class: "true" | 
|  | 116 | +driver: io.openebs.csi-mayastor | 
|  | 117 | +deletionPolicy: Delete | 
|  | 118 | +--- | 
|  | 119 | +apiVersion: storage.k8s.io/v1 | 
|  | 120 | +kind: StorageClass | 
|  | 121 | +metadata: | 
|  | 122 | +  name: mayastor-3-thin | 
|  | 123 | +parameters: | 
|  | 124 | +  protocol: nvmf | 
|  | 125 | +  repl: "3" | 
|  | 126 | +  thin: "true" | 
|  | 127 | +provisioner: io.openebs.csi-mayastor | 
|  | 128 | +reclaimPolicy: Delete | 
|  | 129 | +volumeBindingMode: Immediate | 
|  | 130 | +``` | 
|  | 131 | + | 
|  | 132 | +In this example, We have deployed a sample Nginx test application (with volume mode as file-system) for backup and restore. | 
|  | 133 | + | 
|  | 134 | +**Command** | 
|  | 135 | + | 
|  | 136 | +``` | 
|  | 137 | +kubectl get pods -n mayastor-app | 
|  | 138 | +``` | 
|  | 139 | + | 
|  | 140 | +**Output** | 
|  | 141 | + | 
|  | 142 | +``` | 
|  | 143 | +NAME   READY   STATUS    RESTARTS   AGE | 
|  | 144 | +test   1/1     Running   0          63m | 
|  | 145 | +``` | 
|  | 146 | + | 
|  | 147 | +**Sample Data** | 
|  | 148 | + | 
|  | 149 | +``` | 
|  | 150 | +kubectl exec -it  test -n mayastor-app -- bash | 
|  | 151 | +root@test:/# cd /volume | 
|  | 152 | +root@test:/volume# cat abc | 
|  | 153 | +Mayastor velero Backup and restore | 
|  | 154 | +root@test:/volume# exit | 
|  | 155 | +exit | 
|  | 156 | +``` | 
|  | 157 | + | 
|  | 158 | +### Backup using Velero | 
|  | 159 | + | 
|  | 160 | +- Use the following command to create a Velero backup: | 
|  | 161 | + | 
|  | 162 | +**Command** | 
|  | 163 | + | 
|  | 164 | +``` | 
|  | 165 | +velero backup create my-fs-backup --snapshot-volumes --include-namespaces=mayastor-app --volume-snapshot-locations=default --storage-location=default --snapshot-move-data | 
|  | 166 | +``` | 
|  | 167 | + | 
|  | 168 | +**Output** | 
|  | 169 | + | 
|  | 170 | +``` | 
|  | 171 | +Backup request "my-fs-backup" submitted successfully. | 
|  | 172 | +Run `velero backup describe my-fs-backup` or `velero backup logs my-fs-backup` for more details. | 
|  | 173 | +``` | 
|  | 174 | + | 
|  | 175 | +- Use the following command to verify the backup status: | 
|  | 176 | + | 
|  | 177 | +**Command** | 
|  | 178 | + | 
|  | 179 | +``` | 
|  | 180 | +velero backup get | 
|  | 181 | +``` | 
|  | 182 | + | 
|  | 183 | +**Output** | 
|  | 184 | + | 
|  | 185 | +``` | 
|  | 186 | +NAME         STATUS     ERRORS  WARNINGS  CREATED                        EXPIRES  STORAGE LOCATION   SELECTOR | 
|  | 187 | +my-fs-backup Completed  0       0         2024-07-30 08:48:12 +0000 UTC  29d      default            <none> | 
|  | 188 | +``` | 
|  | 189 | + | 
|  | 190 | +**Command** | 
|  | 191 | + | 
|  | 192 | +``` | 
|  | 193 | +kubectl get datauploads.velero.io -A | 
|  | 194 | +``` | 
|  | 195 | + | 
|  | 196 | +**Output** | 
|  | 197 | + | 
|  | 198 | +``` | 
|  | 199 | +NAMESPACE  NAME                STATUS     STARTED  BYTES DONE  TOTAL BYTES  STORAGE LOCATION  AGE    NODE | 
|  | 200 | +velero     my-fs-backup-z9vrj  Completed  2m10s    35          35           default           2m10s  worker-velero-1 | 
|  | 201 | +``` | 
|  | 202 | + | 
|  | 203 | +- Use the following command to verify the backup on target cluster: | 
|  | 204 | + | 
|  | 205 | +**Command** | 
|  | 206 | + | 
|  | 207 | +``` | 
|  | 208 | +velero backup get | 
|  | 209 | +``` | 
|  | 210 | + | 
|  | 211 | +**Output** | 
|  | 212 | + | 
|  | 213 | +``` | 
|  | 214 | +NAME          STATUS      ERRORS   WARNINGS   CREATED                         EXPIRES   STORAGE LOCATION   SELECTOR | 
|  | 215 | +my-fs-backup  Completed   0        0          2024-07-30 08:48:12 +0000 UTC   29d       default            <none> | 
|  | 216 | +``` | 
|  | 217 | + | 
|  | 218 | +### Restore using Velero | 
|  | 219 | + | 
|  | 220 | +:::important | 
|  | 221 | +In order to ensure that Velero can access the previously saved backups, it is recommended that you install Velero on the target cluster with the same values for the BUCKET-NAME and SECRET-FILENAME placeholders as you did originally. Also, make sure you have Replicated PV Mayastor already installed and that pools and storageclass have been configured. | 
|  | 222 | +::: | 
|  | 223 | + | 
|  | 224 | +- Use the following command to restore on target cluster: | 
|  | 225 | + | 
|  | 226 | +**Command** | 
|  | 227 | + | 
|  | 228 | +``` | 
|  | 229 | +velero restore create my-fs-restore --from-backup my-fs-backup --restore-volumes=true --namespace-mappings mayastor-app:mayastor-app-restore | 
|  | 230 | +``` | 
|  | 231 | + | 
|  | 232 | +**Output** | 
|  | 233 | + | 
|  | 234 | +``` | 
|  | 235 | +Restore request "my-fs-restore" submitted successfully. | 
|  | 236 | +Run `velero restore describe my-fs-restore` or `velero restore logs my-fs-restore` for more details. | 
|  | 237 | +``` | 
|  | 238 | + | 
|  | 239 | +:::note | 
|  | 240 | +This is being restored on the target cluster in the namespace: `mayastor-app-restore`. | 
|  | 241 | +::: | 
|  | 242 | + | 
|  | 243 | +- Use the following command to verify the restore status: | 
|  | 244 | + | 
|  | 245 | +**Command** | 
|  | 246 | + | 
|  | 247 | +``` | 
|  | 248 | +velero restore get | 
|  | 249 | +``` | 
|  | 250 | + | 
|  | 251 | +**Ouput** | 
|  | 252 | + | 
|  | 253 | +``` | 
|  | 254 | +NAME           BACKUP        STATUS     STARTED                        COMPLETED                      ERRORS  WARNINGS   CREATED    SELECTOR | 
|  | 255 | +my-fs-restore  my-fs-backup  Completed  2024-07-30 08:56:25 +0000 UTC  2024-07-30 08:57:11 +0000 UTC  0       1          2024-07-30 08:56:25 +0000 UTC   <none> | 
|  | 256 | +``` | 
|  | 257 | + | 
|  | 258 | +**Command** | 
|  | 259 | + | 
|  | 260 | +``` | 
|  | 261 | +kubectl get datadownloads.velero.io -A | 
|  | 262 | +``` | 
|  | 263 | + | 
|  | 264 | +**Output** | 
|  | 265 | + | 
|  | 266 | +``` | 
|  | 267 | +NAMESPACE   NAME                   STATUS      STARTED   BYTES DONE   TOTAL BYTES   STORAGE LOCATION   AGE   NODE | 
|  | 268 | +velero      my-fs-restore-2s4w5    Completed   56s       35           35            default            56s   worker-restore-1 | 
|  | 269 | +``` | 
|  | 270 | + | 
|  | 271 | +- Use the following command to validate Nginx Application restored on target cluster: | 
|  | 272 | + | 
|  | 273 | +**Command** | 
|  | 274 | + | 
|  | 275 | +``` | 
|  | 276 | +kubectl get pods -n mayastor-app-restore | 
|  | 277 | +``` | 
|  | 278 | + | 
|  | 279 | +**Output** | 
|  | 280 | + | 
|  | 281 | +``` | 
|  | 282 | +NAME   READY   STATUS    RESTARTS   AGE | 
|  | 283 | +test   1/1     Running   0          2m20s | 
|  | 284 | +``` | 
|  | 285 | + | 
|  | 286 | +**Command** | 
|  | 287 | + | 
|  | 288 | +``` | 
|  | 289 | +kubectl get pvc -n mayastor-app-restore | 
|  | 290 | +``` | 
|  | 291 | + | 
|  | 292 | +**Output** | 
|  | 293 | + | 
|  | 294 | +``` | 
|  | 295 | +NAME              STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS      AGE | 
|  | 296 | +ms-volume-claim   Bound    pvc-d1f5eddc-289b-4b7e-a61e-eaccce0f0d71   1Gi        RWO            mayastor-3-thin   2m25s | 
|  | 297 | +``` | 
|  | 298 | + | 
|  | 299 | +- Validate the data on target. | 
|  | 300 | + | 
|  | 301 | +**Sample Data** | 
|  | 302 | + | 
|  | 303 | +``` | 
|  | 304 | +kubectl exec -it test -n mayastor-app-restore -- bash | 
|  | 305 | +root@test:/# cd volume/ | 
|  | 306 | +root@test:/volume# cat abc | 
|  | 307 | +Mayastor velero Backup and restore | 
|  | 308 | +root@test:/volume# exit | 
|  | 309 | +exit | 
|  | 310 | +``` | 
|  | 311 | + | 
|  | 312 | +The `fs data` has been restored to the target cluster. | 
|  | 313 | + | 
|  | 314 | +## See Also | 
|  | 315 | + | 
|  | 316 | +- [Velero Backup and Restore using Replicated PV Mayastor Snapshots - Raw Block Volumes](velero-br-rbv.md) | 
|  | 317 | +- [Replicated PV Mayastor Installation on MicroK8s](../openebs-on-kubernetes-platforms/microkubernetes.md) | 
|  | 318 | +- [Replicated PV Mayastor Installation on Talos](../openebs-on-kubernetes-platforms/talos.md) | 
|  | 319 | +- [Replicated PV Mayastor Installation on Google Kubernetes Engine](../openebs-on-kubernetes-platforms/gke.md) | 
|  | 320 | +- [Provisioning NFS PVCs](../read-write-many/nfspvc.md) | 
0 commit comments