What you will learn in this tip: Microsoft System Center Virtual Machine Manager is an essential tool for anyone operating a data center with more than a handful of Hyper-V servers. The software can be used for creating, managing, optimizing and provisioning virtual machines across the entire organization. Learn how to back up Virtual Machine Manager in this tip, and how to perform a manual and a scripted backup.
Even though virtual machines reside on Hyper-V servers, System Center Virtual Machine Manager makes use of a SQL Server database that contains all of the configuration data used by Virtual Machine Manager. This SQL Server database can be backed up by using the SQL Server Management Studio or by using any backup application that supports SQL Server backup. It is also possible, however, to back up the server by using tools that are native to System Center Virtual Machine Manager. You would only do this if you didn’t have a backup solution in place, or if you needed to do a quick export of the configuration data.
Before I show you how to back up System Center Virtual Machine Manager, I need to point out that these backup techniques cannot be used to write a backup to a root directory because of software limitations. Furthermore, the service account under which SQL Server is running must have read/write access to the backup directory.
Performing a manual backup
There are two main techniques for backing up System Center Virtual Machine Manager. The first of these techniques involves performing a manual backup through the administrative console. To do so, switch to Administration view and click the Back Up Virtual Machine Manager link, found in the Actions pane, as shown in the figure below (click on image for full size). After doing so, you will be prompted to enter a backup path, as shown in Figure 2. Simply enter a non-root path that your SQL Server has access to and the server will be backed up.
Figure 1: Click the "back up Virtual Machine Manager" link
Click here to enlarge Figure 1.
Figure 2: Enter a path for the backup
The other technique that you can use to back up your Virtual Machine Manager server is to use a PowerShell script. The advantage of using a PowerShell script is that scripts can be automated and set to run at specific dates and times. To do so, you will have to enter two separate commands. These commands can be entered manually, or you can save them to a text file with a PS1 extension so they can be used as a PowerShell script. The commands that you will have to use are Virtual Machine Manager-specific, so you will have to load the Virtual Machine Manager extensions for PowerShell.
The easiest way to do this is to click the Start button and choose the All Programs | Microsoft System Center | Virtual Machine Manager 2008 | Windows PowerShell – Virtual Machine Manager commands from the Start menu.
The commands used for backing up the server are:
$VMMServer = Get-VMMServer –ComputerName “<Your server’s FQDN>”
Backup-VMMServer –Path “C:\VMMBackups” –VMMServer $VMMServer
You can see how these commands work in Figure 3 below.
Figure 3: Backing up Virtual Machine Manager using PowerShell commands
If you choose to turn these commands into a PowerShell script, then it's important to remember Windows blocks PowerShell scripts from running. You can enable PowerShell scripts by setting the server’s execution policy to Unrestricted. To do so, enter the following command:
Restoring the Virtual Machine Manager Database
Microsoft provides a command line utility in System Center Virtual Machine Manager 2008 R2 that can be used to restore the database (this utility does not exist in the 2008 version). You would normally only do this if you needed to rebuild the server after a database crash or a hard disk failure. Assuming that you are restoring the database to the same server on which the backup was made, you will have to do a bit of housekeeping before performing the restoration. Essentially you will have to revert the server to its previous state this means that you must:
- Remove any hosts that were created since the backup was made.
- Add back any hosts that have been removed since the backup was created.
- Remove any virtual machines that were removed since the backup was created.
If you can’t perform these actions due to logistical issues, you can still restore the backup, but you will see messages such as "Needs Attention," "Missing" or "Host Not Responding" in relation to any mismatches that may exist.
To restore the backup, follow these steps:
- Open a command prompt window
- Go to: C:\Program Files\Microsoft System Center Virtual Machine Manager 2008 R2\bin
- Enter: SCVMRecover –Path <backup location> -Confirm
If you are already backing up other SQL Servers, then the easiest way to back up System Center Virtual Machine Manager will probably be to use the same approach that you're already using for your other SQL Servers. However, if you want to perform a quick manual backup or if you lack a SQL-aware backup application then the methods that I have discussed will work well in a pinch.
About the author: Brien M. Posey, MCSE, has previously received Microsoft's MVP award for Exchange Server, Windows Server and Internet Information Server (IIS). Brien has served as CIO for a nationwide chain of hospitals and was once responsible for the Department of Information Management at Fort Knox. You can visit Brien's personal website at www.brienposey.com.