-
Export KVM VM with virsh command
-
Import VM export to another KVM host
-
Convert KVM virtual hard disk
-
Manage and Protect VM with Vinchin Backup & Recovery
-
Sum Up
KVM is a popular hypervisor for upgrading physical environment to virtual environment.
Exporting KVM VM will let you have a copy of VM data to use it as VM backup. The KVM VM backup can help recover data when it is necessary by importing data back to the original host. Of course, the VM export can be also used on another KVM host after VM migration.
There are different KVM environments like Red Hat Virtualization and Oracle Linux KVM and different virtual disks might be used like qcow2 virtual disks and raw virtual disks. IT administrators often need to convert the VM or virtual disk to import it to new environment.
P.S. Vinchin Backup & Recovery can let you manage KVM-based hypervisor like Red Hat Virtualization, oVirt, and Oracle Linux KVM, more conveniently. It will be your all-in-one solution for VM backup, recovery, and migration.
In VMware environment, except for copying the folder from datastore, VM export can be also generated by vCenter or ESXi client and the whole VM will be saved as OVF template. If you have an oVirt host, you can export VM via VM Portal.
Export KVM VM with virsh command
In the native KVM environment, VM export is often generated by command. IT administrators need to export both xml file and virtual hard disk.
1. Find the directory of the target VM.
The command below will help present all the VMs on the host:
virsh list --all
2. Shutdown the VM
virsh shutdown target_guest_machine
3. Export the VM configuration, xml file
virsh dumpxml target_guest_machine > /root/target_guest_machine.xml
4. Copy the virtual hard disk.
The command below will help present the directory of virtual hard disk:
virsh domblklist guest_name
Import VM export to another KVM host
You can use not only the virtual hard disk on another host, but also the whole old VM.
To make sure the VM can be successfully imported to the new KVM host, there are 2 important requirements:
The environment on the new host should be the same as the environment on the old host.
The absolute directories of xml file and virtual disk in new envionment must be the same as the directories in the old environment.
Steps to import KVM VM:
1. Copy the xml file and virtual hard disk to the destination host
scp /root/target_guest_machine.xml destination_host_ip://etc/libvirt/qemu
Copy virtual hard disk with the similar command. It might require providing the password of destination host to start data transfer.
2. Define the new VM
virsh define guest_name.xml
Then you can try starting the VM on new host.
Convert KVM virtual hard disk
If the virtual hard disk needs to be imported to another platform, the format of virtual hard disk often needs to be converted. The popular virtual hard disk converter is qemu-img. Just a line of command is enough to convert the virtual hard disk.
Let's take converting qcow2 to vmdk as an example:
qemu-img convert -p -f qcow2 -O vmdk .my_centos.qcow2 .my_centos.vmdk
-p: presenting the conversion progress
-f: format of the source image
-O: format of the target image
Manage and Protect VM with Vinchin Backup & Recovery
Manually exporting and importing VM files with command lines might require complicated procedures and the files are not systematically saved and protected.
Vinchin Backup & Recovery is a professional backup and disaster recovery solution which can help you better manage and protect KVM-based platform, like Red Hat Virtualization, oVirt, Oracle Linux KVM, OpenStack, etc. (Native KVM is not supported for now)
This professional system will let you easily backup KVM virtual machine in a user-friendly web console. There are many backup strategies including schedules, incremental backup, data encryption, etc. VM backup files can be systematically saved in the backup system to let you easily use them later.
VM backup files can be easily used on another host and Vinchin Backup & Recovery can also help easily perform a cross-platform migration. You just need to select a host to restore the VM.
Vinchin Backup & Recovery has been selected by thousands of companies and you can also have a 60-day full-featured free trial to use the powerful system. Just click the button to get the installation package.
Sum Up
KVM is popular hypervisor for virtual environment deployment. Sometimes IT administrators need to export the VM to save data or for later data transfer. The common methods of exporting and importing VM data are exporting files via command and copying files to new host. To move VM to a heterogeneous environment, virtual hard disk might need to be converted.
Vinchin Backup & Recovery can help you better manage and protect KVM-based virtual environment. Don't miss the free trial.
Share on: