none
Delete disk backup recovery point RRS feed

  • Question

  • Hi Guys,

    Am using DPM 2012 SP1 version 4.1.3313.0

    Looking to delete the disk recovery points & using the script mentioned int he gallery - http://gallery.technet.microsoft.com/scriptcenter/DPM-2012-R2-Remove-6167f338

    Somehow when i run the scripts and follow the steps till recovery points there are approx. 192 numbers out of which am not able to distinguish which one is tape and disk recovery point.

    I changed my retention from 15days to 5days the older recovery points are not getting removed automatically instead of the scripts i have ran Removeinactiverecoverypoint.ps1, removerecoverypoint.ps1 & pruneshadowcopiesDpm2010.ps1

    Somehow i managed to shrink but that not what am looking for. I want to delete the older recovery points than 5days and using that gallery script how can i identify which one is tape / disk recovery point.

    Note: i dont want to delete the tape recovery points.

    - Charles

    Monday, September 8, 2014 11:38 AM

Answers

  • Hi,

    it said "No recovery points found!"  I'm thinking it may be that the month is 09 and the day is 02 - so try using:

    09/02/2014 18:01:51


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Regards, Mike J. [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights.

    • Marked as answer by Piramal IT Tuesday, September 9, 2014 11:28 AM
    Tuesday, September 9, 2014 10:06 AM
    Moderator

All replies

  • Hi Charles,

    you can use the Powershell Cmdlet Get-DPMRecoveryPointLocation to find out whether a recovery point is on disk or tape:
    http://technet.microsoft.com/en-us/library/hh881714(v=sc.20).aspx

    You can also use the Cmdlet Remove-DPMRecoveryPoint to delete a specific recovery point.

    Cheers
    Chaib


    Monday, September 8, 2014 2:58 PM
  • While running the second command getting the below error following the article

    PS C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin> $Ds = Get-DPMDatasource $Pg
    Get-DPMDatasource : Cannot convert 'System.Object[]' to the type 'Microsoft.Internal.EnterpriseStorage.Dls.UI
    .ObjectModel.OMCommon.ProtectionGroup' required by parameter 'ProtectionGroup'. Specified method is not suppo
    rted.
    At line:1 char:24
    + $Ds = Get-DPMDatasource <<<<  $Pg
        + CategoryInfo          : InvalidArgument: (:) [Get-DPMDatasource], ParameterBindingException
        + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.Internal.EnterpriseStorage.Dls.UI.Cmdlet.Commo
       n.GetDatasource

    PS C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin>

    Tuesday, September 9, 2014 4:12 AM
  • Hi,

    Please try this script and see if that works for you.

    #Author	: Ruud Baars
    #Date	: 11/09/2008
    #Edited : 11/15/2012 By: Wilson S.
    #edited : 07/25/2014 By: Mike J.
    
    # NOTE: Update script to only remove recovery points on Disk. Recovery points removed will be from the oldest one up to the date
    #       entered by the user while the script is running
    #deletes all recovery points before 'now' on selected data source.
    $version="V4.7.2" 
    $ErrorActionPreference = "silentlycontinue"
    add-pssnapin sqlservercmdletsnapin100
    Add-PSSnapin -Name Microsoft.DataProtectionManager.PowerShell
    #display RP's to delete and ask to continue. 
    #Check & wait data source to be idle else removal may fail (in Mojito filter on 'intent' to see the error)
    #Fixed prune default and logfile name and some logging lines (concatenate question + answer)
    #Check dependent recovery points do not pass BEFORE date and adjust selection to not select those ($reselect)
    #--- Fixed reselect logic to keep adjusting reselect for as long as older than BEFORE date
    #--- Fixed post removal rechecking logic to match what is done so far (was still geared to old logic)
    #--- Modified to remove making RP and ask for pruning, fixed logic for removal rechecking logic
    #--- Prompt for MM/DD/YYYY hh:mm:ss AM/PM  - V4.7.2
    
    $MB=1024*1024
    $logfile="DPMdeleteRP.LOG"
    $wait=10	#seconds
    $confirmpreference = "None" 
    
    function Show_help
    {
    	cls
    	$l="=" * 79
    	write-host $l -foregroundcolor magenta
    	write-host -nonewline "`t<<<" -foregroundcolor white
    	write-host -nonewline " DANGEROUS :: MAY DELETE MANY RECOVERY POINTS " -foregroundcolor red
    	write-host ">>>" -foregroundcolor white
    	write-host $l -foregroundcolor magenta
    	write-host "Version: $version" -foregroundcolor cyan
        	write-host "A: User Selects data source to remove recovery points for" -foregroundcolor green
    	write-host "B: User enters date / time (using 24hr clock) to Delete recovery points" -foregroundcolor green
    	write-host "C: User Confirms deletion after list of recovery points to be deleted is displayed." -foregroundcolor green
    	write-host "Appending to log file $logfile`n" -foregroundcolor white
    	write-host "User Accepts all responsibilities by entering a data source or just pressing [Enter] " -foregroundcolor white -backgroundcolor blue
    
    }
    
    
    "**********************************" >> $logfile
    "Version $version" >> $logfile
    get-date >> $logfile
    show_help
    
    $DPMservername=&"hostname"
    "Selected DPM server = $DPMservername" >> $logfile
    write-host "`nConnnecting to DPM server retrieving data source list...`n" -foregroundcolor green
    $pglist = @(Get-ProtectionGroup $DPMservername) # WILSON - Created PGlist as array in case we have a single protection group.
    $ds=@()
    $tapes=$null
    $count = 0
    $dscount = 0
    foreach ($count in 0..($pglist.count - 1)) 
    {
        # write-host $pglist[$count].friendlyname
        $ds += @(get-datasource $pglist[$count]) # WILSON - Created DS as array in case we have a single protection group.
        # write-host $ds
        # write-host $count -foreground yellow 
    } 
    if ( Get-Datasource $DPMservername -inactive) {$ds += Get-Datasource $DPMservername -inactive}
    
    $i=0
    write-host "Index Protection Group     Computer             Path"
    write-host "---------------------------------------------------------------------------------"
    foreach ($l in $ds) 
    {
    	"[{0,3}] {1,-20} {2,-20} {3}" -f $i, $l.ProtectionGroupName, $l.psinfo.netbiosname, $l.logicalpath
    	$i++
    }
    $DSname=read-host "`nEnter a data source index from list above - Note co-located datasources on same replica will be effected"
    
    if (!$DSname) 
    {
    	write-host "No datasource selected `n" -foregroundcolor yellow
    	"Aborted on Datasource name" >> $logfile
    	exit 0
    }
    $DSselected=$ds[$DSname]
    if (!$DSselected) 
    {
    	write-host "No datasource selected `n" -foregroundcolor yellow
    	"Aborted on Datasource name" >> $logfile
    	exit 0
    }
    $rp=get-recoverypoint $DS[$dsname]
    $rp
    # $DoTape=read-host "`nDo you want to remove when recovery points are on tape ? [y/N]"
    # "Remove tape recovery point = $DoTape" >> $logfile
    
    write-host "`nCollecting recoverypoint information for datasource $DSselected.name" -foregroundcolor green
    if ($DSselected.ShadowCopyUsedspace -gt 0)
    {
        while ($DSSelected.TotalRecoveryPoints -eq 0)
        { # "still 0"
        }
    
    	#this is on disk
    	$oldShadowUsage=[math]::round($DSselected.ShadowCopyUsedspace/$MB,1)
    	$line=("Total recoverypoint usage {0} MB on DISK in {1} recovery points" -f $oldShadowUsage ,$DSselected.TotalRecoveryPoints  ) 
    	$line >> $logfile
    	write-host $line`n -foregroundcolor white
    }
    
    #this is on tape
    #$trptot=0
    #$tp= Get-RecoveryPoint($dsselected) | where {($_.Datalocation -eq "Media")}
    #foreach ($trp in $tp) {$trptot += $trp.size }
    #if ($trptot -gt 0 )
    #{
    #	$line=("Total recoverypoint usage {0} MB on TAPE in {1} recovery points" -f ($trptot/$MB) ,$DSselected.TotalRecoveryPoints  ) 
    #	$line >> $logfile
    #	write-host $line`n -foregroundcolor white		
    #}
    
    [datetime]$afterdate="1/1/1980"
    #$answer=read-host "`nDo you want to delete recovery points from the beginning [Y/n]" 
    #if ($answer -eq "n" )
    #{
    #	[datetime]$afterdate=read-host "Delete recovery points AFTER date [MM/DD/YYYY hh:mm]"
    #}
    [datetime]$enddate=read-host "Delete ALL Disk based recovery points BEFORE and Including date/time entered [MM/DD/YYYY hh:mm:ss AM/PM]" 
    "Deleting recovery points until $enddate" >>$logfile
    write-host "Deleting recovery points until and $enddate" -foregroundcolor yellow
    $rp=get-recoverypoint $DSselected
    
    if ($DoTape -ne "y" )
    {
    	$RPselected=$rp | where {($_.representedpointintime -le $enddate) -and ($_.Isincremental -eq $FALSE) -and ($_.DataLocation -eq "Disk")}
    }
    else
    {
    	$RPselected=$rp | where {($_.representedpointintime -le $enddate) -and ($_.Isincremental -eq $FALSE)}
    }
    
    if (!$RPselected) 
    {
    	write-host "No recovery points found!" -foregroundcolor yellow
    	"No recovery points found, aborting...!" >> $logfile
    	exit 0
    }
    $reselect = $enddate
    $adjustflag = $false
    foreach ($onerp in $RPselected)
    {
    	$rtime=[string]$onerp.representedpointintime
    	$rsize=[math]::round(($onerp.size/$MB),1)
    	$line= "Found {0}, RP size= {1} MB (If 0 MB, co-located datasource cannot be computed), Incremental={2} "-f $rtime, $rsize,$onerp.Isincremental
            $line >> $logfile
    	write-host "$line" -foregroundcolor yellow
    	#
    	#Get dependent rp's for data source
    	#
    	$allRPtbd=$DSselected.GetAllRecoveryPointsToBeDeleted($onerp)
    	foreach ($oneDrp in $allRPtbd)
    	{
    		if ($oneDrp.IsIncremental -eq $FALSE) {continue}
    		$rtime=[string]$oneDrp.representedpointintime
    		$rsize=[math]::round(($oneDrp.size/$MB),1)
    		$line= ("`t...is dependancy for {0} size {1} `tIncremental={2}" -f $rtime, $rsize, $oneDrp.Isincremental) 
    		$line >> $logfile
    		if ($oneDrp.representedpointintime -ge $enddate)
    		{
    			#stick to latest full ($oneDrp = dependents, $onerp = full)
    			$adjustflag = $true
    			$reselect = $onerp.representedpointintime
    			"<< Dependents newer than BEFORE date >>>" >> $logfile
    			Write-Host -nonewline "`t <<< later than BEFORE date >>>" -foregroundcolor white -backgroundcolor red
    			write-host "$line" -foregroundcolor yellow
    		}
    		else
    		{
    			#Ok, include current latest incremental
    			$reselect =  $oneDrp.representedpointintime
            	write-host "$line" -foregroundcolor yellow
    		}
    	}
    }
    if ($reselect -lt $oneDrp.representedpointintime) 
    {
    	#we adjusted further backward than latest incremental within selection
            $reselect =  $rtime 
    	$line =  "Adjusted BEFORE date to be $reselect to include dependents to $enddate"
    	$line >> $logfile
    	Write-Host $line -foregroundcolor white -backgroundcolor blue
    }
    $line="`n<<< SECOND TO LAST CHANCE TO ABORT - ONE MORE PROMPT TO CONFIRM. >>>"
    write-host $line  -foregroundcolor white -backgroundcolor blue
    $line >> $logfile
    $line="Above recovery points within adjusted range will be permanently deleted !!!"
    write-host $line -foregroundcolor red
    $line >> $logfile
    $line="These RP's include dependent recovery points and may contain co-located datasource(s)"
    write-host $line -foregroundcolor red 
    $line >> $logfile
    $line="Data source activity = " + $DSselected.Activity
    $line >> $logfile
    write-host $line -foregroundcolor white
    $DoDelete=""
    while (($DoDelete -ne "N" ) -and ($DoDelete -ne "Y"))
    {
    	$line="Continue with deletion (must answer) Y/N? "
    	write-host $line -foregroundcolor white
    	$DoDelete=read-host
    	$line = $line + $DoDelete
    	$line >> $logfile
    }
    
    if (!$DSselected.Activity -eq "Idle") 
    {
    	$line="Data source not idle, do you want to wait Y/N ? "
    	write-host $line -foregroundcolor yellow
    	$Y=read-host
    	$line = $line + $Y
    	$line >> $logfile
    	if ($Y -ieq "Y") 
    	{
    		Write-Host "Waiting for data source to become idle..."  -foregroundcolor green
    		while ($DSselected.Activity -ne "Idle")
    		{
    			("Waiting {0} seconds" -f $wait) >>$logfile
    			Write-Host -NoNewline "..." -ForegroundColor blue
    			start-sleep -s $wait
    		}
    	}
    }
    
    if ($DoDelete -eq "Y")
    {
       foreach ($onerp in $RPselected)
    	{
    		#reselect is adjusted to safe range relative to what was requested
    		#--- if adjustflag not set then all up to including else only older because we must keep the full
    		if ((($onerp.representedpointintime -le $reselect) -and ($adjustflag -eq $false)) -or ($onerp.representedpointintime -lt $reselect))
    		{
    			$rtime=[string]$onerp.representedpointintime
    			write-host `n$line -foregroundcolor red
    			$line >>$logfile
    			if (($onerp ) -and ($onerp.IsIncremental -eq $FALSE)) { remove-recoverypoint -RecoveryPoint $onerp -confirm:$True} # >> $logfile}
    			$line =("---`nDeleting recoverypoint -> " + $rtime)
    			$line >>$logfile
    		}
    	}
    }
    "All Done!" >> $logfile
    write-host "`nAll Done!`n`n" -foregroundcolor white
    $line="Do you want to View DPMdeleteRP.LOG file Y/N ? "
    	write-host $line -foregroundcolor white
    	$Y=read-host
    	$line = $line + $Y
    	$line >> $logfile
    	if ($Y -ieq "Y") 
    	{		
    	Notepad DPMdeleteRP.LOG
    	}


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Regards, Mike J. [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, September 9, 2014 4:33 AM
    Moderator
  • I just want to delete disk recovery points older than 5 days only, is the above script going to delete all the disk recovery points?

    Where it will log the action activities performed using script?

    - Charles

    Tuesday, September 9, 2014 5:09 AM
  • Hi,

    The script will list all data sources and ask you to select one.  It will then list all disk based recovery points for that data source and ask you to enter a date / time to delete recovery points from.  So you would select the last recovery point date / time you want to delete and the script will delete older recovery point up to and including the date / time you entered.  The activity is logged to a file called DPMDeleteRP.log.


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Regards, Mike J. [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, September 9, 2014 5:17 AM
    Moderator
  • Couple of questions, is below means?

    Location

    Disk - on disk?

    Media - on Tape?

    i ran the below output

    So IN_CHF_GM                   02-09-2014 18:01:51         IN_CHF_GM on computer P... Disk seems to be on disk ryt?

    Then i entered the date and time - 02-09-2014 18:01:51 

    Output resulted as mentioned below.

    Collecting recoverypoint information for datasource IN_CHF_GM on computer PELEXMBP1.mypiramal.com.name
    Total recoverypoint usage 198713.8 MB on DISK in 147 recovery points

    Delete ALL Disk based recovery points BEFORE and Including date/time entered [MM/DD/YYYY hh:mm:ss AM/PM]: 02-0
    9-2014 18:01:51
    Deleting recovery points until and 02/09/2014 18:01:51
    No recovery points found!

    When ran the script again to validate if it was deleted, its still showing in the list after deleting as mentioned below.

    Let me know further if anything i missed

    - Charles

    Tuesday, September 9, 2014 5:51 AM
  • Hi,

    it said "No recovery points found!"  I'm thinking it may be that the month is 09 and the day is 02 - so try using:

    09/02/2014 18:01:51


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Regards, Mike J. [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights.

    • Marked as answer by Piramal IT Tuesday, September 9, 2014 11:28 AM
    Tuesday, September 9, 2014 10:06 AM
    Moderator
  • Seems that was the problem, Thanks Mike for your help & script too.

    Tuesday, September 9, 2014 11:27 AM