Using snapshots for recovering data
If your IBM Hyper Protect Virtual Servers fails for any reason, you can create a new instance and attach the data volume that was attached to the failed instance. Ensure that you use the same contract that was used originally to create the instance.
The following procedure details the use of the virsh
commands. The following information illustrates the use of the virsh
commands and is only for your reference. For more information about virsh
commands,
see libvirt virtualization API.
This procedure is intended for users with the role system admin or app developer or ISV.
Procedure
-
Complete the following steps:
-
Identify the data disk that was used and take a snapshot of it.
virsh domblklist <vm_name>
You can take a backup of the original disk. An example of this command:
cp /var/lib/libvirt/images/newstorage/datavolume /var/lib/libvirt/images/hpcr/snap-image/backupdatavolume
-
Create a folder for saving the snapshots by using the following command:
mkdir /var/lib/libvirt/images/hpcr/snap-image
The following commands show an example of taking a snapshot:
virsh snapshot-create-as --domain <vm_name> guest-state1 --diskspec vdb,file=/var/lib/libvirt/images/hpcr/snap-image/snapshotimg.qcow2 --disk-only --atomic
-
You can view the snapshot that was taken by using the following command:
virsh snapshot-list <vm_name>
List the block device that is in use by using the following command:
virsh domblklist <vm_name>
-
After the backup completes, perform an active-blockcommit by live-merging the contents of
snapshotimg.qcow2
intodata volume
virsh blockcommit <vm_name> vdb --active --verbose --pivot
-
-
Create a new virtual server instance by using the snapshot qcow2 image as a data disk:
The following snippet highlights the modified section the XML file, that you must update before you create the instance:
<disk type='file' device='disk'> <driver name='qemu' type='qcow2' cache='none' iommu='on'/> <source file='/var/lib/libvirt/images/hpcr/snap-image/snapshotimg.qcow2'/> <target dev='vdb' bus='virtio'/> </disk>
Add the following content in a file called
hpcrnew.xml
<domain type='kvm'> <name>hpcrdemonew</name> <uuid>94938412-95df-4611-a3dd-d95cc3b8443f</uuid> <metadata> <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0"> <libosinfo:os id="http://ubuntu.com/ubuntu/20.04"/> </libosinfo:libosinfo> </metadata> <memory unit='KiB'>3906250</memory> <currentMemory unit='KiB'>3906250</currentMemory> <vcpu placement='static'>2</vcpu> <os> <type arch='s390x' machine='s390-ccw-virtio-focal'>hvm</type> <boot dev='hd'/> </os> <cpu mode='host-model' check='partial'/> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> <emulator>/usr/bin/qemu-system-s390x</emulator> <disk type='file' device='disk'> <driver name='qemu' type='qcow2' iommu='on'/> <source file='/var/lib/libvirt/images/hpcr/snapvs/ibm-hyper-protect-container-runtime-24.9.1.qcow2' index='2'/> <backingStore/> <target dev='vda' bus='virtio'/> <alias name='virtio-disk0'/> <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/> </disk> <disk type='file' device='disk'> <driver name='qemu' type='raw' cache='none' io='native' iommu='on'/> <source file='/var/lib/libvirt/images/hpcr/snapvs/init-disk'/> <target dev='vdc' bus='virtio'/> <readonly/> <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0002'/> </disk> <disk type='file' device='disk'> <driver name='qemu' type='qcow2' cache='none' iommu='on'/> <source file='/var/lib/libvirt/images/hpcr/snap-image/snapshotimg.qcow2'/> <target dev='vdb' bus='virtio'/> </disk> <controller type='pci' index='0' model='pci-root'/> <interface type='network'> <mac address='52:54:00:83:2e:37'/> <source network='default'/> <model type='virtio'/> <driver name='vhost' iommu='on'/> <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/> </interface> <console type='pty'> <target type='sclp' port='0'/> </console> <memballoon model='none'/> <panic model='s390'/> </devices> </domain>
To define the domain, use the following command.
virsh define hpcrnew.xml
To start the instance, use the following command.
virsh start hpcr-new --console