Description
Creates a protection group, with disk-based protection, for a simple folder. It can be extended to different data sources like Microsoft Exchange, SQL, SharePoint, system state or virtual servers. The synchronization frequency and retention ranges can be modified to suit different needs.
Because the script protects a sub-folder in a volume, the code uses the CalculateSize parameter in Get-DataSourceDiskAllocation; this calculates the exact size needed for all the items in that folder. This parameter is not needed when protecting an application like Exchange/SQL or protection the entire file system volume.
This script was contributed by the System Center Data Protection Manager (DPM) team.
Supported Platforms
Windows Server 2003 | Yes, with Service Pack 1 |
Windows XP | No |
Windows 2000 | Yes, with Service Pack 4 |
Windows NT 4.0 | No |
Windows 98 | No |
Script Code
# To D2D create PG and do the initial replication
# This script is for creating Disk to Disk PG for File System
# For details contact mukuls[at]microsoft[dot]com
# Create a .ps1 file with this script and run under DPM Management Shell
# Customize these values as per your environment
$dpmname = "DPMServername.somedomain.com"
$psname = "PSservername.somedomain.com"
$dsname = "G:\"
$poname = "G:\ProtectableFolder"
$pgname = "MyCLIPG"
function CreatePG
{
param($dpmname, $psname, $dsname, $poname, $pgname)
write-host "Creating a D->D PG --> $pgname..."
trap{"Error in execution... ";break}
&{
Write-Host "Getting PS: $psname from DPM: $dpmname"
$ps = Get-ProductionServer -DPMServerName $dpmname | where { ($_.machinename,$_.name) -contains $psname }
Write-Host "Running Inquiry on PS: $psname for datasource $dsname"
$ds = Get-Datasource -ProductionServer $ps -Inquire | where { ($_.logicalpath,$_.name) -contains $dsname }
Write-Host "Getting Child-datasource $poname from datasource $dsname"
$po = Get-ChildDatasource -ChildDatasource $ds -Inquire | where { ($_.logicalpath,$_.name) -contains $poname }
write-host "Create New PG ..."
$pg = New-ProtectionGroup -DPMServerName $dpmname -Name $pgname
write-host "Adding child datasource..."
Add-childDatasource -ProtectionGroup $pg -ChildDatasource $po
write-host "Setting Protection Type..."
Set-ProtectionType -ProtectionGroup $pg -ShortTerm disk
write-host "Setting Policy Objective...retention range - 10Days, synchronizationFrequency 15"
Set-PolicyObjective -ProtectionGroup $pg -RetentionRangeInDays 10 -SynchronizationFrequency 15
write-host "Setting Policy Schedules ..."
$ShadowCopysch = Get-PolicySchedule -ProtectionGroup $pg -ShortTerm| where { $_.JobType -eq "ShadowCopy" }
Set-PolicySchedule -ProtectionGroup $pg -Schedule $ShadowCopysch -DaysOfWeek mo -TimesOfDay 02:00
write-host "Setting Disk Allocation, with optimization (will take a few minutes to complete)"
Get-DatasourceDiskAllocation -Datasource $ds -Calculatesize
Set-DatasourceDiskAllocation -Datasource $ds -ProtectionGroup $pg
write-host "Setting Replica Creation Method ..."
Set-ReplicaCreationMethod -ProtectionGroup $pg -NOW
write-host "Commiting PG"
Set-protectiongroup $pg
}
}
function waitforIRtoComplete
{
param($waittime)
write-host "Wait for IR to complete"
$val = $waittime/30
while($val -gt 0)
{
Write-host "Wait for IR to complete... $val"
start-sleep 30
$val--
}
}
Connect-DPMServer -DPMServerName $dpmname;
createPG $dpmname $psname $dsname $poname $pgname;
waitforIRtoComplete 120;
For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.
Disclaimer
The sample scripts are not supported under any Microsoft standard support program or service. The sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.