One of the topics at our Hyper-V FAQs, Tips, and Tricks discussion at TechEd was that of checkpoints and snapshots, and whether they should be used in production or not, as well as the gotchas that one may come across when using them.
Snapshots versus Checkpoints
First, I have to mention that snapshots and checkpoints are the same thing. Hyper-V calls them snapshots, and System Center Virtual Machine Manager calls them checkpoints. When you make a checkpoint in VMM, it actually creates a snapshot in Hyper-V. When you create a snapshot from Hyper-V, you’ll see it in the VMM console as a checkpoint. With that out of the way, let’s discuss what they are for, and when you night use one.
What are snapshots and when/why should I use them?
Snapshots are representations of a virtual machine at the point of time from which the snapshot was taken. They are most useful when you’re about to make a change which you might want to quickly roll back. You can take a snapshot, make your change, and then revert back to your previous state. One of the most common scenarios is in doing software sequencing with something like App-V. You can take a snapshot of your VM, sequence the installation of your software, copy the results off of the machine, and then roll back. However, snapshots are not to be used for backup purposes. Snapshots don’t behave the same way a backup would behave, and traditional backups may likely need to be used, depending on your scenario (either SAN level or from something like System Center Data Protection Manager).
When/why should I not use them? What are the “gotchas”?
Though snapshots are a valuable tool, there a few things to be aware before you ever start using snapshots. Knowing these few things will save you a lot of grief and wasted time in the future:
- Machine rollbacks can cause Active Directory connection problems
- Leaving machines running for an extended period of time after a snapshot can use up significant disk space
- Merging snapshots into existing VM can take many hours, during which the VM has to remain offline to complete the merge
Rollback to previous snapshot can cause Active Directory Password problems
The first thing to be aware of is that computers have a unique machine account password within Active Directory that by default changes every 30 days for security reasons. If the password changes between the time you take the snapshot and the time you want to rollback, you’ll break the computer’s access to Active Directory when you revert to the snapshot. This will in turn cause you to lose the ability to login to your VM with any domain credentials unless they were previously cached. Once you find yourself in this state, you need to login via a local account or account with cached credentials and unjoin/rejoin the computer from the domain.
To prevent this automatic password change from occurring, you can disable the automatic password reset by following the steps within Microsoft KB 154501 (thanks to Aaron Sudduth for the live link during the session). Once you flip the registry key, you can safely revert without having to worry about whether the machine is in sync with AD, since it will permanently keep the same machine account password. (This would apply to a traditional backup as well – anything which brings the VM back to a previous point in time.)
Snapshots, AVHD, and disk space
Once you take a snapshot of your VM, all of the VMs future writes will be written to a differencing disk (AVHD) rather than your original VHD. This means that over time, the AVHD will continue to grow indefinitely, even if space inside the VM isn’t growing, but is merely changing alot. If you’re leaving this machine up for years, it’s only a matter of time before you eventually run out disk space. At that point, you have to make the decision to power down the VM and merge the snapshot into the current VM, which brings me to my final point.
Merging snapshots can mean hours of downtime
In the current version of Hyper-V, the only way you can merge the AVHD back into a VHD is by deleting your original snapshot and powering off the VM, and then waiting for Hyper-V to merge the files. Depending on the speed of your storage, and size of the AVHD, this can take minutes, hours, or days. In general, you don’t have days of time that you can wait for AVHDs to merge, which means you don’t want to get yourself into the situation to begin with.
So the moral of the story is: feel free to use snapshots and checkpoints, but only for VMs that need to be rolled back regularly, and which won’t be left on for really long periods of time after the snapshot is taken. If you actually want to keep a pristine copy of your VM for months or years, use a traditional backup instead. You can do a SAN-level snapshot, a DPM backup, or a simple file copy of your VHD to external storage.
Good luck, and happy virtualizing!