none
Recover a VHD to a Folder RRS feed

  • Question

  • Hello All

    I've tried a lot to do this operation, but I'm tired of try. I have two VMs which are protected from a Virtual DPM Server (yeah, DPM is a VM too).

    I dont have library or tape drives. I want to do a "not expensive off-site" with my VHDs.

    There isn't docs and/or reference guide (or unfortunately I have not found) about DPM Scripting. If somebody knows links about DPM Objects and Powershell, please, send me.

    I need/want to recover a VHD from DPM and put it into a network folder (or just into DPM server).

    I have tried:

      $SERVER = "dpm.mydomain.foo"
      $PG = Get-ProtectionGroup -DPMServerName $SERVER
      $DsList = Get-Datasource -ProtectionGroup $PG
    
       foreach($ds in $DsList) {
    
         $rop =  New-RecoveryOption -HyperVDatasource -Targetserver $SERVER -TargetLocation "H:\" -Recoverylocation CopyToFolder -RecoveryType recover -OverwriteType Overwrite
    
         Recover-recoverableitem -RecoverableItem $item -recoveryoption $RecOpts 
     
       }
    

    It's not worked.

    Well, I know, my failure is in $rop. Its fail with a "New-RecoveryOption : Parameter set cannot be resolved using the specified named parameters."

    But where can I read about this? What the correct format... I'm really lost in this options... I have tried a lot of combinations and nothing...

    In  "get-help New-RecoveryOption" there isn't examples with hyperv. And dont help much. It's a great amount of paramenters without relationship.

    Well, I hope any good soul help me

    :D

    Thx in advanced.

    Monday, February 20, 2012 6:51 PM

Answers

  •  

    Hi,

    There are couple info missing and assumptions

    Let me try to break your script down…

    $SERVER = "dpm.mydomain.foo"

    $PG = Get-ProtectionGroup -DPMServerName $SERVER

    $DsList = Get-Datasource -ProtectionGroup $PG

    The line above might get you an error if you do have more than one protection group on your DPM Server. The reason for that is that $PG will be an Array and to work with an Array you need  to specify the array position you are referring about. Example:

    In my DPM I Do have two protection Groups (GroupA and GroupB)

    After I run command $PG = Get-ProtectionGroup -DPMServerName $SERVER

    $PG will be set as an array where:

    $PG[0] = GroupA

    $PG[1] = GroupB

    In your script you will need to know upfront in which position of the array the protection group you are interested in is located or you can run the command this way:

    $NamePG = "GroupA"

    $PG = Get-ProtectionGroup -DPMServerName $DPMServer | where {$_.FriendlyName -eq $NamePG}

    In this case $PG will return only one entry as I am specifying which Protection Group I am interested in.

    The next you are doing is creating a loop for all datasources within the selected Protection Group. Lets suppose that on GroupA I have two VMs VM1 and VM2.

    foreach($ds in $DsList)

    {

                $rop =  New-RecoveryOption -HyperVDatasource -Targetserver $SERVER -TargetLocation "H:\" -Recoverylocation CopyToFolder -RecoveryType recover -OverwriteType Overwrite

                Recover-recoverableitem -RecoverableItem $item -recoveryoption $RecOpts

     

    }

    The command Recover-Recoverableitem requires a RecoverPoint to restore from and this entry is missing from the loop.

    The loop should have  this:

    $RP = get-RecoveryPoint $ds

    This will give you ALL RECOVERY POINTS (and again, if you have more than one recovery point $RP will be an ARRAY) for the selected VM and will include everything that was backed up for that VM, not only the VHD you are looking for.

    To get into the VHDs, you need to run this…

    $RI = get-recoverableItem -BrowseType child -Recoverableitem $RP[-1]

    $RI will contain all VHDs for the selected VM. The $RP[-1] means I want the latest recovery point. If your VM has more than one VHD, then $RI will be an ARRAY.

    Here is the correct syntax for $ROP for your scenario.

    $RO = New-RecoveryOption -HyperVDatasource -TargetServer $SERVER -RecoveryLocation CopyToFolder -TargetLocation "H:\"  -RecoveryType restore

    So here is a sample script. The assumption here is that in group <GROUP> I have only VMs. And Each VM has more than one Recovery Point Available and every VM has more than 1 VHD attached to it.

    $dpmserver = "<DPMSERVER>"
    Connect-DPMServer $DPMServer
    $NamePG = "<GROUP>"
    $pg = Get-ProtectionGroup -DPMServerName $DPMServer | where {$_.FriendlyName -eq $NamePG}
    $ds = Get-Datasource -ProtectionGroup $pg
    $rp = Get-RecoveryPoint -Datasource $ds[0]
    $ri = get-recoverableItem -BrowseType child -Recoverableitem $rp[-1]
    $ro = New-RecoveryOption -HyperVDatasource -TargetServer $dpmserver -RecoveryLocation CopyToFolder -TargetLocation "<location>"  -RecoveryType restore
    Recover-RecoverableItem -RecoveryOption $ro -RecoverableItem $ri[0]


    Thanks, Wilson Souza - MSFT This posting is provided "AS IS" with no warranties, and confers no rights

    Monday, February 20, 2012 8:18 PM
    Moderator
  •  Perfect! You was perfect in your explanation!

     Now I understand. I was wondering if  I was near the correct way.

     With your help, now my script works!


     P.S: For people reading this thread, in the last line, "$ri[0]" should be only "$ri" because it's isn't an array.

     Thanks Wilson Souza.

    • Marked as answer by LenonMga Tuesday, February 21, 2012 2:06 AM
    Tuesday, February 21, 2012 2:05 AM

All replies

  •  

    Hi,

    There are couple info missing and assumptions

    Let me try to break your script down…

    $SERVER = "dpm.mydomain.foo"

    $PG = Get-ProtectionGroup -DPMServerName $SERVER

    $DsList = Get-Datasource -ProtectionGroup $PG

    The line above might get you an error if you do have more than one protection group on your DPM Server. The reason for that is that $PG will be an Array and to work with an Array you need  to specify the array position you are referring about. Example:

    In my DPM I Do have two protection Groups (GroupA and GroupB)

    After I run command $PG = Get-ProtectionGroup -DPMServerName $SERVER

    $PG will be set as an array where:

    $PG[0] = GroupA

    $PG[1] = GroupB

    In your script you will need to know upfront in which position of the array the protection group you are interested in is located or you can run the command this way:

    $NamePG = "GroupA"

    $PG = Get-ProtectionGroup -DPMServerName $DPMServer | where {$_.FriendlyName -eq $NamePG}

    In this case $PG will return only one entry as I am specifying which Protection Group I am interested in.

    The next you are doing is creating a loop for all datasources within the selected Protection Group. Lets suppose that on GroupA I have two VMs VM1 and VM2.

    foreach($ds in $DsList)

    {

                $rop =  New-RecoveryOption -HyperVDatasource -Targetserver $SERVER -TargetLocation "H:\" -Recoverylocation CopyToFolder -RecoveryType recover -OverwriteType Overwrite

                Recover-recoverableitem -RecoverableItem $item -recoveryoption $RecOpts

     

    }

    The command Recover-Recoverableitem requires a RecoverPoint to restore from and this entry is missing from the loop.

    The loop should have  this:

    $RP = get-RecoveryPoint $ds

    This will give you ALL RECOVERY POINTS (and again, if you have more than one recovery point $RP will be an ARRAY) for the selected VM and will include everything that was backed up for that VM, not only the VHD you are looking for.

    To get into the VHDs, you need to run this…

    $RI = get-recoverableItem -BrowseType child -Recoverableitem $RP[-1]

    $RI will contain all VHDs for the selected VM. The $RP[-1] means I want the latest recovery point. If your VM has more than one VHD, then $RI will be an ARRAY.

    Here is the correct syntax for $ROP for your scenario.

    $RO = New-RecoveryOption -HyperVDatasource -TargetServer $SERVER -RecoveryLocation CopyToFolder -TargetLocation "H:\"  -RecoveryType restore

    So here is a sample script. The assumption here is that in group <GROUP> I have only VMs. And Each VM has more than one Recovery Point Available and every VM has more than 1 VHD attached to it.

    $dpmserver = "<DPMSERVER>"
    Connect-DPMServer $DPMServer
    $NamePG = "<GROUP>"
    $pg = Get-ProtectionGroup -DPMServerName $DPMServer | where {$_.FriendlyName -eq $NamePG}
    $ds = Get-Datasource -ProtectionGroup $pg
    $rp = Get-RecoveryPoint -Datasource $ds[0]
    $ri = get-recoverableItem -BrowseType child -Recoverableitem $rp[-1]
    $ro = New-RecoveryOption -HyperVDatasource -TargetServer $dpmserver -RecoveryLocation CopyToFolder -TargetLocation "<location>"  -RecoveryType restore
    Recover-RecoverableItem -RecoveryOption $ro -RecoverableItem $ri[0]


    Thanks, Wilson Souza - MSFT This posting is provided "AS IS" with no warranties, and confers no rights

    Monday, February 20, 2012 8:18 PM
    Moderator
  •  Perfect! You was perfect in your explanation!

     Now I understand. I was wondering if  I was near the correct way.

     With your help, now my script works!


     P.S: For people reading this thread, in the last line, "$ri[0]" should be only "$ri" because it's isn't an array.

     Thanks Wilson Souza.

    • Marked as answer by LenonMga Tuesday, February 21, 2012 2:06 AM
    Tuesday, February 21, 2012 2:05 AM