RHV native VMs image backup solution (export as ova)
Red Hat Virtualization come with a feature "export OVA", it can export the running VM(powered up) and save it as OVA. Although this ova format cannot import back to vmware, but it is good enough to backup the critical virtual machine and restore it if necessary. First the VM will auto take snapshot and copy the disk and remove the snapshot after export finish. It same as what backup software does and backup software is doing better such as incremental backup, schedule, select VM to backup etc.
1. Export OVA button
[root@rhvh0 backup]# df -h
Filesystem Size Used Avail Use% Mounted on
...
nfs:/Public/rhv 5.4T 3.6T 1.8T 67% /rhev/data-center/mnt/nfs:_Public_rhv
...
[root@rhvh0 backup]# pwd
/rhev/data-center/mnt/nfs:_Public_rhv/backup
2. It is good, next we can create script to call api to the rhvm and vms.txt file for backup.
[root@nfs ~]# cat backup.sh
#!/bin/bash
filename=vms.txt
while read -r line; do
vmname="$line"
read -r line
vmid="$line"
echo $vmname
echo $vmid
echo "curl -v -k --request POST \
--header 'Version: 4' \
--header 'Accept: application/xml' \
--header 'Content-Type: application/xml' \
-d '<action><host><name>rhvh1.example.com</name></host><directory>/rhev/data-center/mnt/nfs:_Public_rhv/backup</directory><filename>'$vmname'.ova</filename></action>' \
-u admin@internal:password \
https://rhvm.example.com:443/ovirt-engine/api/vms/$vmid/export"
curl -v -k --request POST \
--header 'Version: 4' \
--header 'Accept: application/xml' \
--header 'Content-Type: application/xml' \
-d '<action><host><name>rhvh1.example.com</name></host><directory>/rhev/data-center/mnt/nfs:_Public_rhv/backup</directory><filename>'$vmname'.ova</filename></action>' \
-u admin@internal:password \
https://rhvm.example.com:443/ovirt-engine/api/vms/$vmid/export
sleep 15m
done < "$filename"
[root@nfs ~]# cat vms.txt
dc02
714ebf55-0780-47bd-812a-94a45247ca35
demo
1ad3ca59-19e4-4669-81de-6472d26dc431
[root@nfs ~]#
From the VM page, we can find VM ID:
Tested work well in RHV 4.4
Comments