Monday, October 30, 2017

Recovering Hyper-V data - How to restore a VM

In a private cloud deployment, it is recommended that you deploy all VMs with a golden image (a single parent VHD). Leveraging the same parent VHD and creating differencing disks for the VMs saves disk space. It is recommended that you keep the parent VHD on a high performant storage (for example, SSD) because most read operations will come from this VHD. DPM supports restoring the VM to the original location with or without a parent disk, but there are more steps involved with the latter option. The following steps show an example Alternate Location Recovery where you use DPM to restore a VM that has only a single parent disk and recover it to an alternate location. Start by getting the information from Virtual Machine Manager on which DPM server protects the VM that needs to be recovered to the original location. (This is DPMServer01 in this example.)

1. Delete the corrupt VM:
Stop-VM -ComputerName HyperVHostName -Name VMName 
Remove-VM -ComputerName HyperVHostName -Name VMName

In the preceding command, HyperVHostName is the host on which the corrupt VM is located.

2. Create a symbolic link on the target server:
Enter-PSSession -ComputerName  
cd c:\ cmd /c "mklink /d link

In the preceding command, RecoveryHost is the host on which the VM needs to be recovered and SharedLocation is the storage location for the recovered VM.

3. Connect to the DPM server, get the protection group on the DPM server named DPMServer01, and store the results in the $Pg variable:
$Pg = Get-DPMProtectionGroup -DPMServerName "DPMServer01" | where {$_.Name –eq "PGName"}

4. Get the list of protected and unprotected data in the protection group and store the data source object:
$Ds = Get-DPMDatasource -ProtectionGroup $Pg | where {$_.Computer -eq }

5. Specify the recovery points for the given data source:
$Rps = Get-DPMRecoveryPoint -Datasource $Ds

6. Specify a particular recovery point:
$Rp = $Rps[$Rps.Length – 1]

In the preceding command, - 1 indicates the latest recover point; - 2 would be the recovery point before that, and so on.

7. Recover the item to the alternate location (Hyper-V host):
$Rpo = New-DPMRecoveryOption -HyperVDatasource -TargetServer HyperVHostName -RecoveryLocation AlternateHyperVServer -RecoveryType Recover -TargetLocation  
Recover-RecoverableItem -RecoverableItem $Rp -RecoveryOption $Rpo

8. Connect to the host where the VM has been recovered and perform the following steps:
a. Perform storage migration
Move-VMStorage -ComputerName HyperVHostName -VMName VMName -DestinationStoragePath

b. Re-parent the recovered VM to its original parent:
Get-VMHardDiskDrive VMName | Get-VHD | where {$_.parentPath -ne $null} | Set-VHD -ParentPath

c. Delete the local parent VHD that was just recovered.

d. Delete the symbolic link (“c:\link”) by opening Windows PowerShell session as an elevated user.

e. Configure the recovered VM as a highly available source:
Get-VM –Name VMName | Select VMId, ConfigurationLocation $res = Get-ClusterResource -Name "VMClusterResourceName" -Cluster ComputeClusterName Set-ClusterParameter -InputObject $res -Name VMId -Value -Cluster ComputeClusterName

Source of Information : Microsoft System Center

No comments: