From v1.30.2, the restoration of an SMB file share snapshot is now supported by CSI driver.
Follow the instructions to install snapshot driver.
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/storageclass-azurefile-csi.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/pvc-azurefile-csi.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/nginx-pod-azurefile.yaml
- Check source PVC
$ kubectl exec nginx-azurefile -- ls /mnt/azurefile
outfile
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/snapshot/volumesnapshotclass-azurefile.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/snapshot/volumesnapshot-azurefile.yaml
- Check snapshot Status
$ kubectl describe volumesnapshot azurefile-volume-snapshot
Name: azurefile-volume-snapshot
Namespace: default
Labels: <none>
Annotations: API Version: snapshot.storage.k8s.io/v1
Kind: VolumeSnapshot
Metadata:
Creation Timestamp: 2020-07-21T08:00:50Z
Finalizers:
snapshot.storage.kubernetes.io/volumesnapshot-as-source-protection
snapshot.storage.kubernetes.io/volumesnapshot-bound-protection
Generation: 1
Resource Version: 16078
Self Link: /apis/snapshot.storage.k8s.io/v1/namespaces/default/volumesnapshots/azurefile-volume-snapshot
UID: d7a3a5fb-cf58-4e57-b561-f6d7a0d10d6d
Spec:
Source:
Persistent Volume Claim Name: pvc-azurefile
Volume Snapshot Class Name: csi-azurefile-vsc
Status:
Bound Volume Snapshot Content Name: snapcontent-d7a3a5fb-cf58-4e57-b561-f6d7a0d10d6d
Creation Time: 2020-07-21T07:36:02Z
Ready To Use: true
Restore Size: 100Gi
Events: <none>
In above example,
snapcontent-2b0ef334-4112-4c86-8360-079c625d5562
is the snapshot name
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/snapshot/pvc-azurefile-snapshot-restored.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/snapshot/nginx-pod-restored-snapshot.yaml
- Check data
$ kubectl exec nginx-restored -- ls /mnt/azurefile
lost+found
outfile