This article describes how a snapshot can be used to restore data or recreate a scenario. We assume that you already have taken the snapshot of the volume that has to be restored or recreated. If not, click here to know the steps to generate a snapshot.
Possible Use Cases
- A snapshot can be used to recreate a particular scenario or stage of a cluster. This can be useful for debugging purposes.
- The snapshot can be used to restore data.
Note: When restoring using snapshot, the data will be reverted to the state at which snapshot had been taken.
How to restore?
Step 1:
Select Volumes under the Topology section, this displays a detailed view of all the Volumes in the cluster. The snapshots are also visible in the topology graph, connected with the associated volume having a camera icon () on it.
Click on the snapshot that you to want to clone. This opens up a pop-up towards the right of your screen. Click on Clone Snapshot () icon.
Step 2:
NOTE: This article is written assuming that the application has been deployed in default namespace.
Cloning of snapshot creates a new PVC, which uses the openebs-snapshot-promoter as it's storage class. This storage class is created by default while installing openebs. The new PVC will have the same storage capacity as that of the Source Volume and will be deployed in the same namespace. To view the name of the PVC, execute:
kubectl get pvc -n <application_namespace>
Sample Command:
kubectl get pvc
Sample Output:
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
clone-vol1-claim-37b5 Bound pvc-9a7ae7d0-5e0f-11ea-8710-42010a800236 20G RWO openebs-snapshot-promoter 12m
vol1-claim Bound pvc-6d77dd6a-5e02-11ea-8710-42010a800236 20G RWO openebs-sc-statefulset 107m
In this example, vol1-claim is the source PVC and clone-vol1-claim-37b5 is the cloned PVC.
Step 3:
Use this PVC name(Obtained in Step 2) in your application YAML to restore the application to the desired state.
You can create another application and mount this PVC.
To create another application first copy the YAML and then edit it.
To get the YAML in another file, execute:
kubectl get pod <pod_name> -o yaml > deployment.yaml
Now, edit you application spec, with the new PVC name under metadata.volumes.persistentVolumeClaim.claimName
volumes: - name: demo-vol1 persistentVolumeClaim: claimName: clone-vol1-claim-37b5
Then apply the new YAML using:
kubectl apply -f deployment.yaml
Your application should now be running and in the desired state with the required data. To know the status of the pod, execute:
kubectl get pods
Sample Output:
NAME READY STATUS RESTARTS AGE
percona-9756d4896-wj225 1/1 Running 0 32s