Managing Snapshots with Hyper-V

Hyper-V introduces the concept of virtual machine snapshots - which is to say point in time images of a virtual machine that you can return to at any stage.  These snapshots are implemented in the virtualization layer - and can be taken at any time with any guest operating system (even during an operating system installation).  Snapshots can be taken whether the virtual machine is running or stopped.  If the virtual machine is running when the snapshot is taken there is no downtime involved to create the snapshot.

Snapshots can be created in the Hyper-V Manager (by selecting a virtual machine and selecting Snapshot from the Action menu or panel) and in the Virtual Machine Connection window (by clicking on the snapshot button in the toolbar or by opening the Action menu and selecting Snapshot... ).

Selecting to create a snapshot from the Virtual Machine Connection window will result in a dialog that allows you to enter a custom name for the snapshot (e.g. "Installed Office 2007" or "Just before I do something stupid and ruin the virtual machine").  If you want you can dismiss this dialog and have the snapshot use an auto-generated name.  This auto-generated name will consist of the name of the virtual machine followed by the date and time when the snapshot was taken.

If you select to create a snapshot from the Hyper-V Manager the snapshot will be created with an auto-generated name.

Once you have created a snapshot you can view it in the Snapshots pane of the Hyper-V Manager by selecting the virtual machine that the snapshot is associated with.  Snapshots are displayed in the Snapshots pane in a hierarchal manner that describes the order in which the snapshots where taken.  One snapshot will have a green arrow head on top of it - this indicates that this snapshot was the last one to be taken or applied to the virtual machine.  When you select a snapshot there are a couple of options that are provided to you in the Action menu / panel:

  • Settings...

    Selecting this will allow you to open the Virtual Machine Settings dialog with the settings that the virtual machine had when the snapshot was taken.  All the settings will be disabled - because a snapshot is essentially read only.  The only settings that you can change here are the snapshot name and the notes associated with the snapshot.

  • Apply...

    Applying a snapshot to a virtual machine basically means copying the complete virtual machine state from the selected snapshot to the active virtual machine.  This process means that any unsaved data in the currently active virtual machine will be lost - and you will be asked if you want to create a snapshot of your current active virtual machine before the selected snapshot is applied.

    Once the snapshot is applied the virtual machine will either be in a saved state or stopped (depending on if the snapshot was taken of a running or stopped virtual machine).  If there are any settings that you need to change before starting the virtual machine you can now select the virtual machine, open the Virtual Machine Settings, and change them.

  • Rename...

    This is a quick shortcut that allows you to rename a snapshot without having to open the Virtual Machine Settings.

  • Delete Snapshot...

    Deleting a snapshot means that you can no longer restore the virtual machine to that point in time.  It is important to understand that deleting a snapshot will never effect any other snapshots, nor will it affect the current state of the virtual machine.  The only thing that will disappear is the selected snapshot.

    Sometimes in order to delete a snapshot we will need to merge the differencing disk that we created for the snapshot (this differencing disk is hidden from the user under most circumstances - I will talk more about the actual plumbing involved with snapshots another day).  This merging will happen automatically the next time that the virtual machine is not running.

  • Delete Snapshot Subtree...

    Will delete the selected snapshot and any snapshots that are hierarchically underneath it.

Once you have snapshots associated with a virtual machine you can use the Revert option.  This will take a virtual machine back to the last snapshot that was taken or applied (indicated in the Snapshots pane by the green arrow head) and delete any changes that have been made since that snapshot.

Cheers,
Ben

Comments

  • Anonymous
    January 16, 2008
    "I will talk more about the actual plumbing involved with snapshots another day" Please do so.  This will be useful information for making disk space considerations for those hosts that we think will utilize this feature extensively.  

  • Anonymous
    January 17, 2008
    DO snapshots work with VSS in the hosted OS. Maybe I'm using the wrong acronym there...but you get what I'm saying right? I have used some desktop level VM software that didn't, and well...things went bad when reverting back to a prior snapshot.

  • Anonymous
    January 17, 2008
    I've used a number of VSS snapshots that do work in VS2005SP1.  I wonder what specifically has changed to improve(?) VSS functionality for guest snapshots... Here's what MSDN is saying is new in VSS... http://msdn2.microsoft.com/en-us/library/aa819772.aspx

  • Anonymous
    January 18, 2008
    There's one thing to be careful about when reverting virtual machines to earlier points in time.  By default, if the machine is a member of a domain, it will change its machine password every so often.  If you revert to a time before the password change, the machine will no longer be able to connect to the domain. If you are working with test machines where security is not a significant issue, you can turn off machine password changes using Group Policy.

  • Anonymous
    January 19, 2008
    Brent's comment addresses an issue that created a lot of work for us when we first enabled our users with the ability to use Checkpoints (VS 2005 guests w/VMM Self Service portal) on their "development" guests. We've managed to work around this in our environment via a combination of a local user account defined in the base virtual (pre-snapshots) and the ability for the user in question to rejoin a particular machine account back to the domain on their own, but I like Brent's solution better. :) Curious what others are doing in this situation?  (other than not operating in a domain and rather workgroup)

  • Anonymous
    February 15, 2008
    Snapshots appear to consume disk space at a rate not at all in proportion with the size of the original vhd.  I had new 60GB disk, added a 6GB W2K8 guest, took two snapshots and ended up with a full disk?

  • Anonymous
    July 30, 2010
    hi ben, i removed the snapshots directly from the folder and not the GUI. Now i have issue with doing anything with the disk as it says snapshots are their even though they are not. Can you give me the regkey or somehow way to clean it up? thanks my email is ums_5@hotmail.com

  • Anonymous
    October 13, 2010
    I have a virtual machine..I create an snapshot but after something that I did to the vps I delete the snapshot. The problem is the server where the virtual machine hosted was crushed but I have backup of the VM then I created new VM to another server then use the backup for me to have the same VM but all my data after the created and delete the snapshot got lost. I thinking very hard how this was happen. Any help please.  

  • Anonymous
    March 29, 2011
    Thanks for the great info Ben. Your blog is the first place I look for concise, effective info on Windows Virtualization. Great job.

  • Anonymous
    June 07, 2011
    The comment has been removed

  • Anonymous
    May 17, 2012
    Hi, Unfortunately we have reverted one of our VM to old Snapshot, We don’t have new Snapshot. Is there any chance that we can recover our running VM up and running. Please help in this. Thanking you in advance. Thanks & Regards Kishore Varanasi +91 7893226226

  • Anonymous
    August 06, 2013
    Thanks, this info was usefull for me.

  • Anonymous
    November 25, 2015
    How to get active snapshot using powershell and hyper-v module? I don't have SCM.