创建和自定义恢复计划Create and customize recovery plans

本文介绍如何在 Azure Site Recovery 中为故障转移创建和自定义恢复计划。This article describes how to create and customize a recovery plan for failover in Azure Site Recovery. 在开始之前,请详细了解恢复计划。Before you start, learn more about recovery plans.

创建恢复计划Create a recovery plan

  1. 在恢复服务保管库中,选择“恢复计划 (Site Recovery)” > “+恢复计划”。 In the Recovery Services vault, select Recovery Plans (Site Recovery) > +Recovery Plan.

  2. 在“创建恢复计划”中,为计划指定一个名称。 In Create recovery plan, specify a name for the plan.

  3. 根据计划中的计算机选择一个源和目标,对于部署模型,选择“资源管理器”。 Choose a source and target based on the machines in the plan, and select Resource Manager for the deployment model. 源位置必须具有已针对故障转移和恢复启用的计算机。The source location must have machines that are enabled for failover and recovery.

    故障转移Failover SourceSource TargetTarget
    Azure 到 AzureAzure to Azure 选择 Azure 区域Select the Azure region 选择 Azure 区域Select the Azure region
    VMware 到 AzureVMware to Azure 选择配置服务器Select the configuration server 选择 AzureSelect Azure
    物理计算机到 AzurePhysical machines to Azure 选择配置服务器Select the configuration server 选择 AzureSelect Azure
    Hyper-V 到 AzureHyper-V to Azure 选择 Hyper-V 站点名称Select the Hyper-V site name 选择 AzureSelect Azure
    Hyper-V(由 VMM 托管)到 AzureHyper-V (managed by VMM) to Azure 选择 VMM 服务器Select the VMM server 选择 AzureSelect Azure

    注意以下事项:Note the following:

    • 只能使用恢复计划从源位置故障转移到 Azure。You can only use a recovery plan for failover from the source location to Azure. 不能使用恢复计划从 Azure 进行故障回复。You can't use a recovery plan for failback from Azure.
    • 源位置必须具有已针对故障转移和恢复启用的计算机。The source location must have machines that are enabled for failover and recovery.
    • 恢复计划可以包含具有相同源和目标的计算机。A recovery plan can contain machines with the same source and target.
    • 可以在同一计划中包括由 VMM 托管的 VMware VM 和 Hyper-V VM。You can include VMware VMs and Hyper-V VMs managed by VMM, in the same plan.
    • VMware VM 和物理服务器可以在同一计划中。VMware VMs and physical servers can be in the same plan.
  4. 在“选择项目虚拟机” 中,选择要添加到计划中的计算机(或复制组)。In Select items virtual machines, select the machines (or replication group) that you want to add to the plan. Then click OK.

    • 计算机将添加到计划中的默认组(组 1)。Machines are added default group (Group 1) in the plan. 在故障转移后,此组中的所有计算机将同时启动。After failover, all machines in this group start at the same time.
    • 你只能选择位于你指定的源和目标位置的计算机。You can only select machines are in the source and target locations that you specified.
  5. 单击“确定” 以创建计划。Click OK to create the plan.

向计划中添加组Add a group to a plan

可创建更多组,向各个组中添加计算机,以便可以逐个组指定不同的行为。You create additional groups, and add machines to different groups so that you can specify different behavior on a group-by-group basis. 例如,你可以为每个组指定组中的计算机在故障转移后应该在何时启动,或者为每个组指定自定义操作。For example, you can specify when machines in a group should start after failover, or specify customized actions per group.

  1. 在“恢复计划”中,右键单击该计划 >“自定义”。 In Recovery Plans, right-click the plan > Customize. 默认情况下,在创建计划后,添加到计划中的所有计算机都位于默认的组 1 中。By default, after creating a plan all the machines you added to it are located in default Group 1.
  2. 单击“+组”。 Click +Group. 默认情况下,新组按其添加顺序进行编号。By default a new group is numbered in the order in which it's added. 最多可以添加七个组。You can have up to seven groups.
  3. 选择要移动到新组的计算机,单击“更改组”,然后选择新组。 Select the machine you want to move to the new group, click Change group, and then select the new group. 或者,右键单击组名称 >“受保护的项” ,然后向该组添加计算机。Alternatively, right-click the group name > Protected item, and add machines to the group. 在一个恢复计划中,一台计算机或一个复制组只能属于一个组。A machine or replication group can only belong to one group in a recovery plan.

添加脚本或手动操作Add a script or manual action

可以通过添加脚本或手动操作来自定义恢复计划。You can customize a recovery plan by adding a script or manual action. 请注意:Note that:

  • 如果要复制到 Azure,可以将 Azure 自动化 Runbook 集成到恢复计划中。If you're replicating to Azure you can integrate Azure automation runbooks into your recovery plan.

  • 如果要复制由 System Center VMM 托管的 Hyper-V VM,可以在本地 VMM 服务器上创建一个脚本,并将该脚本包括在恢复计划中。If you're replicating Hyper-V VMs managed by System Center VMM, you can create a script on the on-premises VMM server, and include it in the recovery plan.

  • 添加脚本时,为该组添加一组新的操作。When you add a script, it adds a new set of actions for the group. 例如,使用以下名称创建了组 1 的一组预先步骤:“组 1:预先步骤” 。For example, a set of pre-steps for Group 1 is created with the name Group 1: pre-steps. 该集中将列出所有预先步骤。All pre-steps are listed inside this set. 仅当已部署 VMM 服务器时,才能在主站点上添加脚本。You can add a script on the primary site only if you have a VMM server deployed.

  • 如果添加手动操作,当恢复计划运行时,它会在你插入了手动操作的点停止。If you add a manual action, when the recovery plan runs, it stops at the point at which you inserted the manual action. 此时会显示一个对话框,提示指定该手动操作已完成。A dialog box prompts you to specify that the manual action was completed.

  • 若要在 VMM 服务器上创建脚本,请遵循此文章中的说明。To create a script on the VMM server, follow the instructions in this article.

  • 在故障转移到辅助站点期间,以及从辅助站点故障回复到主站点期间,都可以应用脚本。Scripts can be applied during failover to the secondary site, and during failback from the secondary site to the primary. 支持取决于复制方案:Support depends on your replication scenario:

    方案Scenario 故障转移Failover 故障回复Failback
    Azure 到 AzureAzure to Azure RunbookRunbook RunbookRunbook
    VMware 复制到 AzureVMware to Azure RunbookRunbook 不可用NA
    从包含 VMM 的 Hyper-V 到 AzureHyper-V with VMM to Azure RunbookRunbook 脚本Script
    Hyper-V 站点到 AzureHyper-V site to Azure RunbookRunbook 不可用NA
    从 VMM 到辅助 VMMVMM to secondary VMM 脚本Script 脚本Script
  1. 在恢复计划中,单击应当将操作添加到的步骤,并指定操作应在何时发生:In the recovery plan, click the step to which the action should be added, and specify when the action should occur:
    1. 如果希望操作在故障转移后在组中的计算机启动之前发生,请选择“添加预操作” 。If you want the action to occur before the machines in the group are started after failover, select Add pre-action.
    2. 如果希望操作在故障转移后在组中的计算机启动之后发生,请选择“添加后操作” 。If you want the action to occur after the machines in the group start after failover, select Add post action. 若要移动操作的位置,请选择“上移”或“下移”按钮 。To move the position of the action, select the Move Up or Move Down buttons.
  2. 在“插入操作”中,选择“脚本”或“手动操作” 。In Insert action, select Script or Manual action.
  3. 如果要添加手动操作,请执行以下操作:If you want to add a manual action, do the following:
    1. 为操作键入一个名称,然后键入操作说明。Type in a name for the action, and type in action instructions. 运行故障转移的人员将会看到这些说明。The person running the failover will see these instructions.
    2. 指定是否要为所有类型的故障转移(测试、故障转移、计划内故障转移(如果相关))添加手动操作。Specify whether you want to add the manual action for all types of failover (Test, Failover, Planned failover (if relevant)). Then click OK.
  4. 如果要添加脚本,请执行以下操作:If you want to add a script, do the following:
    1. 如果要添加 VMM 脚本,请选择“故障转移到 VMM 脚本” ,并在“脚本路径” 中键入共享的相对路径。If you're adding a VMM script, select Failover to VMM script, and in Script Path type the relative path to the share. 例如,如果共享位于 \<VMMServerName>\MSSCVMMLibrary\RPScripts,请指定以下路径:\RPScripts\RPScript.PS1。For example, if the share is located at \<VMMServerName>\MSSCVMMLibrary\RPScripts, specify the path: \RPScripts\RPScript.PS1.
    2. 如果要添加 Azure 自动化 Runbook,请指定该 Runbook 所在的 Azure 自动化帐户,并选择相应的 Azure Runbook 脚本If you're adding an Azure automation run book, specify the Azure Automation Account in which the runbook is located, and select the appropriate Azure Runbook Script.
  5. 运行恢复计划的测试故障转移,以确保脚本按预期运行。Run a test failover of the recovery plan to ensure that the script works as expected.

后续步骤Next steps

详细了解如何运行故障转移Learn more about running failovers.