How To KVM Backup and Restore in Linux
How To KVM Backup and Restore in Linux
How To KVM Backup and Restore in Linux
techsoftcenter.com/how-to-kvm-backup-and-restore-in-linux/
By following the steps below, we’ll see how you can upload your KVM virtuals and return
them from the backup again.
1. Backup Import
First, let’s list our machines and see that they are operational. To do this, we use the
following command.
Then let’s list the machines again and see that they are turned off.
1/4
Now let’s back up the machine (XML file) with the following command/method.
or
You can copy the corresponding XLM to the corresponding backup directory with the cp
command from the “/etc/libvirt/qemu” directory where the XML is stored in default.
Now let’s back up the disk file (qcow2) with the following command/method.
Copy the qcow2 f format disk file to /MyBackup. The default location of disk files is
under “/var/lib/libvirt/images/”.
or
> virsh domblklist Ubuntu18 command you can see where it is. You can copy it to your
backup folder with cp or scp (remote) command from the related place.
1 > ls -lash
2/4
Note: You can do the backup process without turning off the machines, but it may be
healthy to turn it off and on despite errors or data loss. Of course, if the machine should
not be interrupted service, as I said VM opened backup can take.
2. Restore Making
Now let’s go back to the backup scenario. To do so, you can delete or undefine the XML.
or
If the XML file containing the server properties is deleted and we list it, we can see that the
machine is gone.
Now let’s delete the disk (qcow2) file to perform the scenario.
1 > rm /var/lib/libvirt/images/Ubuntu18.qcow2
And we can start implementing the script. Let’s start the process of copying the disk
(qcow2) from the place we took the backup to where it should be.
3/4
1 > cp /MyBackup/Ubuntu18.qcow2 /var/lib/libvirt/images/
After the copying process of the disk is finished, let’s make the XML file with the machine
properties available with the following command/method.
or
Let the XML file containing the server properties be copied back to the directory.
4/4