Removing DPM Recovery Points from Inactive Protection

By YellowOnline on Tuesday 22 January 2013 10:55 - Comments (6)
Category: SCDPM, Views: 4.810

Removing DPM Recovery Points from Inactive Protection

An annoying limit of SCDPM is its maximum of 9000 recovery points per server (which is a VSS limit it seems). Recently I did a migration of a bunch of protected servers to another DPM server without moving the protected data as well - because that's simply not possible as far as I know. If it is, please let me know.

So anyway: after moving the protected server to another DPM server, the problem is that I can't just throw away the old data. I have to guarantee 2 months of recovery so the data needs to stay on the old DPM server for two months, under a header Inactive protection for previously protected data.

When I wanted to add new protected servers to the DPM server that I moved other protected servers away from, I hit the 9000 recovery points. Blast.

Of course: I have the data of two drives on 22 servers as Inactive protection for previously protected data. That's 22x2x62 = 2728 recovery points. Yikes, these old snapshots are eating about a third of my snapshot capability.

That migration happened about three weeks ago. The problem is that inactive recovery points will not automatically prune just like a recovery point that is part of an active protection group. An idea would be to remove all recovery points that are older than 2 months, which would give me right now 924 available recovery points, enough to add the stuff I need to backup to that same DPM server.

So how do we remove recovery points? Not through the GUI in any case: it only offers the possibility of removing all recovery points for a given data source, not specific points in time. Also, removing 924 recovery points by hand would be quite a tedious job. Automation is the keyword.

Powershell to the rescue!


I had to write a script that would allow me to access the individual recovery points of data that is not part of a protection group (you'll a script easily online from Mike Jacquet, MSFT that'll do exactly that for you), select a range of protection points and in the end, of course, delete them.

First thing to do: get the data sources from the server. $Server contains the host name or FQDN of the DPM server.



C#:
1
$DataSources = Get-DataSource $Server


The second step is to get the inactive protected data only, which can be filtered by comparing the individual objects of the $DataSources array to the following:



C#:
1
$DataSource.InactiveProtectionStatus -EQ [Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.OMCommon.InactiveProtection]::Disk -OR $DataSource.InactiveProtectionStatus -EQ [Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.OMCommon.InactiveProtection]::DiskAndTape)


Now I put away all data sources with inactive protected data into another array called $InactiveServers. For each object in that array I'll have to get the available recovery points. Mind that here I will select the time range through the variable $Retention which I chose to do in days. You can easily alter the code to use months instead. Or hours, or minutes, or... well you, get the point.



C#:
1
$RecoveryPoints = @(Get-RecoveryPoint $InactiveServer | Where-Object {$_.RepresentedPointInTime.Date -LT $((Get-Date).AddDays(-$Retention))})


Great, we have an array with all of our recovery points for a given data source. Now let's delete those RPs. For each object in the array we go:



C#:
1
Remove-RecoveryPoint -RecoveryPoint $RecoveryPoint -Confirm:$False


I added the -Confirm:$False because otherwise it will ask you to confirm every single removal. Have fun with a few hundreds of recovery points!

In any case: I made a quick script around this that I happily share with you. It's dirtier than usual - no logging and ugly output to screen (although it is Yellow :)) - but I did put quite some safety measures into it so that you don't accidentally remove too much.

The script expects 2 parameters: the server to run on and the retention you want to keep (in days, feel free to change). There is also a third -WhatIf parameter so you can simulate what would happen. Always a good idea!

Finally it will give you an overview of your choices and ask confirmation in a case sensitive way. If you type 'Yes' there, the show really starts



C#:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#Requires -version 2
<# 
==================================================================================================
Microsoft PowerShell Source File
NAME    :    Remove-InactiveRecoveryPoints v1.0
AUTHOR  :    YellowOnline
DATE    :    21/01/2013

COMMENTS:    Script to be handled with carePotentially veryvery dangerous
==================================================================================================
#>
Param($Server = $(Throw "Please enter a server name"), $Retention = $(Throw "Please enter a retention time IN DAYS."), [switch]$WhatIf)
If ((Get-PSSnapin -Name Microsoft.DataProtectionManager.PowerShell -ErrorAction SilentlyContinue) -EQ $Null)
    {
    Try {Add-PsSnapin Microsoft.DataProtectionManager.PowerShell}
    Catch {Throw "Missing the DPM snapin."}
    }
If ([System.Runtime.InterOpServices.Marshal]::SizeOf([System.IntPtr]) -EQ 4)
    {
    Throw "This script needs to be run in x64."
    }
Clear-Host
Write-Warning "You will delete all recovery points from previously protected"
Write-Warning "servers on $Server that are older than $Retention days."
Write-Warning "No recovery points from existing Protection Groups will be deleted."
Write-Warning "Type `"Yes`" (case sensitive) if you are sure you want to continue."
$UserInput = Read-Host
If ($UserInput -CNE "Yes")
    {
    Write-Warning "Execution not confirmed. Quitting."    
    }
Else
    {
    Disconnect-DPMServer
    Write-Warning "Enumerating Datasources"
    $DataSources = Get-DataSource $Server
    $InactiveServers = @()
    ForEach($DataSource in $DataSources)
        {
        If(($DataSource.InactiveProtectionStatus -EQ [Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.OMCommon.InactiveProtection]::Disk -OR $DataSource.InactiveProtectionStatus -EQ [Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.OMCommon.InactiveProtection]::DiskAndTape))
            {
            $InactiveServers += $DataSource
            }
        }
    Write-Warning "Sorting inactive servers"
    $InactiveServers = $InactiveServers | Sort-Object ProductionServerName
    ForEach ($InactiveServer in $InactiveServers)
        {
        $RecoveryPoints = @(Get-RecoveryPoint $InactiveServer | Where-Object {$_.RepresentedPointInTime.Date -LT $((Get-Date).AddDays(-$Retention))})
        ForEach ($RecoveryPoint in $RecoveryPoints)
            {
            Write-Warning "Removing $($RecoveryPoint.DataSource.LogicalPath) dated $($RecoveryPoint.RepresentedPointInTime) from $($RecoveryPoint.DataSource.ProductionServerName)"
            If ($WhatIf)
                {
                Remove-RecoveryPoint -RecoveryPoint $RecoveryPoint -Confirm:$False -WhatIf | Out-Null
                }
            Else
                {
                Remove-RecoveryPoint -RecoveryPoint $RecoveryPoint -Confirm:$False | Out-Null
                }
            }
        }
    Disconnect-DPMServer
    }


An output example:



code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
WARNING: You will delete all recovery points from previously protected
WARNING: servers on MYDPMSERVER001 that are older than 64 days.
WARNING: No recovery points from existing Protection Groups will be deleted.
WARNING: Type "Yes" (case sensitive) if you are sure you want to continue.
Yes
WARNING: Enumerating Datasources
WARNING: Sorting inactive servers
WARNING: Removing G:\ dated 11/19/2012 20:34:16 from SERVER001.contoso.com
WARNING: Removing E:\ dated 11/19/2012 21:59:54 from SERVER001.contoso.com
WARNING: Removing G:\ dated 11/19/2012 20:34:16 from SERVER002.contoso.com
WARNING: Removing E:\ dated 11/19/2012 21:59:38 from SERVER002.contoso.com
WARNING: Removing G:\ dated 11/19/2012 22:00:42 from SERVER003.contoso.com
WARNING: Removing E:\ dated 11/19/2012 20:34:17 from SERVER003.contoso.com
WARNING: Removing E:\ dated 11/19/2012 22:02:24 from SERVER004.contoso.com
WARNING: Removing G:\ dated 11/19/2012 21:04:15 from SERVER004.contoso.com


That's it. If anyone would be wondering about the Disconnect-DPM-Server both in the beginning and at the end: this is to catch the situation were the script was started (so a DPM connection was made) but prematurely ended (e.g. because of Ctrl+C). This would keep the connection with the DPM server open and running the script subsequently on a different server would fail because there is still an open connection.

I hope someone can use this. Enjoy!

Volgende: PES 2013: "Unable to access hard disk" 03-'13 PES 2013: "Unable to access hard disk"
Volgende: Oost-West: Kerst in Duitsland 01-'13 Oost-West: Kerst in Duitsland

Comments


By Tweakers user YellowOnline, Thursday 24 January 2013 09:28

Er is geen enkel topic is waar ik zo weinig reactie op krijg als op DPM :) Misschien eens een thread starten op GoT zodat ik een idee heb wie er eigenlijk mee bezig is...

* YellowOnline heeft weet van één Tweaker behalve hemzelf in ieder geval

[Comment edited on Thursday 24 January 2013 09:29]


By Tweakers user Moby, Thursday 24 January 2013 16:00

Omdat alleen een reactie van jezelf op je blogitem niet zo leuk is geef ik wel een reactie.

Bij deze!

By Tweakers user YellowOnline, Thursday 24 January 2013 16:03

Moby wrote on Thursday 24 January 2013 @ 16:00:
Omdat alleen een reactie van jezelf op je blogitem niet zo leuk is geef ik wel een reactie.

Bij deze!
DPM en ik danken je :)

By Tweakers user Moby, Thursday 24 January 2013 16:06

We kunnen er ook gewoon een prive babbelbox van maken, maar dat is wel een beetje respectloos voor je blog natuurlijk.

By Tweakers user HyperBart, Wednesday 30 January 2013 00:31

YellowOnline wrote on Thursday 24 January 2013 @ 09:28:
Er is geen enkel topic is waar ik zo weinig reactie op krijg als op DPM :) Misschien eens een thread starten op GoT zodat ik een idee heb wie er eigenlijk mee bezig is...

* YellowOnline heeft weet van één Tweaker behalve hemzelf in ieder geval
Hier ook een (Belgische) DPM-gebruiker/operations-dude die ze moet beheren voor verscheidene klanten.

By Tweakers user YellowOnline, Wednesday 30 January 2013 10:20

Zijn we al met drie \o/

Comments are closed