Copy of VM including snapshots

pgraluk

New Member
Aug 3, 2015
6
0
1
Hi all! Is there a way to create a clone of a VM including all its snapshots?
 
Last edited:
not by web ide, afaik.

if you can take snapshots, and (eg) it's on qcow2 storage, every snapshot is a raw file in the VM folder under <storage path>/images/<VMID>/

and has a similar naming schema as "base" disks,
if VM disks are named like vm-122-disk-1.qcow2
snapshots appear as vm-122-state-img_001.raw, vm-122-state-img_002.raw, etc.

Never tried, but, looking at my VMs storage folder, you should probably:

stop the VM to be cloned, clone it as usual on a storage that allows snapshots (like NFS fore above qcow2 example)
and then by CLI copy snapshots raw images in the destination folder, renaming them appropriately

note: the destination VM should have in its .conf a line like
vmstate: <storage name>:122/vm-122-state-img_002.raw
stating what snapshot file is in use now

and a line like
snaptime: 1438262544
stating when the snapshot in use was taken, I guess.

and a line like
parent: img_001
stating which disk image is the parent of the one in use, I guess

probably the best thing is copy the <VMID>.conf file from source to destination, adjusting manually VMIDs, MACS, storages, etc.

many guessing here, but hth
Marco
 
Last edited:
Thank you Marco, you're guessing was good. I copied the snapshots -> .raw files from the old machine to the new one in <storage path>/images/<VMID>/ and also editing the .conf file of the new machine adding the entries like in the old one and changing MACs, VMIDs and storages. In Proxmox web if at Snapshots appears the same hierarchy for the new machine as the old one.
 
This method worked fine for cloning a machine with eth0 interface but when I try to clone a VM that has virtio interface after doing all the copies when I start the VM from Proxmox console there seem to be no eth0 interface configured. I tried to added it manually by editing /etc/sysconfig/network-scripts/ifcfg-eth0. When I run service network restart a message like this appears: Bringing up interface eth0: Device eth0 does not seem to be present, delaying initialization. I'm running out of options. The initial machine has just the virtio interface added on hardware but on ifconfig command eth0 seems to be present. Why this does't apply to the clone?
 
? without snapshots, I cloned a VM with virtio network card without problems...
this shouldn't be related to the VM having snapshot, btw...
try to clone a simple VM (with virtio network card) without snapshots: it should work, afaik.

in fact, i think you could clone the vm as usual (without snapshots) and then by CLI copy snapshot files and adapt .conf files...
never tried, though...

Marco
 
Last edited:
The thing is that when I clone this VM with virtio interface the clone has no interface eth0 configured, just the loopback. Then I configured it manually as I said in /etc/sysconfig/network-scripts/ifcfg-eth0 In this step the VM is accesible but then after copying the snapshots and trying to rollback to one of its snapshots the same problem appears: no eth0 configured, just the loopback. Configuring it again manually doesn't work anymore. Am I missing something?
 
Am I missing something?

Clone Operation change the MAC address of the NIC. Maybe that could be the reason? AFAIK RHEL store MAC at
/etc/udev/rules.d/70-persistent-net.rules, so it may be enough to remove that file after clone.
 
  • Like
Reactions: Spirog
/etc/udev/rules.d/70-persistent-net.rules, so it may be enough to remove that file after clone.
I tried your suggestion and yes after removing /etc/udev/rules.d/70-persistent-net.rules and rebooting the machine the interface eth0 is configured.
Thanks!
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!