Edit

Fail over a replicated virtual machine with Hyper-V Replica

After you enable Hyper-V Replica and replicate a virtual machine (VM), you can perform failover operations to switch the VM to the replica host or cluster. This article explains how to perform different types of failover operations by using Hyper-V Replica with Windows Admin Center - Virtualization mode, Hyper-V Manager, Failover Cluster Manager, or PowerShell.

For more information about Hyper-V Replica, or if you need to enable replication or replicate a VM, see the following articles:

Failover scenarios

Hyper-V Replica supports the following three failover scenarios.

  • Test failover: creates a test VM on the replica host or cluster without affecting the ongoing replication. It enables you to verify that the replica VM is functioning correctly. After testing, you can stop the test failover to remove the test VM.

    By default, the test VM is created from the latest recovery point and isn't connected to a network. If you configured extra recovery points, you can choose to create the test VM from one of those points. You can only run one test failover on a VM at a time.

  • Planned failover: use when you can gracefully shut down the primary VM. It helps you to perform an end-to-end validation of your recovery plan. It ensures that all changes are replicated to the replica before switching over, resulting in zero data loss. After the planned failover, you can optionally reverse replication back to the original primary host or cluster, then fail back the VM to the original location.

    Planned failover isn't a substitute for high availability, but it can enable you to keep your workloads running with minimal downtime without data loss. It can be useful for events such as planned maintenance of an entire site or datacenter.

  • Unplanned failover: use when the primary VM is unavailable due to a failure, such as a power outage. It enables you to switch to the replica VM by using the latest recovery point or previous recovery points, if configured. After the unplanned failover, you can complete the failover process and optionally reverse replication back to the original primary host or cluster, then fail back the VM to the original location.

    Unplanned failover is designed for disaster recovery scenarios where the primary VM can't be gracefully shut down. It might result in some data loss, depending on the recovery point selected.

Prerequisites

Before you begin, make sure you meet the following prerequisites:

  • You have a VM that you're replicating by using Hyper-V Replica.

  • The VM's replication health state is Normal. To check the replication health, see Monitor replication progress.

  • A user account that's a member of the Hyper-V Administrators security group on each host. In an Active Directory domain, you can add users or groups to this group by using Group Policy Preferences. Alternatively, the account can be a local administrator on each host. For more information about the Hyper-V Administrators group, see Active Directory Security Groups.

  • If you want to control the static IP address a VM uses after failover, configure static IP injection before performing a failover. For more information, see Configure static IP injection for failover.

Fail over a virtual machine

You need to run a failover operation for each VM. You can only run one failover operation at a time for a VM. You can run each failover operation by using the following combinations:

  • Hyper-V Manager on clusters or single hosts
  • Failover Cluster Manager on clusters
  • PowerShell on clusters or single hosts
  • Windows Admin Center - Virtualization mode on clusters or single hosts.

Select the relevant tab for instructions.

Important

Configuring Hyper-V Replica using Windows Admin Center - Virtualization mode is currently in PREVIEW. This information relates to a prerelease product that may be substantially modified before it's released. Microsoft makes no warranties, expressed or implied, with respect to the information provided here.

For more information about Windows Admin Center - Virtualization mode, see Windows Admin Center - Virtualization mode overview.

Failing over a virtual machine by using Windows Admin Center - Virtualization mode depends on the type of failover you want to perform.

Planned failover using Windows Admin Center

To run a planned failover using Windows Admin Center - Virtualization mode:

  1. Go to your URL for Windows Admin Center - Virtualization mode and sign in.

  2. In the resources pane, expand the host that contains the primary VM you want to perform a planned failover, and then select the VM to enter its overview.

  3. Shut down the VM if it's running. You must shut down the VM to perform a planned failover.

  4. In the Replication section, select Planned Failover.

    Screenshot of Windows Admin Center showing the VM replication overview with replication state, recovery points, and action buttons.

  5. In the pane that opens, review the summary of the planned failover, and then select Fail Over. The failover process begins and the replication state is Prepared for planned failover. If you want to cancel the planned failover at this point, select Cancel Planned Failover.

    Screenshot of Windows Admin Center showing the Planned Failover summary pane with prerequisite checks and replication direction details.

  6. In the resources pane, select the host that has the replica VM.

  7. From the list of tools for the host, select Virtual machines, and then select the replica VM to enter its overview.

  8. In the Replication section, select Failover.

    Screenshot of Windows Admin Center showing the Replication section for a VM with the Planned Failover action highlighted.

  9. In the pane that opens, check the box if you want to Start the Replica virtual machine after failover, depending on your requirements. By default, the replica VM starts after failover. Don't forget to attach the VM to a network if necessary. Then select Fail Over to begin the process. Once the failover is complete, in the replication section the replication state changes to Failover Complete.

    Screenshot of the Planned Failover summary pane in Windows Admin Center showing prerequisite checks and the Fail Over button.

  10. To complete the planned failover, in the Replication section select Remove Recovery Points. For the confirmation, select Yes. This action removes the recovery points and merges the replica checkpoint. At this point, failover is complete. To reverse the replication direction, see Reverse replication using Windows Admin Center - Virtualization mode.

    Screenshot of Windows Admin Center after planned failover showing replication state updated and reverse replication option.

  11. Start the VM if it isn't already running. Don't forget to attach the VM to a network if necessary.

Unplanned failover using Windows Admin Center

To run a test failover using Windows Admin Center - Virtualization mode:

  1. Go to your URL for Windows Admin Center - Virtualization mode and sign in.

  2. In the resources pane, select the host that contains the replica VM you want to perform an unplanned failover.

  3. From the list of tools for the host, select Virtual machines, then select the replica VM to enter its overview.

  4. In the Replication section, select Failover.

    Screenshot of Windows Admin Center showing the VM Replication panel with Failover action for unplanned failover.

  5. In the pane that opens, review the summary of the unplanned failover, select a recovery point to use from the drop-down list, then select Fail Over. The failover process begins.

    Screenshot of the Failover pane in Windows Admin Center showing the recovery point selection list for an unplanned failover.

  6. The process creates a checkpoint for the replica VM. You should start the VM and perform tests that you require to verify that the recovery point you chose functions correctly. Don't forget to attach the VM to a network if necessary.

    If you need to select a different recovery point, you can cancel the failover by selecting Cancel Planned Failover. Then you can choose a different recovery point.

  7. Once you test the VM and don't need to revert to a different recovery point, you need to complete the failover. In the Replication section, select Remove Recovery Points. This action removes the recovery points and merges the checkpoint, which means you can't revert to an earlier recovery point. If you want to keep extra recovery points, you can first export the replica VM before completing failover.

    Screenshot of the context menu option to remove recovery points after an unplanned failover in Windows Admin Center.

    At this point failover is complete, however the replication health shows as Warning because that replication direction isn't configured. To configure reverse replication, see Reverse replication using Windows Admin Center - Virtualization mode.

Test failover using Windows Admin Center - Virtualization mode

To run a test failover using Windows Admin Center - Virtualization mode:

  1. Go to your URL for Windows Admin Center - Virtualization mode and sign in.

  2. In the resources pane, expand the host that contains the replica VM you want to test, then select the VM to enter its overview.

  3. Scroll to the Replication section, then select Test Failover.

  4. In the pane that opens, select the recovery point to use from the drop-down list, then select Failover.

  5. The host creates a duplicate test VM. The VM name is the original VM name with - Test appended. The duplicate VM isn't connected to a network by default. Start the VM and perform tests that you require to verify that it functions correctly.

  6. When you finish testing, in the Replication section select Cancel Test Failover. In the confirmation dialog, select Yes to delete the test VM and discard its data.

Reverse replication using Windows Admin Center - Virtualization mode

After a planned or unplanned failover is complete, you can reverse the replication direction so that changes made on the new primary (formerly the replica) are replicated back to the original primary host or cluster. This step is necessary to restore bidirectional protection.

To configure reverse replication by using Windows Admin Center - Virtualization mode:

  1. Go to your URL for Windows Admin Center - Virtualization mode and sign in.

  2. In the resources pane, expand the host that contains the VM where failover is complete (the VM that is now running as the primary), then select the VM to enter its overview.

  3. Scroll to the Replication section, select Reverse Replication to open the Reverse Replication wizard.

  4. For the Replication Connection tab, complete the following information, then select Replication Configuration to continue:

    1. For Replica server, enter the FQDN or NetBIOS name of the original primary host or Hyper-V Replica Broker.

    2. For Replica server port, enter the port number.

    3. For Authentication type, select the correct authentication method. If you're using certificate-based authentication, select Select to choose the certificate. If you want to compress data, check the box.

  5. For the Replication Configuration tab, configure the replication frequency and recovery point settings, then select Initial Replication to continue.

  6. For the Initial Replication tab, select the initial replication method, then select Review.

  7. Review the summary information, then select Enable Replication.

  8. Reverse replication begins. The replication health returns to Ok and changes are replicated to the original primary host. To return to the original replication direction, you can perform a planned failover.