VMware Cloud Community
eager2learnn
Contributor
Contributor

Cloning a VM along with it's Snapshot

Hi there

My use case is as follows :

I have a set of VM's on which I have some snapshots, these snapshots are meant for lab purpose for students to rollback and move forward.

Now I want to create multiple such set of VM's, for which I thought let me clone, but the moment I clone all the snapshots on the new VM's are gone and disks are consolidated. So is there any way to retain the Snapshots on the new VM while copying/cloning.

Any pointers on the above will be much appreciated. Thanks

Regards,

Born2Learn

0 Kudos
28 Replies
continuum
Immortal
Immortal

> Can you please highlight the files which you edited for the MAC address and UUID stuff.
That is not necessary at all if you follow Sandeeps list:

1. Power of the VM

2. Copy the entire VM folder to your new host

3. Browse to the datastore from vCenter or host client and locate the .vmx file

4. Right click and say, "Add to Inventory".

5. Provide a name for VM and add to inventory.

6. Power on VM.

7. When the client asks you how you moved the files, select the option "Copied it"
Answering "I copied it" should do it.
But you need to doublecheck all the vmdk-descriptors and make sure that none of them uses an absolut path.
Your snapshots and your basedisk need to be in a single folder.


________________________________________________
Do you need support with a VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

0 Kudos
daphnissov
Immortal
Immortal

I altered

ethernet0.generatedAddress

uuid.bios

vc.uuid

BTW, I'm not saying changing these is required, but these are unique identifiers which I know should be different regardless what mechanism makes that so.

0 Kudos
eager2learnn
Contributor
Contributor

ok thanks daphnissov

LucD​ : Can you please help me in editing the value of

ethernet0.generatedAddress

uuid.bios

vc.uuid

in various text files in a VM folder like vmx, vmdk and vmsn programattically. I tried to do the following but couldn't get it through.

$vm = get-vm "testvm"

$snaps = Get-Snapshot -VM $vm

$date = get-date -format “dd hh mm ss”

$newUuid = “56 4d 50 2e 9e df e5 e4-a7 f4 21 3b ” + $date

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec

$spec.uuid = $newUuid

$vm.Extensiondata.ReconfigVM_Task($spec)

foreach($snap in $snaps)

{

#(get-view $snap.Id).Config.uuid

((get-view $snap.Id).Config.uuid).ReconfigVM_Task($spec)

}

Regards,

born2learnn

0 Kudos
eager2learnn
Contributor
Contributor

LucD​ : Can you please advise.

0 Kudos
LucD
Leadership
Leadership

For a VM you can change/reset the MACAddress, InstanceUUid and the Uuid through the ReconfigVM method.

But afaik there is no documented method to do this for a Snapshot of a VM.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
eager2learnn
Contributor
Contributor

ok.. thanks LucD

Can you please advise if this can be achieved by any other way. I am now trying to write a script which I will run inside the ESXi and will edit all the *.vmsn files, but appreciate if you could think of something better.

0 Kudos
LucD
Leadership
Leadership

Sorry, but as I already mentioned, I don't know of any supported method to do this.

Besides opening the files in a text editor and hoping for the best, I know of no other method.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
eager2learnn
Contributor
Contributor

okay ..no problem LucD​.

Thanks for your help daphnissov

0 Kudos
ferdis
Hot Shot
Hot Shot

Hi, have you solved this in any way? I have same use case.

0 Kudos