kastenhq / kubestr

Apache License 2.0
349 stars 47 forks source link

Adding "./kubestr file-restore" command #287

Closed shlokc9 closed 1 month ago

shlokc9 commented 2 months ago

This PR adds a new command ./kubestr file-restore which would allow the users to browse through the contents of a VolumeSnapshot along with it's source PVC using Filebrowser UI and enable copying file(s) from snapshot to PVC. Users can also copy a file from snapshot to PVC without the Filebrowser UI by simply mentioning the path of the file with --path flag.

Unit-tested these code changes with new fake tests and mock objects. Tested these code changes by executing the command on a GKE cluster. Please find the output below;

> ./kubestr file-restore --fromSnapshot test-snapshot --toPVC test-pvc1 -n file-level-restore
Fetching the snapshot.
Fetching the source PVC.
Creating the restored PVC & browser Pod.
Forwarding the port.
Port forwarding is ready to get traffic. visit http://localhost:8080/
^C
Stopping port forward.
Cleaning up browser pod & restored PVC.
> ./kubestr file-restore --fromSnapshot test-snapshot -n file-level-restore
Fetching the snapshot.
Fetching the source PVC from snapshot.
Creating the restored PVC & browser Pod.
Forwarding the port.
Port forwarding is ready to get traffic. visit http://localhost:8080/
^C
Stopping port forward.
Cleaning up browser pod & restored PVC.
> ./kubestr file-restore --fromSnapshot test-snapshot -n application --path /time.txt
Fetching the snapshot.
Creating the restored PVC & browser Pod.
Restoring the file /time.txt
File restored from VolumeSnapshot test-snapshot to Source PVC test-pvc1.
Cleaning up browser pod & restored PVC.

During cleanup, we clean the restore PVC created from the VolumeSnapshot along with the Filebrowser pod.

Closes #286