Pruning DPM Replicas

There are times when, as a DPM administrator, you might want to prune disk-based replicas of data sources, either to save space or because of another reason entirely. As we’re currently experiencing an issue with DPM 2016 CU4 whereby replicas of filesystem data (disks/volumes/directories/shares) aren’t being pruned (the maintenance task calls a SQL procedure with too many arguments when removing these replicas resulting in a crash) I wrote this script to help delete replicas of other types of data that weren’t being cleared up because of these crashes:

Clear-Host
Import-Module DataProtectionManager

$DPMServerName = Read-Host "Enter DPM Server Name"
$Dte = Read-Host "Enter cutoff date (mm/dd/yyyy)"
$pg = Get-ProtectionGroup -DPMServerName $DPMServerName

Write-Host "Available Protection Groups:" -foreground "magenta"
for($i=0; $i-le $pg.length-1; $i++)
{
Write-host "$i - $($pg[$i].FriendlyName)"
}

$ProtectionGroup = Read-Host "Enter the number of the group to process"
$ds = Get-Datasource -ProtectionGroup $pg[$ProtectionGroup]

Clear-Host
Write-Host "Protection Group Data Sources:" -foreground "magenta"

for($i=0; $i-le $ds.length-1; $i++)
{
Write-Host "$i - $($ds[$i].Name) on $($ds[$i].Computer)"
}
Write-Host "A - Process all datasources"

$Datasource = Read-Host "Enter the Datasource ID"
if($Datasource -ne "A")
{
$recoverypoints = Get-RecoveryPoint -Datasource $ds[$Datasource]
}
else
{
$recoverypoints = @()
foreach($source in $ds)
{
$recoverypoints += Get-RecoveryPoint -Datasource $source
}
}

if($Datasource -ne "A")
{
Write-Host "Most recent recovery point: $($recoverypoints[$recoverypoints.count-1].representedpointintime)"
}
clear-host
foreach($rp in $recoverypoints)
{
$rpsize = [math]::truncate($rp.Size / 1GB)
$line = "$($rp.datasource) - $($rp.representedpointintime) ($($rpsize)GB)"
if($rp.representedpointintime -lt $Dte)
{
write-host "Removing $($line)..."
Remove-RecoveryPoint $rp -Confirm:$false -ErrorAction SilentlyContinue
}
else
{
write-host "$($line) later than cutoff, skipping..."
}
}

Simply save it to a .ps1 file on your DPM server and launch it from the DPM Management Shell. When run it will ask for the name of the DPM server to connect to, and a cut-off date. Replicas on storage earlier than the cut-off will be removed. Next the script will show all your protection groups and ask to choose one. After this will show you all the data sources in that protection group, giving you the option of processing just one item, or all items in the group.

Hope this script is helpful. Any comments or suggestions, please feel free to let me know!

Share and Enjoy:
  • Digg
  • StumbleUpon
  • Technorati
  • del.icio.us
  • Twitter
  • blogmarks
  • HackerNews
  • Tumblr
  • Posterous
  • email
Bookmark the permalink. Follow any comments here with the RSS feed for this post.
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Your email address will not be published. Required fields are marked *

This blog is kept spam free by WP-SpamFree.