Item Level Recovery of Hyper-V machine in DPM Server using Powershell RRS feed

  • Question

  • Hi All,

    I am trying to restore a file present in a machine inside my Hyper-V, Manually through DPM Server GUI I can perform Item Level recovery very easily but through PowerShell I am not able to perform the same. Instead it is recovering the .vdx files which i don't want. I only need a specific Folder inside the Hyper V machine to be recovered.

    My Code is  :

    $DPMServer = "DPMServer1" ## Enter the DPM Server Name

    $Agent_Hostname = "Agent" ## Enter the AGENT Server Hostname 

    $Protection_GroupName = "Hyper-V" ## Enter the Protection Group Name

    $Protection_ObjectName = "Test-DPMBackup" ## Enter the Protection object Name, Files are present inside it that needs to be recovered. If I double click on it will show NEW VOLUME then D:\Inetpub or something, I need to recover this Inetpub folder only 

    # Task 1 : Selecting the Specific Protection Group

    $PGroup = Get-DPMProtectionGroup -DPMServerName $DPMServer
    $PGroup = $PGroup | ?{$_.Name -eq $Protection_GroupName }

    # Task 2 : Selecting the Specific Protection Object

    $PObjects = Get-DPMDatasource -ProtectionGroup $PGroup
    $PObjects = $PObjects | ?{$_.Name -eq $Protection_ObjectName}

    $RPoint = Get-DPMRecoveryPoint -Datasource $PObjects | Sort -Property RepresentedPointInTime -Descending | Select-Object -First 1
    $ROption = New-DPMRecoveryOption -HyperVDataSource -TargetServer $DPMServer -RecoveryLocation CopyToFolder -TargetLocation "C:\BackupTemp\" -RecoveryType restore

    Restore-DPMRecoverableItem -RecoverableItem $RPoint -RecoveryOption $ROption

    Tuesday, January 3, 2017 3:05 PM

All replies

  • This works for me on DPM 2016. It might work for earlier versions by using equivalent cmdlets.

    $DPMServerName = "MyDPMServer" #DPM server $RestoreToServer = "MyTargetServer" #Target restore server. Must be protected by the same DPM server as the source. $RestoreToPath = "H:\RESTORE\" #Valid path on the target server. $ProtectionGroupName = "MyProtectionGroup" #DPM protection group of the source VM. $RestoreFromVM = "MySourceVM" #VM that contains items to recover $RestoreItem = "MyRestoreItem" #This should be a folder or file you want to restore. You might need to define more variables to traverse the directory structure as noted later. $DPMProtectionGroup = Get-DPMProtectionGroup -DPMServerName $DPMServerName | Where-Object FriendlyName -EQ $ProtectionGroupName #Get the protection group object $DPMDataSource = Get-DPMDatasource -ProtectionGroup $DPMProtectionGroup | Where-Object Name -EQ $RestoreFromVM #Get the VM backup as a DPM datasource $DPMRecoveryPoint = Get-DPMRecoveryPoint -Datasource $DPMDataSource | Sort -Property RepresentedPointInTime -Descending | Select-Object -First 1 #Get the latest recovery point $DPMRecoveryOption = New-DPMRecoveryOption -HyperVDatasource -TargetServer $RestoreToServer -RecoveryLocation CopyToFolder -TargetLocation $RestoreToPath -RestoreSecurity -RecoveryType Restore #Set up restore options $DPMItemVM = Get-DPMRecoverableItem -RecoverableItem $DPMRecoveryPoint -BrowseType Child #Select the VM as a recoverable item. $DPMItemVolume = Get-DPMRecoverableItem -RecoverableItem $DPMItemVM -BrowseType Child #Select the VM volume. If there are multiple volumes in the VM you might need to filter this with where-object. #Select the directory to recover. I don't know a way to drill down directly to the directory or item so you might have to repeat this process to traverse the tree. $DPMItemDirectory = Get-DPMRecoverableItem -RecoverableItem $DPMItemVolume -BrowseType Child | Where-Object Name -EQ $RestoreItem $DPMRestore = Restore-DPMRecoverableItem -RecoverableItem $DPMItemDirectory -RecoveryOption $DPMRecoveryOption #Perform the restore.

    $DPMRestore.HasCompleted #Check the recovery status. Run again as needed or in some loop. #Your item will be recovered to the path you chose + DestinationForAlternateRecovery of the recovery point. Use robocopy or another method to complete the restore. $DPMRecoveryPoint.DestinationForAlternateRecovery

    • Edited by ClubHouseKey Thursday, August 9, 2018 2:39 PM
    • Proposed as answer by ClubHouseKey Friday, November 9, 2018 7:14 PM
    Thursday, August 9, 2018 2:37 PM