Unix & Linux Asked by user73383 on February 16, 2021
I have spent about a week trying to figure out how to backup/restore/restore a virt-manager VM including all snapshots.
If I examine the qcow2 file it contains all the snapshots that were made:
sudo qemu-img snapshot -l '../LinuxLiteV3.8.qcow2'
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
1 LinuxLite38_PreUD01 0 B 2020-11-06 23:37:14 00:00:00.000
2 snapshot1 0 B 2020-12-27 15:59:03 00:00:00.000
I can take this file to another instance of virt-manager, and recreate the VM and it will run, but virt-manager appears to have no knowledge of the snapshots.
Since the original VM still exists if necessary I could create xml files using:
virsh dumpxml LinuxLiteV3.8 --security-info --migratable >LinuxLiteV3.8
virsh snapshot-dumpxml LinuxLiteV3.8 LinuxLite38_PreUD01 --security-info >LinuxLite38_PreUD01.xml
virsh snapshot-dumpxml LinuxLiteV3.8 snapshot1 --security-info >snapshot1.xml
but I have no idea how to import the definitions into virt-manager.
IIUC virsh snapshot-create will create a new snapshot and not import an existing snapshot.
At this time, I am trying to recreate several machines that are defined as qemu:///system that I want to move to qemu:///session. I know virsh has a -c option that allows a choice to be made between qemu:///system and qemu:///session, but I don’t know how to export/import.
I also am in the process of migrating my system to new hardware, so I need to be able to reload VMs and their snapshots on a new installation of virt-manager. I am assuming that this is essentially the same problem only I’m exporting on one system and importing on another.
It would be preferable to work with only the qcow2 file, but since I still have the original working install I have the option of working with the xml files.
With an older VM named "sled9", having two disks and two snapshots, I did the following:
On the source machine:
~$ virsh dumpxml sled9 > sled9.xml
~$ virsh snapshot-list sled9
Name Creation Time State
--------------------------------------------------
snapshot1 2021-01-10 20:58:45 +0100 shutoff
vor grub 2019-05-03 12:43:30 +0200 running
~$ virsh snapshot-dumpxml sled9 snapshot1 > snapshot1.xml
~$ virsh snapshot-dumpxml sled9 'vor grub' > vor_grub.xml
Copied the two disk files and the three xml files to the target machine, into newly created directory /var/lib/libvirt/images/sled9
On the target machine:
First modified the three xml files to reflect the different path to the disk files (from /var/lib/libvirt/images/local
to /var/lib/libvirt/images/sled9
). This is only important, if the paths differ on the different machines. Then
~$ virsh define sled9.xml
~$ virsh snapshot-create sled9 --xmlfile vor_grub.xml --redefine
~$ virsh snapshot-create sled9 --xmlfile snapshot1.xml --redefine
~$ virsh snapshot-list sled9
Name Creation Time State
--------------------------------------------------
snapshot1 2021-01-10 20:58:45 +0100 shutoff
vor grub 2019-05-03 12:43:30 +0200 running
The domain was shown in the virtmanager on the target machine, the snapshots were shown, and the VM could be started without problems after modifying the network interface, which is different on both machines.
It is important to redefine the snapshots in the correct order, otherwise virsh will complain (missing parent).
Answered by ridgy on February 16, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP