How snapshots work in Hyper-V 1

The ability to do snapshots in Hyper-V, or in any virtualisation product is in my opinion is awesome, gone are the days of before you applied any patches to your server or applications, you had to make sure that you had done decent backup, apply the patches and hope you don’t have to restore from your backup which would had probably been to tape. Nowadays if your server is virtualised, take a snapshot, do the updates and if it goes wrong just revert to the snapshot, how is that not awesome.

I do want to make one thing clear, in fact say this out loud, A SNAPSHOT IS NOT A BACKUP, why not well if you lose your primary copy of your VM, you would be better off with a bit off with a poptart, as a snapshot isn’t going to help you get your data back, and at least a pop tart will mean you ain’t hungry, do you still get pop tarts?

Before going into how snapshots work it is worth just quickly going over the files that make a Hyper-V VM.
*.vhd This contains all the data, like the OS, Applications & Files.
*.xml This is the config file for the *.vhd, each snapshot will also have an associated xml file.
*.bin Contains the memory of a virtual machine or snapshot that is in a saved state.
*.vsv Contains the saved state from the devices associated with the virtual machine.
*.avhd This is the snapshot for a *.vhd file

So how do Snapshots work in Hyper-V?
OK so we now know the snapshot is stored in the *.avhd file, but what exactly is happening to create this file?
When you create a snapshot the following happens:
The VM is paused.
A differencing disk for each virtual hard disk is made, the *.avhd
A copy of the virtual machine’s configuration file is made.
The virtual machine is resumed, this happens so quickly that you should not notice the VM was paused
Once the VM is running again the contents of the virtual machine’s memory is saved to disk.

Once the snapshot is completed you will have a set of the virtual machine configuration file, the virtual machine saved state files and the snapshot differencing disks (.AVHDs) stored in a folder under the virtual machine’s snapshot directory.

This is can now be treated as a read-only “point in time” image of a virtual machine. That you can roll back to if you ever needed.

It is a good idea to ensure that you tidy up all your snapshots and delete them when you are sure you don’t need them, and remember snapshots are great for rolling back your VM in case of a failed upgrade, but they should not be treated as backup.

Hope this helps any questions let me know.

One comment on “How snapshots work in Hyper-V

  1. Pingback: Backup up XenDesktop7 ← Gavin Dye

Leave a Reply

%d bloggers like this: