When you run production services within virtual machines (VMs), you need to make sure the VMs are protected at all times. There are several ways to protect VMs, and the method you use will depend on the hypervisor you run.
One of the great advantages of running virtual machines on Microsoft Hyper-V is that Hyper-V always includes a parent partition that runs a full copy of Windows Server 2008. This gives you access to Windows Server 2008 features — features that can help protect your VMs.
One of these features is the Windows Server Volume Shadow Copy Service (VSS). Each disk drive in Windows Server 2008 can protect the contents of shared folders through the use of VSS snapshots that are created on a regular schedule. Windows Server 2008 supports up to 512 snapshots before it needs to overwrite them. If you store your VMs on a Windows Server file share, then you can rely on VSS to capture regular VSS snapshots of the VMs.
Don't confuse Volume Shadow Copy Service snapshots with Hyper-V snapshots. When you take a Hyper-V snapshot, it automatically converts the VHD into a differencing disk and creates a parent-child relationship between the disks. Although this is a good way to retain a specific image of a VM, it is not a good way to perform virtual machine backups because it transforms the VM's disks. Note that Microsoft does not recommend using Hyper-V snapshots on VMs running certain Windows workloads. Active Directory Domain Services is an example of this, because it can potentially cause the VM to break.
VSS snapshots, on the other hand, provide a disk image of the state of a VM and rely on this disk image to perform a backup. VSS snapshots are application-specific and maintain the consistency of VM data during the backup operation without modifying the VM's virtual disk structure.
In Windows Server, each drive that is attached to a server is shared by default as \\servername\Drive$. This share is a hidden share — because of the attached $ sign — but it is always generated automatically. This means that you do not need to create a share for the disks or folders that contain VM files because the share already exists -- and because the share exists, you can use VSS snapshots on it. To do so, proceed as follows:
Ideally, you will be able to prepare the host server by adding an additional volume. This volume will be used to store all of its VSS snapshots. Because each snapshot is 300 MB in size and you want to store 512 of them, your volume should be about 180 GB. You can double that if you need to protect two different data volumes.
Enable VSS for the data volume or the volume containing the VM files. VSC is a property of a disk volume in Windows Server. To enable it, open Windows Explorer, locate the data drive, right-click it and select Configure Shadow Copies. Accept the User Account Control prompt if it appears.
Now you need to specify VSS settings. In the Shadow Copies dialog box, click the Settings button. In the Settings dialog box, use the drop-down list to select the new drive you added to store the snapshots (see Figure 1). Set the limit for the copy as appropriate (the default should be fine).
Change the schedule if it's required. Begin with the default schedule at first; you can always change it later. By default, snapshots are created every weekday at 7:00 a.m. and 12:00 p.m. Click OK when done.
Make sure you select the data volume you want to protect and click Enable to turn on VSS for this volume. A warning will appear (see Figure 2). You can safely discard this warning because you just set the configuration for your snapshots. Click Yes.
VSS will now automatically generate two snapshots per day for this volume. Repeat the operation for any other volume you want to protect.
In the event of a mishap, you can now rely on the Previous Versions client to restore lost files and folders or the files that make up a VM (see Figure 3). You can therefore rely on this tool to recover lost VMs on a Hyper-V host. The Previous Versions client is built into Windows Vista, Windows 7 and Windows Server 2008. It must be installed on older versions of Windows. You'll find it in the %SystemRoot%\System32\Clients folder on Windows Server 2003 installations. The installation file is named TWCLI32.msi.
Previous Versions is a feature of the properties of a file in Windows. Simply right-click the object (file or folder) and select Restore Previous Versions to recover the content you lost. This is a powerful OS feature and one that Hyper-V simply inherits because it runs the operating system in its parent partition.
You can open, copy or restore the contents of a snapshot. This lets you restore any component of a virtual machine. In a way, it provides the same feature as the Hyper-V snapshot utility, but it gives you 512 snapshots instead of 50 and doesn't turn the VHD into a differencing disk.
Still, you should be very careful when using Previous Versions to restore virtual machine files. Ideally, you will use this for data disks only. You can use it to restore an entire virtual machine, but use caution. Production VMs and virtual machines running complex, time-based processes such as domain controllers are not good candidates for Previous Versions restores. Machines that contain all services in one VM, such as Windows Small Business Server, can be restored with this method because everything is contained in one computer.
The VSS backup method is very useful for test and development environments but should be used with care on production VMs. For more information on this and other protection mechanisms for Hyper-V VMs, check out MCTS Self-Paced Training Kit (Exam 70-652): Configuring Windows Server Virtualization.
ABOUT THE AUTHOR
Danielle Ruest and Nelson Ruest are IT professionals focused on technology futures. Both are passionate about virtualization and continuous service availability. They are authors of multiple books, including MCTS Self-Paced Training Kit (Exam 70-652): Configuring Windows Server Virtualization. for MS Press as well as Virtualization, A Beginner's Guide and Windows Server 2008: The Complete Reference for McGraw-Hill Osborne. Feel free to contact them at email@example.com for any comments or suggestions.
This was first published in August 2009