To activate the protection of virtual machines, you first create a protection group for host-based replication (HBR).

You create protection groups to enable Site Recovery Manager (SRM) to protect virtual machines. This example shows how to create a protection group for host-based replication by using the Site Recovery Manager SDK for PowerShell.

Prerequisites

  • Verify that your SRM connection is authenticated against the protected (local) and recovery (remote) vCenter Server systems. This example uses the $srmConnection variable from Connect to a Local and to a Remote Site Recovery Manager (SRM) Server.

  • The VMs that you want to protect must be replicated by using vSphere Replication.
  • You must have the required privileges to create protection groups on the recovery site.

Procedure

  1. Get the VM that you want to add to a protection group.
    $replicatedVm = Invoke-SrmGetReplicatedVms `
        -PairingId $srmConnection.ConnectedPairing.PairingId `
        -VcenterId $srmConnection.ConnectedPairing.LocalVcServer.Id `
        -FilterProperty "Name" `
        -Filter "<myVmName>"
  2. Prepare the HBR protection group spec.
    $hbrSpec = Initialize-SrmHbrProtectionGroupSpec -Vms $replicatedVm.List[0].Id
    
  3. Prepare the protection group creation spec.
    For the ReplicationType parameter, specify HBR.
    $protectionGroupSpec = Initialize-SrmProtectionGroupCreateSpec -Name "<myProtectionGroupName>" `
        -ReplicationType HBR `
        -ProtectedVcGuid $srmConnection.ConnectedPairing.LocalVcServer.Id `
        -HbrSpec $hbrSpec
    
  4. Create the protection group task.
    $task = Invoke-SrmCreateGroup -PairingId $srmConnection.ConnectedPairing.PairingId `
        -ProtectionGroupCreateSpec $protectionGroupSpec
  5. Monitor the task progress.
    $task = Invoke-SrmGetTaskInfo -TaskId $task.Id

    $task.Status eventually changes to SUCCESS.

  6. (Optional) Retrieve the protection group you created.
    $protectionGroup = Invoke-SrmGetGroup -PairingId $srmConnection.ConnectedPairing.PairingId `
       -GroupId $task.Result

What to do next

Create a recovery plan for your protection group.