Quantcast
Channel: Jive Syndication Feed
Viewing all articles
Browse latest Browse all 4

Cloning a snapshotted VM and restoring to the exact point of the snapshot

$
0
0

If you snapshot a running VM and then just copy the base disk away then you lose the running information and may corrupt a VM restored from this disk particularly if the VM is stateful like a database server. The method below will work to allow you to take a snapshot of a live machine, copy away the files and create a cloned VM that can be resumed from the exact point of the snapshot. This technique can be used for backup and restore purposes and is obviously scriptable. The reason we do this is because the disk files of a running VM are locked and therefore cannot be copied, particularly on Linux hosts where there is no VSS functionality. Note that the disk files in use after the snapshot are called *-000001.vmdk where there may be more than one depending on how many disks you have and whether they are split into 2GB chunks or not. The .vmdk disk files that are not named *-000001.vmdk are the base, original disks, and are no longer locked after a snapshot since they are read-only.

 

1) Create a new folder for the cloned VM

 

2) Copy in here the following files from the running, snapshotted VM you want to live backup:

 

     *-Snapshot1.vmem renamed to drop the "-Snapshot1" part
     *-Snapshot1.vmsn renamed to drop the "-Snapshot1" part and change ".vmsn" to ".vmss"
     Disk files (obviously more than one file if 2GB split) - don't copy the *-000001.vmdk files as these are the post snapshot disk files and will be in use
     *.vmx
     *.vmxf
     *.nvram

 

3) Add this line to the .vmx which is the key to making VMware realise that this VM that you add to the inventory is suspended:

 

checkpoint.vmState = "Whatever it is called.vmss"

4) Change the reference to the disk in the .vmx from *-000001.vmdk to the base .vmdk(s) that you have copied over

 

5) Add the .vmx to the inventory and check that it shows as suspended

 

5) Start it - note that it will ask if you have copied or moved it but you can safely answer "copied" and it will retain the suspended state and not clash with the other VM at the VMware layer but may do network, SID, etc wise if the original VM is still running

 

I have tested this on an openSUSE host but beleive it should work too on Windows hosts.


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images