System Center Data Protection Manager 2010

 

Recently we have written a blog on using scripts to help you automatically protect new Virtual Machines in you environment, on your Primary DPM server. With some of our customers using it successfully already we have received requests for similar scripts to automatically protect new Virtual Machines on the Secondary DPM server.

This blog post aims to further simplify your protection tasks by automating the process of adding new VMs that are added in your primary DPM server, to be protected on the secondary DPM server as well. 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 on the secondary DPM.

 

Download Scripts:  AddNewClusteredVMToDRServer.ps1  and AddNewStandAloneVMToDRServer.ps1

 

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

These scripts work in a manner similar to the ones used to add VMs to the Primary DPM Server, AddNewClusteredVM.ps1 and AddNewStandAloneVM.ps1. The only difference is that they take an additional parameter that is theFQDN of the primary DPM server. If you know how these scripts work, you may skip reading the rest of the blog post and go back to use the new scripts right away.

The attached scripts automate the task of adding any new Hyper-V virtual machines recognized in the primary DPM server, into existing protection groups. There are different scripts for VMs from a Hyper-V cluster (AddNewClusteredVMToDRServer.ps1) and from a standalone Hyper-V host (AddNewStandAloneVMToDRServer.ps1). You would still use the script for standalone servers to automatically protect on the Secondary DPM server, 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 on the Secondary DPM

The script for standalone servers (AddNewStandAloneVMToDRServer.ps1) takes as input the following three 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 on the secondary DPM to which we are adding the new virtual machines. Protection Group 3
Primary DPM Server Name Fully Qualified Domain Name of the Primary DPM server. dpm-server01.contoso.com

 

The script performs the following tasks:

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

2. Searches for the protected server, the protection group on the secondary DPM server and the primary DPM server.

3. Runs inquiry on the Primary DPM Server and 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

Protection Group 3 - replace this with the name of the protection group on the Secondary DPM.

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

PS C:\Program Files\Microsoft DPM\DPM\bin> .\AddNewStandAloneVMToDRServer.ps1 hyperv01.contoso.com "Protection Group 3" dpm-server01.contoso.com

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 on the Secondary DPM

The script for clustered servers (AddNewClusteredVMToDRServer.ps1) takes as input the following three 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 on the secondary DPM to which we are adding the new virtual machines. Protection Group 2
Primary DPM Server Name Fully Qualified Domain Name of the Primary DPM server. dpm-server01.contoso.com

 

The script performs the following tasks:

1. Takes FQDN of protected cluster, name of protection group and FQDN of the primary DPM server as input.

2. Searches for the protected cluster, the protection group and the primary DPM server.

3. Runs inquiry on the primary DPM server and 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 AddNewClusteredVMToDRServer.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

Protection Group 2 - replace this with the name of the protection group on the Secondary DPM.

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

PS C:\Program Files\Microsoft DPM\DPM\bin> .\AddNewCLusteredVMToDRServer.ps1 csv01.contoso.com "Protection Group 2" dpm-server01.contoso.com

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)