Hyper-V Protection with DPM 2010 Beta - How to automatically protect new Virtual Machines
Published Feb 15 2019 01:34 AM 1,199 Views
First published on TECHNET on Dec 03, 2009

We had a great question come into the DPM Newsgroup recently. How do I automatically protect new VMs added to a Hyper-V host using DPM?

In any virtualized environment, adding new VMs is a frequent operation. While backup administrators can protect an entire Hyper-V host using the DPM Management Console, the protection group had to be modified manually to include the new virtual machines that have come up on the Hyper-V host.

This blog post aims to make this an automated task by adding new virtual machines to protection on the given Hyper-V hosts using simple PowerShell scripts. These scripts are expected to work with DPM 2010 Beta. By using the information in this blog post, you should be able to quickly put together a script that can enable the auto protection of your hyper-v hosts.

Download Scripts : AddNewClusteredVM.ps1 and AddNewStandAloneVM.ps1

Note: These scripts work on an existing protection group and do not create a fresh protection group.

The attached scripts automate the task of adding any new virtual machines recognized in the Hyper-V hosts protected by the DPM server into existing protection groups. There are different scripts for Hyper-V clusters ( AddNewClusteredVM.ps1 ) and standalone Hyper-V hosts ( AddNewStandAloneVM.ps1 ). You would still use the script for standalone servers to automatically protect the non-clustered virtual machines of any Hyper-V host that is part of a cluster.

Let us now walk you through the scenario and the scripts...

Walk Through

Protecting standalone Hyper-V hosts

The script for standalone servers ( AddNewStandAloneVM.ps1 ) takes as input the following two values in order:

Variable Explanation Example
Server Name Fully Qualified Domain Name of the Hyper-V host server. hyperv01.contoso.com
Protection Group Name of the existing protection group to which we are adding the new virtual machines. Protection Group 3

The script performs the following tasks:

1. Takes FQDN of protected server and name of protection group as input.

2. Searches for the protected server and the protection group.

3. Runs inquiry on the Hyper-V host and obtains the list of unprotected virtual machines.

4. Adds the obtained list of virtual machines to the protection group.

5. Saves the changes to the protection group and exits.

Example usage:

This example takes the following values as inputs:

hyperv01.contoso.com – replace this with the name of your Hyper-V host

dpm-server01.contoso.com – replace this with the name of your DPM server

PS C:\Program Files\Microsoft DPM\DPM\bin> .\AddNewStandAloneVM.ps1 hyperv01.contoso.com "Protection Group 3"

Name                                                     Domain

----                                                         ------

dpm-server01.contoso.com                CONTOSO.COM

Running Inquiry on hyperv01.contoso.com

Adding data source Backup Using Child Partition Snapshot\StandaloneVM to Protection Group 3

Adding new Hyper-V data sources to Protection Group 3

Exiting from script

Protecting Hyper-V clusters

The script for clustered servers ( AddNewClusteredVM.ps1 ) takes as input the following two values in order:

Variable Explanation Example
Cluster Name Fully Qualified Domain Name of the Hyper-V cluster. csv01.contoso.com
Protection Group Name of the existing protection group to which we are adding the new virtual machines. Protection Group 2

The script performs the following tasks:

1. Takes FQDN of protected cluster and name of protection group as input.

2. Searches for the protected cluster and the protection group.

3. Runs inquiry on the cluster to get the list of resource groups.

4. Runs parallel inquiry for each resource group and obtains the list of unprotected virtual machines under them.

5. Adds the unprotected virtual machines to the protection group.

6. Saves the changes to the protection group and exits.

The difference in this script is in Step 3 & 4 in AddNewClusteredVM.ps1 where we run inquiry on the cluster to get the list of resource groups, followed by inquiry on the resource groups. Also, inquiry on resource groups is run in parallel unlike what we do for standalone servers. We run inquiry in parallel for the cluster to avoid a performance overhead. Such an overhead is not seen for standalone servers.

Example usage:

This example takes the following values as input:

csv01.contoso.com – replace this with the name of your Hyper-V cluster

dpm-server01.contoso.com – replace this with the name of your DPM server

PS C:\Program Files\Microsoft DPM\DPM\bin> .\AddNewCLusteredVM.ps1 csv01.contoso.com "Protection Group 2"

Name                                                     Domain

----                                                        ------

dpm-server01.contoso.com                CONTOSO.COM

Running Inquiry on csv01.contoso.com

Running Inquiry on Cluster Group

Running Inquiry on Available Storage

Running Inquiry on SQLLoadVM

Running Inquiry on SharepointLoadVM

Running Inquiry on Win7VM

Waiting for inquiry to complete 0 item(s) obtained...

.

Waiting for inquiry to complete 1 item(s) obtained...

.

.

Waiting for inquiry to complete 5 item(s) obtained...

Inquiry listed 5 item(s)...

Adding data source Backup Using Child Partition Snapshot\Win7VM to Protection Group 2

Adding new Hyper-V data sources to Protection Group 2

Exiting from script

You can now write a batch file to call the above scripts one after the other and schedule it using the Windows Task Scheduler to run as frequently as needed.

Important:

· Shared disks that may be listed under the resource groups of your Hyper-V cluster are not Hyper-V data sources, and are not considered for automatic addition using this script.

· Any new virtual machines that are finally added to a protection group are scheduled for immediate replica creation, overriding any existing protection group behavior. You may modify the respective script to change this after referring the specific cmdlet help option.

-- Angad Pal Singh | DPM Team (Author)

Version history
Last update:
‎Mar 11 2019 08:19 AM
Updated by: