How cool would it be, if we could schedule a nightly task that automatically grows your replica and shadow copy storage volume sizes, and in turn help the protection SLA to be good for the rest of the week!
The script below does exactly the same. Save it as a powershell script (.ps1) and add it to Windows Scheduler to achieve this magic.
--------------------------------- Start of script -------------------------------------
#This DPM powershell script helps automate the growing of replica and shadow copy volumes which need to be grown.#You can edit the below constants which can help you configure how much you want to grow the volumes by each time
$ReplicaThreshold = 500MB$SCThreshold = 1GB$ReplicaGrowBy = 5GB$SCGrowBy = 5GB
#End of Constants
$dpmservername = &"hostname"
# The cmdlet below is called Connect-Serverin the DPM v2 Beta2 build$dpmserver=Connect-DPMServer $dpmservername
if(!$dpmserver){ write-error "Unable to connect to $dpmservername" exit 1}
$PGList = @(Get-ProtectionGroup $dpmservername)
foreach($PG in $PGList){
# The cmdlet below is called Modify-ProtectionGroup in the DPM v2 Beta2 build $MPG = Get-ModifiableProtectionGroup $PG
$dslist=@(get-datasource $MPG) foreach ($ds in $dslist) { if(($ds.ReplicaSize - $ds.ReplicaUsedSpace) -lt $ReplicaThreshold) { "Need to grow replica for $($ds.Name) on $($ds.ProductionServerName)" $NewReplicaSize = $ds.ReplicaSize + $ReplicaGrowBy Set-DatasourceDiskAllocation -Manual -Datasource $ds -ProtectionGroup $MPG -ReplicaArea
$NewReplicaSize } else { $ReplicaFreeSpace = $ds.ReplicaSize - $ds.ReplicaUsedSpace $ReplicaFreeSpace /= 1MB "Replica for $($ds.Name) on $($ds.ProductionServerName) does not need to grow and has
$ReplicaFreeSpace MB free" } if($ds.ShadowCopyAreaSize - $ds.ShadowCopyUsedSpace -lt $SCThreshold) { "Need to grow recovery point volume for $($ds.Name) on $($ds.ProductionServerName)" $NewSCSize = $ds.ShadowCopyAreaSize + $SCGrowBy Set-DatasourceDiskAllocation -Manual -Datasource $ds -ProtectionGroup $MPG -ShadowCopyArea
$NewSCSize } else { $SCFreeSpace = $ds.ShadowCopyAreaSize - $ds.ShadowCopyUsedSpace $SCFreeSpace /= 1MB "Recovery Point volume for $($ds.Name) on $($ds.ProductionServerName) does not need to grow and has
$SCFreeSpace MB free" } } # The cmdlet below is called Save-ProtectionGroup in the DPM v2 Beta2 build Set-ProtectionGroup $MPG
}
# The cmdlet below is called Disconnect-Server in the DPM v2 Beta2 buildDisconnect-DPMServer $dpmservername
"Exiting from script"--------------------------------- End of script ---------------------------------------
- Kapil Malhotra
Hi,
Very cool but I like to place 1 remark;
This is perfect as a guard but should not be encouraged as a 'daily thin provisioning' strategy rather than appropriate sizing up-front.
Cheers
Ruud
Hi Kapil,
I understand that the script blindfoldedly increases the Allocated Replica Size and Allocated Shadow copy area size if it doesn't meet the threshold value. Have you tested for the senarios where the disk space available doesn't meeet the requirements for allocating extra space ? In such cases,are there any issues with Save-ProtectionGroup and Modify-ProtectionGroup ??
With regards,
Mohd Abubakr.
Appears that there is a error in the Script if you copy it as above.
This Line:
"Set-DatasourceDiskAllocation -Manual -Datasource $ds -ProtectionGroup $MPG -ReplicaArea
$NewReplicaSize"
Needs to Read:
"Set-DatasourceDiskAllocation -Manual -Datasource $ds -ProtectionGroup $MPG -ReplicaArea $NewReplicaSize"
The Extra space caused the script to error out.
It works from within Powershell (IF I remove the '&' in front of the hostname), but when I schedule a task to run it as:
C:\WINDOWS\system32\WINDOW~2\v1.0\powershell.exe -command "& 'GrowRPVs.ps1'"
I get this:
"The term 'Connect-DPMServer' is not recognized as a cmdlet, function, operable
program, or script file. Verify the term and try again.
At C:\Program Files\Microsoft DPM\DPM\bin\GrowRPVs.ps1:17 char:29
+ $dpmserver=Connect-DPMServer <<<< $dpmservername"
That is because you are calling the powershell console without the DPM PS snapin loaded. I use the following code in the beginning of all of my DPM scripts so i can run them through the standard PS console:
if (!(Get-PSSnapin microsoft.dataprotectionmanager.powershell))
{
write-host "Adding PS Snapin for DPM..." -Fore Green
add-PSSnapin Microsoft.DataProtectionManager.PowerShell}
This will check to see if the snapin is loaded, and if not, load it.
Check out this article for more detail on running DPM scripts outside of the DPM management shell and scheduling them to run:
http://0direction.com/blog/index.php/2008/10/31/running-dpm-scripts-outside-of-the-dpm-management-shell/
When running I receive the following Error:
Set-DatasourceDiskAllocation : Missing an argument for parameter 'ShadowCopyAre
a'. Specify a parameter of type 'System.Int64' and try again.
At C:\Program Files\Microsoft DPM\DPM\bin\extend_DPM_disk.ps1:53 char:95
+ Set-DatasourceDiskAllocation -Manual -Datasource $ds -ProtectionGroup $MP
G -ShadowCopyArea <<<<
8178892800
Performing general administrative DPM tasks can be quite time consuming so why not get Operations Manager
I cant seem to get this to work on system state datasources, works on file based. Is there something special that needs to be done to get system states to work?