none
scripted recovery of a Bare Metal Recovery Protection Group to alternate location fails (DPM 2010) RRS feed

  • Question

  • I wrote a powershell script to recover the latest recovery point of all my "System Protection" Protection Groups to a USB disk attached to the DPM server.

    This script works great if i try to recover only a protected folder - but for the "System Protection" the powershell crashes

    	
    $restorePath="e:\Backup"
    $targetServerName="srvdpm"
    $pgList = Get-ProtectionGroup -dpmServerName srvdpm | where {$_.FriendlyName -match "BareMetalRestore"}
    
    $DSList = @()
    ForEach ($pg in $pgList)
    {
     $DSList += @(Get-Datasource -protectionGroup $pg)
    }
    
    ForEach ($DS in $DSList)
    {
     #Get the latest recovery point.
     $recoveryPoints = @(Get-RecoveryPoint -datasource $DS | sort -property RepresentedPointInTime -Descending)
      if ($recoveryPoints.Length -eq 0)
      {
        Write-Host "No recovery point available for" $DS.Name -ForeGroundColor Yellow
        Continue
      }
      $latestRecoveryPoint = $recoveryPoints[0]
      $RecoverableItem = Get-RecoverableItem -RecoverableItem $latestRecoveryPoint -BrowseType child | where { $_.UserFriendlyName -eq "Bare Metal Recovery" }
      $RecoverableItem
      $rop = New-RecoveryOption -targetServer $targetServerName -recoveryLocation CopyToFolder -FileSystem -AlternateLocation $restorePath -OverwriteType overwrite -RecoveryType Restore
      Recover-RecoverableItem -RecoverableItem $RecoverableItem -recoveryoption $rop
    }
    When i try to execute the script, powershell crashes with the following message:
    
    

    Problemsignatur:

    Problemereignisname: PowerShell

    NameOfExe: powershell.exe

    FileVersionOfSystemManagementAutomation: 6.1.7600.16385

    InnermostExceptionType: System.NullReferenceException

    OutermostExceptionType: System.Reflection.TargetInvocation

    DeepestPowerShellFrame: unknown

    DeepestFrame: System.RuntimeMethodHandle._InvokeMethodFast

    ThreadName: unknown

    Betriebsystemversion: 6.1.7600.2.0.0.272.7

    Gebietsschema-ID: 1031

    Lesen Sie unsere Datenschutzbestimmungen online:

     

    Wenn die Onlinedatenschutzbestimmungen nicht verfügbar sind, lesen Sie unsere Datenschutzbestimmungen offline:

     

    C:\Windows\system32\de-DE\erofflps.txt

    • Moved by MarcReynolds Friday, May 20, 2011 3:16 PM (From:Data Protection Manager)
    Wednesday, June 9, 2010 6:21 PM

Answers

  • Okay, with enough poking and prodding, finally got this to work for me.  Let me know if these changes (highlighted) work for you.

     (just changed sections included)

          $RecoverableItem = @(Get-RecoverableItem -RecoverableItem $latestRecoveryPoint -BrowseType child | where { $_.UserFriendlyName -eq "Bare Metal Recovery" })

       # $RecoverableItem #don’t ever do this in scripts, you return a full object, not text

               $rop = New-RecoveryOption -targetServer $targetServerName -recoveryLocation CopyToFolder -SystemProtectionDataSource -TargetLocation $restorePath -RecoveryType Restore

    Note:  Removed -OverwriteType overwrite from $rop definition


    Thanks, Chris - [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights
    • Marked as answer by Ma.Schmidt Thursday, June 10, 2010 4:44 PM
    Thursday, June 10, 2010 4:16 PM

All replies

  • Have you broken the script down and run it manually in PowerShell?  I'm not a PowerShell guru by any stretch, but when I ran this on my system I didn't even get $pgList to populate.  After each of the first three lines, I just tried to dump out the results.  $restorePath and $targetServerName both gave me the values I expected, but the $pglist did not.  The other thing that may be an easy fix is I believe you should be matching on "BareMetalRecovery" (not "BareMetalRestore"), but since mine didn't return any values (and I do have some BMR protection), I'm not sure that is where the problem is either.  I'll continue testing to see if I can isolate the issue.
    Thanks, Chris - [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights
    Wednesday, June 9, 2010 8:47 PM
  • All my Protection Groups with "System Protection" backup contain a "BareMetalRestore" in the protection group name.

    I ran the script line by line and it works great - as long as i dont execute the last line (Recover-RecoverableItem)

    But the $RecoverableItem the script returns IS the Bare Metal Restore. But i cannot automate the restore of this item.

    Wednesday, June 9, 2010 8:56 PM
  • Just a thought here...
     
    Could you try to recover (for test) to the local drive and see if that works?
     
    I'm thinking that the problem is with the USB drive
     
    Let us know
     
    Cheers,
     
    Mike Resseler
    "AI-M.Schmidt" wrote in message news:a30c0dee-cf77-475f-9a46-f3ef6a4f02e0...

    All my Protection Groups with "System Protection" backup contain a "BareMetalRestore" in the protection group name.

    I ran the script line by line and it works great - as long as i dont execute the last line (Recover-RecoverableItem)

    But the $RecoverableItem the script returns IS the Bare Metal Restore. But i cannot automate the restore of this item.


    Visit System Center User Group Belgium @ http://scug.be and http://scug.be/blogs/scdpm
    Thursday, June 10, 2010 10:03 AM
    Moderator
  • I already tried that before with different restore locations - but with no luck.
    Thursday, June 10, 2010 10:28 AM
  • I don't have a solution yet, but leveraging some PowerShell folks I am closer.  Here is the modified script.  Using this, it no longer crashes but reports an error getting to the path I am specifying (I have used both C: and E: - both local drives).

    ·         $restorePath="e:\Backup"

    ·         $targetServerName="srvdpm"

    ·         $pgList = Get-ProtectionGroup -dpmServerName srvdpm | where {$_.FriendlyName -match "BareMetalRestore"}

    ·          

    ·         $DSList = @()

    ·         ForEach ($pg in $pgList)

    ·         {

    ·          $DSList += @(Get-Datasource -protectionGroup $pg)

    ·         }

    ·          

    ·         ForEach ($DS in $DSList)

    ·         {

    ·          #Get the latest recovery point.

    ·          $recoveryPoints = @(Get-RecoveryPoint -datasource $DS | sort -property RepresentedPointInTime -Descending)

    ·           if ($recoveryPoints.Length -eq 0)

    ·           {

    ·             Write-Host "No recovery point available for" $DS.Name -ForeGroundColor Yellow

    ·             Continue

    ·           }

    ·           $latestRecoveryPoint = $recoveryPoints[0]

    ·           $RecoverableItem = @(Get-RecoverableItem -RecoverableItem $latestRecoveryPoint -BrowseType child | where { $_.UserFriendlyName -eq "Bare Metal Recovery" })

    ·          # $RecoverableItem #don’t ever do this in scripts, you return a full object, not text

    ·           $rop = New-RecoveryOption -targetServer $targetServerName -recoveryLocation CopyToFolder -FileSystem -AlternateLocation $restorePath -OverwriteType overwrite -RecoveryType Restore

    ·           Recover-RecoverableItem -RecoverableItem $RecoverableItem -recoveryoption $rop

    ·         }

    Maybe this will get your closer to the goal.  The error seems to be indicating that the recovery options being passed are not valid and then complains about not detecting the volume.  I will keep working on it but wanted to share this with you so you can continue working on it as well.


    Thanks, Chris - [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights
    Thursday, June 10, 2010 3:43 PM
  • Okay, with enough poking and prodding, finally got this to work for me.  Let me know if these changes (highlighted) work for you.

     (just changed sections included)

          $RecoverableItem = @(Get-RecoverableItem -RecoverableItem $latestRecoveryPoint -BrowseType child | where { $_.UserFriendlyName -eq "Bare Metal Recovery" })

       # $RecoverableItem #don’t ever do this in scripts, you return a full object, not text

               $rop = New-RecoveryOption -targetServer $targetServerName -recoveryLocation CopyToFolder -SystemProtectionDataSource -TargetLocation $restorePath -RecoveryType Restore

    Note:  Removed -OverwriteType overwrite from $rop definition


    Thanks, Chris - [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights
    • Marked as answer by Ma.Schmidt Thursday, June 10, 2010 4:44 PM
    Thursday, June 10, 2010 4:16 PM
  • Thank you - it works. It was only the wrong Recovery Option.

    Here is the complete script:

     

    $restorePath="e:\Backup"
    $targetServerName="srvdpm"
    $pgList = Get-ProtectionGroup -dpmServerName srvdpm | where {$_.FriendlyName -match "BareMetalRestore"}

    $DSList = @()
    ForEach ($pg in $pgList)
    {
     $DSList += @(Get-Datasource -protectionGroup $pg)
    }

    ForEach ($DS in $DSList)
    {
     #Get the latest recovery point.
     $recoveryPoints = @(Get-RecoveryPoint -datasource $DS | sort -property RepresentedPointInTime -Descending)
        if ($recoveryPoints.Length -eq 0)
        {
            Write-Host "No recovery point available for" $DS.Name -ForeGroundColor Yellow
            Continue
        }
        $latestRecoveryPoint = $recoveryPoints[0]
        $RecoverableItem = Get-RecoverableItem -RecoverableItem $latestRecoveryPoint -BrowseType child | where { $_.UserFriendlyName -eq "Bare Metal Recovery" }
        $rop = New-RecoveryOption -targetServer $targetServerName -recoveryLocation CopyToFolder -SystemProtectionDataSource -TargetLocation $restorePath -RecoveryType Restore
        Recover-RecoverableItem -RecoverableItem $RecoverableItem -recoveryoption $rop
    }

    Thursday, June 10, 2010 4:53 PM