none
Cannot delete recovery point for media(tape) in SCDPM RRS feed

  • Question

  • Hi,

    I want to delete the old recovery point from year 2017 and below but not successful. I'm using the PowerShell command to delete the disk, it can be successful deleted but when i choose media(tape),it will show no recovery point found although the recovery point for year 2017 and below is list out. 

    Wednesday, October 16, 2019 12:12 PM

All replies

  • Hi,

    Can you provide the full PowerShell command you’re using when trying to dwlete the recovery points?

    Where are you checking the available tape recovery points?

    Best regards,

    Leon


    Blog: https://thesystemcenterblog.com LinkedIn:

    Wednesday, October 16, 2019 1:01 PM
  • Hi Leon,

    This is the PowerShell Script that was used:

    #Author : Ruud Baars
    #Date : 11/09/2008
    #Edited : 11/15/2012 By: Wilson S.
    #edited : 11:27:2012 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" 
    $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
    $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]" 
    "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
    }

    The script will list out the recovery point for year 2017 and below but when delete it will show no recovery point found. Please see below output. 

    TIM01                    12/8/2017 6:19:03 PM               TIM01 on computer TI... Media                           
    TIM01                    12/15/2017 6:26:42 PM             TIM01 on computer TI... Media                           
    TIM01                    12/22/2017 7:09:56 PM             TIM01 on computer TI... Media                           
    TIM01                    12/29/2017 6:08:04 PM             TIM01 on computer TI... Media                           
    TIM01                    12/31/2017 6:03:26 PM             TIM01 on computer TI... Media  

    Total recoverypoint usage 1062334.9 MB on DISK in 135 recovery points

    Delete ALL Disk based recovery points BEFORE and Including date/time entered [MM/DD/YYYY hh:mm]:  12/31/2017 6:03:26 PM
    Deleting recovery points until and 12/31/2017 18:03:26
    No recovery points found!

    Thanks,

    Fieqa

              
    Friday, October 18, 2019 6:54 AM
  • The script is only intended for removing recovery points on DISK, not on TAPE.

    Blog: https://thesystemcenterblog.com LinkedIn:

    Friday, October 18, 2019 7:29 AM
  • May I know if you have the script to delete the recovery point on tape?

    Friday, October 18, 2019 9:06 AM
  • Which version and build of DPM are you currently using?


    Blog: https://thesystemcenterblog.com LinkedIn:

    Friday, October 18, 2019 9:08 AM
  • Windows Server 2012 R2, System Center 2012 R2, Version 4.2.1417.0. 
    Friday, October 18, 2019 9:15 AM
  • You can use the Remove-DPMRecoveryPoint PowerShell cmdlet to remove recovery points from both Disks and Tapes.

    Note: The link is for the newest DPM PowerShell, you'll find the DPM 2012 R2 PowerShell cmdlet reference over here:
    http://download.microsoft.com/download/A/0/B/A0BB6495-3010-43A8-B06C-6B0F0E8F92D9/SC2012R2_DPM_Cmdlets.pdf



    Blog: https://thesystemcenterblog.com LinkedIn:

    Friday, October 18, 2019 9:23 AM
  • Do you have the specific script so can just choose to delete all old recovery point for 2017 and below only? 
    Friday, October 18, 2019 10:11 AM
  • I don't have one, but you can try this one: DPM 2012 R2: Remove Recovery Points - version 2

    I'm not sure if it will work for tapes though.


    Blog: https://thesystemcenterblog.com LinkedIn:

    Friday, October 18, 2019 10:17 AM
  • Already try the script, but it also did not delete the tape. There is no error stated.
    Friday, October 18, 2019 11:11 AM
  • Okay, then I’m afraid you will have to create a script yourself with the Remove-DPMRecoveryPoint PowerShell cmdlet, there is an example in the documentation on how to use the cmdlet.

    You can also find some guides out on the Internet on how to remove recovery points with this cmdlet, here’s one for example:

    Removing a DPM Recovery Point


    Blog: https://thesystemcenterblog.com LinkedIn:

    • Proposed as answer by Leon Laude Tuesday, October 22, 2019 8:33 PM
    Friday, October 18, 2019 11:18 AM