cloning vm with snapshots

karpa13a

New Member
Feb 16, 2020
2
0
1
45
Hi all! Is there a way to create a clone of a VM including all its snapshots?

0. i have VM with pack of snapshots, i would to clone it, to test some upgrades.

here's what I tried:
1. create clone from "current" snapshot
2. copy all vm-xxx-state-* files to new VM
3. copy/paste config part from original VM, with replacing name, net0, virtio0, virtio0, vmgenid by proper values from new VM/location

GUI now sees snapshots, but, unable to restore with the error "qemu-img: Could not apply snapshot '123': Failed to load snapshot: No such file or directory"
console command, to check list of snapshots "/usr/bin/qemu-img info /var/lib/vz/images/112/vm-112-disk-0.qcow2" provides nothing, so, seems i missed smth
112 - fresh clone

Can you advise please, how to clone VM with all snapshots?

Proxmox VE 6.1-7
simple all-in-one node: no clustering, ceph and other magic)
 
Hi,
AFAICT it's not possible to transfer all the snapshots to the clone using PVE's API. The problem is that the cloned disks do not contain the snapshots anymore so a roll-back isn't possible.

But the following should work: besides what you already did, you also have to copy the disks including the snapshots to the new VM. For qcow2, a simple cp should be enough, for ZFS, use send/recv.
 
@Fabian_E you are right:
need to copy original main disk from disabled vm and all the snapshots, to make this "feature" works. of cource with replacing storage/mac/vmgenid in clonded config (original config copy-pasta).

it works)