VirualMachine data is usually stored in the PV/PVC on OCPv4. This testing is for checking if the PV/PVC backup is valid to VM backup too.
$ mkdir /home/fedora/test_dir
$ echo TestData > /home/fedora/test_dir/test.txt
$ oc create -f - <<EOF
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: new-backup-pvc
namespace: backup-test
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 15Gi
storageClassName: gp2
EOF
$ oc create deployment sleep --image=registry.access.redhat.com/rhel7/rhel-tools -- tail -f /dev/null
$ oc set volume deployment/sleep --add -t pvc --name=old-pvc --claim-name=backup-test-rootdisk-3v2kg --mount-path=/old-pvc
$ oc set volume deployment/sleep --add -t pvc --name=new-pvc --claim-name=new-backup-pvc --mount-path=/new-pvc
$ oc get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
backup-test-rootdisk-3v2kg Bound pvc-c7d8dde6-28a5-4803-aaf8-9b93efab4f9e 15Gi RWO gp2 40m
new-backup-pvc Bound pvc-28f99c53-76d3-46e4-8960-6adaa441361a 15Gi RWO gp2 2m32s
$ oc get pod
NAME READY STATUS RESTARTS AGE
sleep-6f979fcb4d-mvdrz 1/1 Running 0 77s
$ oc rsh sleep-6f979fcb4d-mvdrz
sh-4.2$ ls -al /{old,new}-pvc
/new-pvc:
total 20
drwxrwsr-x. 3 root 1000610000 4096 May 26 06:42 .
drwxr-xr-x. 1 root root 36 May 26 06:42 ..
/old-pvc:
total 1025212
drwxrwsr-x. 2 root 1000610000 4096 May 26 06:03 .
drwxr-xr-x. 1 root root 36 May 26 06:42 ..
-rw-rw----. 1 root 1000610000 15727509504 May 26 06:31 disk.img
sh-4.2$ rsync -avxHAX --progress /old-pvc/* /new-pvc
sending incremental file list
disk.img
15,727,509,504 100% 157.24MB/s 0:01:35 (xfr#1, to-chk=0/1)
sent 15,731,349,359 bytes received 35 bytes 163,019,164.70 bytes/sec
total size is 15,727,509,504 speedup is 1.00
Select with "Existing PVC" after "Create Virtual Machine" -> "New with Wizard"
Add disk with "Using an existing PVC" we created previously
Select the disk as "Boot Source"
And run the new VM.
Ok, the data is restored intactly.
Done.