Welcome to TechNet Blogs Sign in | Join | Help

CLI: Grow your replica and shadow copy volume sizes automatically!

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 build
Disconnect-DPMServer $dpmservername

"Exiting from script"
--------------------------------- End of script ---------------------------------------

- Kapil Malhotra

Published Tuesday, July 10, 2007 12:38 PM by dpm

Comments

Tuesday, July 10, 2007 8:27 AM by ruudb

# re: CLI: Grow your replica and shadow copy volume sizes automatically!

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

Friday, July 20, 2007 7:29 AM by mohdabubakr

# re: CLI: Grow your replica and shadow copy volume sizes automatically!

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.

Friday, March 28, 2008 3:57 PM by GradonSilverton

# re: CLI: Grow your replica and shadow copy volume sizes automatically!

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.

Anonymous comments are disabled
 
Page view tracker