At our Kansas City TechNet Event several weeks ago, Chris H. asked:
You don’t, It can’t be done. You must buy our products. Resistance is futile.
“Oh c’mon.. get serious, Kevin.”
Sorry. Okay, I’m sure there are several ways that this can be accomplished. Virtual machines running under Hyper-V are typically really just a few configuration, hard disk, and differencing-disk files. So making a backup, at least at the heart of it all, is really just making a copy of those files. I’ll throw out a few suggested methods here, and if you folks reading this have other ideas or solutions, we’d love to have you share them in the comments. (You should also read the “Planning for Backup” article on TechNet.)
Make a copy of the hard disk files. Really, if you’re not using snapshots (which create additional files in a differencing disk relationship), the easiest way to make a quick, worst-case but simple backup, is to copy the .VHD files from a stopped virtual machine. Restoring would require you to re-create the machine and configure it to use the hard disk files.
Export the virtual machine. This is something that I do regularly. It takes some time, but you can make an importable copy of many virtual machines at once by using the Hyper-V Manager. What you end up with is a set of files that can be copied to a new location and easily imported.
- Shut down the virtual machine
- Export the Virtual Machine and/or Copy the .VHD files
- Start the virtual machine
A most-excellent starting point for learning how to use scripting of PowerShell and WMI for Hyper-V is found on Ben Pearce’s blog, in THIS POST HERE.
NOTE: This is going to become a whole lot (and I mean a WHOLE LOT) easier to do with the included PowerShell cmdlets in the next version of Windows Server coming later this year, and in beta very soon.
Use Windows Server Backup. You can register the Microsoft Hyper-V VSS writer with Windows Server Backup, and then use this to backup running virtual machines. And to, of course, restore them if needed. Read “How to back up Hyper-V virtual machines from the parent partition on a Windows Server 2008-based computer by using Windows Server Backup” for learning all about to back-up Hyper-V virtual machines from the parent partition on a… you get the idea.
Treat it like any other machine. If you treat it with the same love and respect as you to any other server, one option is to treat it as if it were a physical server – complete with backup agents installed into it, and using some enterprise class backup and archiving solution. It all depends upon the purpose of the server, the business applications and/or data housed therein, the ease with which you want to be able to recreate the server, etc.
“But what about ‘snapshots’? Aren’t those a good way to keep a backup?”
(READ THIS if you’d like to know more about Hyper-V Snapshots.)
No, they’re not a backup. Oh sure, they’re a way to maintain a point-in-time in cases where you may need to jump back (or ahead). I regularly use them as a kind of mile-marker during complex installations and configurations while I’m learning a new product or technology, so that I can go back to where A) I have a clean install of Windows with all current updates, or B) this is where I have SQL installed, or C) here is where the product was freshly installed, but not yet configured.. etc. For complex demonstrations I’ll use snapshots to jump ahead to a point in time after an ordinarily long process that I’m showing has completed. (The cooking show demo, where you immediately and magically pull the completely baked cake out of the oven.)
But for backup? No. Every snapshot you take adds additional disk space being consumed, plus additional overhead as the running OS has to refer to more and more files that represent the running hard disks.
One additional note about virtual machine backups: Remember that there is more to the machine running on a new server than just the VM files. The networking configuration needs to be taken into account. It’s not something that can’t be overcome without a little extra work, but it’s just annoying to import or restore a virtual machine to a new VM host only to find that you don’t recall how the networking was configured that made it work properly. That “Planning for Backup” article I referred to earlier goes into this in greater detail.
How are you doing VM backups and restores? Got any tips or tools or ideas to share? Any horror stories that we can all learn from? We’d love to hear about them in the comments!