Using checkpoints to revert virtual machines to a previous state
One of the great benefits to virtualization is the ability to easily save the state of a virtual machine. In Hyper-V this is done through the use of virtual machine checkpoints. You may want to create a virtual machine checkpoint before making software configuration changes, applying a software update, or installing new software. If a system change were to cause an issue, the virtual machine can be reverted to the state at which it was when then checkpoint was taken.
Windows 10 and 11 Hyper-V includes two types of checkpoints:
Standard Checkpoints: takes a snapshot of the virtual machine and virtual machine memory state at the time the checkpoint is initiated. A snapshot is not a full backup and can cause data consistency issues with systems that replicate data between different nodes such as Active Directory. Hyper-V only offered standard checkpoints (formerly called snapshots) prior to Windows 10.
Production Checkpoints: uses Volume Shadow Copy Service or File System Freeze on a Linux virtual machine to create a data-consistent backup of the virtual machine. No snapshot of the virtual machine memory state is taken.
Production checkpoints are selected by default however this can be changed using either Hyper-V manager or PowerShell.
Note
The Hyper-V PowerShell module has several aliases so that checkpoint and snapshot can be used interchangeably.
This document uses checkpoint, however be aware that you may see similar commands using the term snapshot.
Changing the Checkpoint Type
Open Hyper-V Manager.
Right-click on a virtual machine and select settings.
Under Management select Checkpoints.
Select the desired checkpoint type.
Creating checkpoints
Creates a checkpoint of the type configured for the virtual machine. See the Configuring Checkpoint Type section earlier in this document for instructions on how to change this type.
To create a checkpoint:
In Hyper-V Manager, select the virtual machine.
Right-click the name of the virtual machine, and then click Checkpoint.
When the process is complete, the checkpoint will appear under Checkpoints in the Hyper-V Manager.
Applying checkpoints
If you want to revert your virtual machine to a previous point-in-time, you can apply an existing checkpoint.
In Hyper-V Manager, under Virtual Machines, select the virtual machine.
In the Checkpoints section, right-click the checkpoint that you want to use and click Apply.
A dialog box appears with the following options:
- Create Checkpoint and Apply: Creates a new checkpoint of the virtual machine before it applies the earlier checkpoint.
- Apply: Applies only the checkpoint that you have chosen. You cannot undo this action.
- Cancel: Closes the dialog box without doing anything.
Select either Apply option to create apply the checkpoint.
Renaming checkpoints
Many checkpoints are created at a specific point. Giving them an identifiable name makes it easier to remember details about the system state when the checkpoint was created.
By default, the name of a checkpoint is the name of the virtual machine combined with the date and time the checkpoint was taken. This is the standard format:
virtual_machine_name (MM/DD/YYY -hh:mm:ss AM\PM)
Names are limited to 100 characters, and the name can't be blank.
In Hyper-V Manager, select the virtual machine.
Right-click the checkpoint, and then select Rename.
Enter in the new name for the checkpoint. It must be less than 100 characters, and the field cannot be empty.
Select ENTER when you are done.
Deleting checkpoints
Deleting checkpoints can help create space on your Hyper-V host.
Behind the scenes, checkpoints are stored as .avhdx files in the same location as the .vhdx files for the virtual machine. When you delete a checkpoint, Hyper-V merges the .avhdx and .vhdx files for you. Once completed, the checkpoint's .avhdx file will be deleted from the file system.
You should not delete the .avhdx files directly.
To cleanly delete a checkpoint:
In Hyper-V Manager, select the virtual machine.
In the Checkpoints section, right-click the checkpoint that you want to delete and select Delete. You can also delete a checkpoint and all subsequent checkpoints. To do so, right-click the earliest checkpoint that you want to delete, and then select Delete Checkpoint Subtree.
You might be asked to verify that you want to delete the checkpoint. Confirm that it is the correct checkpoint, and then select Delete.
Exporting checkpoints
Export bundles the checkpoint as a virtual machine so the checkpoint can be moved to a new location. Once imported, the checkpoint is restored as a virtual machine. Exported checkpoints can be used for backup.
Export-VMCheckpoint -VMName <virtual machine name> -Name <checkpoint name> -Path <path for export>
Enable or disable checkpoints
In Hyper-V Manager, right-click the name of the virtual machine, and select Settings.
In the Management section, select Checkpoints.
To allow checkpoints to be taken off this virtual machine, make sure Enable Checkpoints is selected -- this is the default behavior. To disable checkpoints, deselect the Enable Checkpoints check box.
Select Apply to apply your changes. If you are done, select OK to close the dialog box.
Configure checkpoint location
If the virtual machine has no checkpoints, you can change where the checkpoint configuration and saved state files are stored.
In Hyper-V Manager, right-click the name of the virtual machine, and select Settings.
In the Management section, select Checkpoints or Checkpoint File Location.
In Checkpoint File Location, enter the path to the folder where you would like to store the files.
Select Apply to apply your changes. If you are done, select OK to close the dialog box.
The default location for storing checkpoint configuration files is: %systemroot%\ProgramData\Microsoft\Windows\Hyper-V\Snapshots
.
Using standard checkpoints
This exercise walks through creating and applying a standard checkpoint versus a production checkpoint. For this example, you'll make a simple change to the virtual machine and observe the different behavior.
Create a standard checkpoint
Log into your virtual machine and create a text file on the desktop.
Open the file with Notepad and enter the text ‘This is a Standard Checkpoint.’ Do not save the file or close Notepad.
Change the checkpoint to standard. Follow the instructions in changing the checkpoints.
Create a new checkpoint.
Apply the standard checkpoint with Hyper-V Manager
Now that a checkpoint exists, make a modification to the virtual machine and then apply the checkpoint to revert the virtual machine back to the saved state.
Close the text file if it is still open and delete it from the virtual machine's desktop.
Open Hyper-V Manager, right-click on the standard checkpoint, and select Apply.
Select Apply on the Apply Checkpoint notification window.
Once the checkpoint has been applied, notice that not only is the text file present, but the system is in the exact state that it was when the checkpoint was created. In this case Notepad is open and the text file loaded.
Using production checkpoints
Let’s now examine production checkpoints. This process is almost identical to working with a standard checkpoint, however will have slightly different results. Before beginning make sure you have a virtual machine and that you have changes the checkpoint type to Production checkpoints.
Modify the virtual machine and Create a Production Checkpoint
Log into the virtual machine and create a new text file. If you followed the previous exercise, you can use the existing text file.
Enter ‘This is a Production Checkpoint.’ into the text file, save the file but do not close Notepad.
Open Hyper-V Manager, right-click on the virtual machine, and select Checkpoint.
Select OK on the Production Checkpoint Created Window.
Apply the Production Checkpoint with Hyper-V Manager
Now that a checkpoint exists make a modification to the system and then apply the checkpoint to revert the virtual machine back to the saved state.
Close the text file if it is still open and delete it from the virtual machine's desktop.
Open Hyper-V Manager, right click on the production checkpoint, and select Apply.
Select Apply on the Apply Checkpoint notification window.
Once the production checkpoint has been applied, noticed that the virtual machine is in an off state.
Start and log into the virtual machine.
Take note that the text file has been restored. But unlike the standard checkpoint, Notepad is not open.