如何在 Azure 门户中还原 Azure VM 数据How to restore Azure VM data in Azure portal

本文介绍如何从 Azure 备份恢复服务保管库中存储的恢复点还原 Azure VM 数据。This article describes how to restore Azure VM data from the recovery points stored in Azure Backup Recovery Services vaults.

还原选项Restore options

Azure 备份提供多种方法用于还原 VM。Azure Backup provides a number of ways to restore a VM.

还原选项Restore option 详细信息Details
创建新 VMCreate a new VM 从还原点快速创建并正常运行一个基本的 VM。Quickly creates and gets a basic VM up and running from a restore point.

可以指定 VM 的名称,选择要将此 VM 放入到的资源组和虚拟网络 (VNet),以及为已还原的 VM 指定存储帐户。You can specify a name for the VM, select the resource group and virtual network (VNet) in which it will be placed, and specify a storage account for the restored VM. 新 VM 必须在源 VM 所在的区域创建。The new VM must be created in the same region as the source VM.
还原磁盘Restore disk 还原某个 VM 磁盘,然后使用它来创建新的 VM。Restores a VM disk, which can then be used to create a new VM.

Azure 备份提供一个模板来帮助你自定义和创建 VM。Azure Backup provides a template to help you customize and create a VM.

还原作业会生成一个模板,可以下载该模板,并使用它来指定自定义的 VM 设置和创建 VM。The restore job generates a template that you can download and use to specify custom VM settings, and create a VM.

磁盘将复制到指定的资源组。The disks are copied to the Resource Group you specify.

或者,可将磁盘附加到现有 VM,或使用 PowerShell 创建新的 VM。Alternatively, you can attach the disk to an existing VM, or create a new VM using PowerShell.

若要自定义 VM、添加在备份时不存在的配置设置,或添加必须使用模板或 PowerShell 配置的设置,则此选项非常有用。This option is useful if you want to customize the VM, add configuration settings that weren't there at the time of backup, or add settings that must be configured using the template or PowerShell.
替换现有项Replace existing 可以还原某个磁盘,并使用它来替换现有 VM 上的磁盘。You can restore a disk, and use it to replace a disk on the existing VM.

当前 VM 必须存在。The current VM must exist. 如果已将其删除,则无法使用此选项。If it's been deleted, this option can't be used.

Azure 备份会在替换磁盘之前获取现有 VM 的快照,并将其存储在指定的暂存位置。Azure Backup takes a snapshot of the existing VM before replacing the disk, and stores it in the staging location you specify. 连接到该 VM 的现有磁盘将替换为所选的还原点。Existing disks connected to the VM are replaced with the selected restore point.

快照将复制到保管库,并根据保留策略进行保留。The snapshot is copied to the vault, and retained in accordance with the retention policy.

替换磁盘操作完成后,原始磁盘会保留在资源组中。After the replace disk operation, the original disk is retained in the resource group. 如果不需要原始磁盘,可以选择手动删除它们。You can choose to manually delete the original disks if they are not needed.

对于未加密的托管 VM(包括使用自定义映像创建的 VM),支持替换现有磁盘。Replace existing is supported for unencrypted managed VMs, including VMs created using custom images. 经典 VM 不支持此功能。It is unsupported for classic VMs.

如果还原点中的磁盘数多于或少于当前 VM 中的磁盘数,则还原点中的磁盘数只反映 VM 配置。If the restore point has more or less disks than the current VM, then the number of disks in the restore point will only reflect the VM configuration.

包含链接资源(如用户分配的托管标识Key Vault)的 VM 不支持替换现有磁盘,因为备份客户端应用在执行还原时对这些资源没有权限。Replace existing isn't supported for VMs with linked resources (like user-assigned managed-identity or Key Vault) because the backup client-app doesn't have permissions on these resources while performing the restore.

备注

还可以恢复 Azure VM 上的特定文件和文件夹。You can also recover specific files and folders on an Azure VM. 了解详细信息Learn more.

存储帐户Storage accounts

一些有关存储帐户的详细信息:Some details about storage accounts:

  • 创建 VM:在创建新的 VM 时,该 VM 将放置于指定的存储帐户中。Create VM: When you create a new VM, the VM will be placed in the storage account you specify.
  • 还原磁盘:当你还原磁盘时,该磁盘将复制到指定的存储帐户。Restore disk: When you restore a disk, the disk is copied to the storage account you specify. 还原作业会生成一个模板,你可以下载该模板,并使用它来指定自定义的 VM 设置。The restore job generates a template that you can download and use to specify custom VM settings. 此模板放置于指定的存储帐户中。This template is placed in the specified storage account.
  • 替换磁盘:当你替换现有 VM 上的磁盘时,Azure 备份会在替换该磁盘前创建现有 VM 的快照。Replace disk: When you replace a disk on an existing VM, Azure Backup takes a snapshot of the existing VM before replacing the disk. 该快照存储在指定的暂存位置(存储帐户)中。The snapshot is stored in the staging location (storage account) you specify. 此存储帐户用于在还原过程中临时存储快照,我们建议创建一个新帐户来执行此存储操作,该帐户随后可以被轻松删除。This storage account is used to temporarily store the snapshot during the restore process, and we recommend that you create a new account to do this, that can be easily removed afterwards.
  • 存储帐户位置:存储帐户必须与保管库位于同一个区域中。Storage account location: The storage account must be in the same region as the vault. 仅显示这些帐户。Only these accounts are displayed. 如果该位置中没有任何存储帐户,你需要创建一个存储帐户。If there are no storage accounts in the location, you need to create one.
  • 存储类型:不支持 Blob 存储。Storage type: Blob storage isn't supported.
  • 存储冗余:不支持区域冗余存储 (ZRS)。Storage redundancy: Zone redundant storage (ZRS) isn't supported. 帐户的复制和冗余信息显示在帐户名之后的括号内。The replication and redundancy information for the account is shown in parentheses after the account name.
  • 高级存储Premium storage:
    • 在还原非高级 VM 时,高级存储帐户不受支持。When restoring non-premium VMs, premium storage accounts aren't supported.
    • 在还原托管 VM 时,使用网络规则配置的高级存储帐户不受支持。When restoring managed VMs, premium storage accounts configured with network rules aren't supported.

开始之前Before you start

若要还原 VM(创建新的 VM),请确保对“还原 VM”操作具有正确的基于角色的访问控制 (RBAC) 权限To restore a VM (create a new VM), make sure you have the correct role-based access control (RBAC) permissions for the Restore VM operation.

如果没有权限,则可以还原磁盘,然后在该磁盘还原后,可以使用模板(在执行还原操作的过程中生成)来创建新的 VM。If you don't have permissions, you can restore a disk, and then after the disk is restored, you can use the template that was generated as part of the restore operation to create a new VM.

选择还原点Select a restore point

  1. 在与要还原的 VM 关联的保管库中,单击“备份项” > “Azure 虚拟机”。 In the vault associated with the VM you want to restore, click Backup items > Azure Virtual Machine.

  2. 单击某个 VM。Click a VM. VM 仪表板默认会显示过去 30 天的恢复点。By default on the VM dashboard, recovery points from the last 30 days are displayed. 可以显示 30 天以前的恢复点,或者根据日期、时间范围和不同类型的快照一致性进行筛选,以找到所需的恢复点。You can display recovery points older than 30 days, or filter to find recovery points based on dates, time ranges, and different types of snapshot consistency.

  3. 若要还原 VM,请单击“还原 VM”。To restore the VM, click Restore VM.

    还原点

  4. 选择用于恢复的还原点。Select a restore point to use for the recovery.

选择 VM 还原配置Choose a VM restore configuration

  1. 在“还原配置”中选择一个还原选项:In Restore configuration, select a restore option:

    • 新建:若要创建新的 VM,请使用此选项。Create new: Use this option if you want to create a new VM. 可以使用简单的设置创建 VM,或还原某个磁盘并创建自定义的 VM。You can create a VM with simple settings, or restore a disk and create a customized VM.

    • 替换现有项:若要替换现有 VM 上的磁盘,请使用此选项。Replace existing: Use this option if you want to replace disks on an existing VM.

      还原配置向导

  2. 为选定的还原选项指定设置。Specify settings for your selected restore option.

创建 VMCreate a VM

作为还原选项之一,你可以使用基本的设置从还原点快速创建 VM。As one of the restore options, you can create a VM quickly with basic settings from a restore point.

  1. 在“还原配置” > “新建” > “还原类型”中,选择“创建虚拟机”。 In Restore configuration > Create new > Restore Type, select Create a virtual machine.

  2. 在“虚拟机名称”中,指定订阅中不存在的 VM。In Virtual machine name, specify a VM that doesn't exist in the subscription.

  3. 在“资源组”中,为新 VM 选择现有的资源组,或者创建具有全局唯一名称的新资源组。In Resource group, select an existing resource group for the new VM, or create a new one with a globally unique name. 如果分配的名称已存在,则 Azure 将为该组分配与 VM 相同的名称。If you assign a name that already exists, Azure assigns the group the same name as the VM.

  4. 在“虚拟网络”中,选择要将 VM 放入到的 VNet。In Virtual network, select the VNet in which the VM will be placed. 此时会显示与订阅关联的所有 VNet。All VNets associated with the subscription are displayed. 选择子网。Select the subnet. 默认已选择第一个子网。The first subnet is selected by default.

  5. 在“存储位置”中,为该 VM 指定存储帐户。In Storage Location, specify the storage account for the VM. 了解详细信息Learn more.

    还原配置向导

  6. 在“还原配置”中,选择“确定”。 In Restore configuration, select OK. 在“还原”中,选择“还原”以触发还原操作。 In Restore, click Restore to trigger the restore operation.

还原磁盘Restore disks

作为还原选项之一,你可以从还原点快速创建磁盘。As one of the restore options, you can create a disk from a restore point. 然后可以使用该磁盘执行以下操作之一:Then with the disk, you can do one of the following:

  • 使用执行还原操作期间生成的模板来自定义设置,并触发 VM 部署。Use the template that is generated during the restore operation to customize settings, and trigger VM deployment. 编辑默认模板设置,然后提交模板进行 VM 部署。You edit the default template settings, and submit the template for VM deployment.
  • 将已还原的磁盘附加到现有 VM。Attach restored disks to an existing VM.
  • 使用 PowerShell 从已还原的磁盘创建新的 VMCreate a new VM from the restored disks using PowerShell.
  1. 在“还原配置” > “新建” > “还原类型”中,选择“还原磁盘”。 In Restore configuration > Create new > Restore Type, select Restore disks.

  2. 在“资源组”中,为已还原的磁盘选择现有资源组,或者创建具有全局唯一名称的新资源组。In Resource group, select an existing resource group for the restored disks, or create a new one with a globally unique name.

  3. 在“存储帐户”中,指定要将 VHD 复制到的帐户。In Storage account, specify the account to which to copy the VHDs. 了解详细信息Learn more.

    已完成恢复配置

  4. 在“还原配置”中,选择“确定”。 In Restore configuration, select OK. 在“还原”中,选择“还原”以触发还原操作。 In Restore, click Restore to trigger the restore operation.

当虚拟机使用托管磁盘,而你选择“创建虚拟机”选项时,Azure 备份不使用指定的存储帐户。When your virtual machine uses managed disks and you select the Create virtual machine option, Azure Backup doesn't use the specified storage account. 在使用“还原磁盘”和“即时还原”时,存储帐户仅用于存储模板。In the case of Restore disks and Instant Restore, the storage account is used only for storing the template. 在指定的资源组中创建了托管磁盘。Managed disks are created in the specified resource group. 当虚拟机使用非托管磁盘时,它们会以 Blob 的形式还原到存储帐户。When your virtual machine uses unmanaged disks, they are restored as blobs to the storage account.

使用模板自定义还原 VMUse templates to customize a restored VM

还原磁盘后,使用执行还原操作期间生成的模板进行自定义并创建新的 VM:After the disk is restored, use the template that was generated as part of the restore operation to customize and create a new VM:

  1. 打开相关作业的“还原作业详细信息”。Open Restore Job Details for the relevant job.

  2. 在“还原作业详细信息”中,选择“部署模板”启动模板部署 。In Restore Job Details, select Deploy Template to initiate template deployment.

    深入到还原作业

  3. 若要自定义模板中提供的 VM 设置,请单击“编辑模板”。To customize the VM setting provided in the template, click Edit template. 若要添加其他自定义项,请单击“编辑参数”。If you want to add more customizations, click Edit parameters.

    加载模板部署

  4. 输入 VM 的自定义值,接受“条款和条件”,然后单击“购买”。 Enter the custom values for the VM, accept the Terms and Conditions and click Purchase.

    提交模板部署

替换现有磁盘Replace existing disks

作为还原选项之一,你可以使用选定的还原点替换现有的 VM 磁盘。As one of the restore options, you can replace an existing VM disk with the selected restore point. 查看所有还原选项。Review all restore options.

  1. 在“还原配置”中,单击“替换现有项”。 In Restore configuration, click Replace existing.

  2. 在“还原类型”中,选择“替换磁盘”。 In Restore Type, select Replace disk/s. 这是用于替换现有 VM 磁盘的还原点。This is the restore point that will be used replace existing VM disks.

  3. 在“暂存位置”中,指定在还原过程中应将当前托管磁盘的快照保存到的位置。In Staging Location, specify where snapshots of the current managed disks should be saved during the restore process. 了解详细信息Learn more.

    还原配置向导“替换现有”

采用特殊配置还原 VMRestore VMs with special configurations

在许多常见情况下,可能需要还原 VM。There are a number of common scenarios in which you might need to restore VMs.

方案Scenario 指南Guidance
通过混合使用权益还原 VMRestore VMs using Hybrid Use Benefit 如果 Windows VM 使用混合使用权益 (HUB) 许可,请还原磁盘,并使用提供的模板(将“许可证类型”设置为“Windows_Server”)或 PowerShell 创建新的 VM。 If a Windows VM uses Hybrid Use Benefit (HUB) licensing, restore the disks, and create a new VM using the provided template (with License Type set to Windows_Server), or PowerShell. 也可以在创建 VM 后应用此设置。This setting can also be applied after creating the VM.
在发生 Azure 数据中心灾难期间还原 VMRestore VMs during an Azure datacenter disaster 如果保管库使用 GRS 并且 VM 的主数据中心出现故障,Azure 备份支持将已备份的 VM 还原到配对的数据中心。If the vault uses GRS and the primary datacenter for the VM goes down, Azure Backup supports restoring backed-up VMs to the paired datacenter. 在配对的数据中心选择一个存储帐户,然后像平时一样进行还原。You select a storage account in the paired datacenter, and restore as normal. Azure 备份使用配对区域中的计算服务来创建已还原的 VM。Azure Backup uses the compute service in the paired region to create the restored VM. 详细了解数据中心复原能力。Learn more about datacenter resiliency.
还原单个域中的单个域控制器 VMRestore single domain controller VM in single domain 像还原其他任何 VM 一样还原该 VM。Restore the VM like any other VM. 请注意:Note that:

从 Active Directory 的角度来看,Azure VM 与任何其他 VM 类似。From an Active Directory perspective, the Azure VM is like any other VM.

还可使用目录服务还原模式 (DSRM),因此所有 Active Directory 恢复方案都是可行的。Directory Services Restore Mode (DSRM) is also available, so all Active Directory recovery scenarios are viable. 详细了解虚拟化域控制器的备份和还原注意事项。Learn more about backup and restore considerations for virtualized domain controllers.
还原单一域中的多个域控制器 VMRestore multiple domain controller VMs in single domain 如果可以通过网络访问同一个域中的其他域控制器,则可以像还原任何 VM 一样还原域控制器。If other domain controllers in the same domain can be reached over the network, the domain controller can be restored like any VM. 对于域中剩余的最后一个域控制器,或者在隔离的网络中执行恢复,请使用林恢复If it's the last remaining domain controller in the domain, or a recovery in an isolated network is performed, use a forest recovery.
还原一个林中的多个域Restore multiple domains in one forest 建议使用林恢复We recommend a forest recovery.
裸机还原Bare-metal restore Azure VM 与本地虚拟机监控程序之间的主要差别是 Azure 中不提供 VM 控制台。The major difference between Azure VMs and on-premises hypervisors is that there's no VM console available in Azure. 某些方案(如使用裸机恢复 (BMR) 类型备份进行恢复)需要控制台。A console is required for certain scenarios, such as recovering by using a bare-metal recovery (BMR)-type backup. 但是,通过保管库进行 VM 还原完全取代了 BMR。However, VM restore from the vault is a full replacement for BMR.
还原采用特殊网络配置的 VMRestore VMs with special network configurations 特殊网络配置包括使用内部或外部负载均衡、使用多个 NIC 或多个保留 IP 地址的 VM。Special network configurations include VMs using internal or external load balancing, using multiple NICS, or multiple reserved IP addresses. 可使用还原磁盘选项还原这些 VM。You restore these VMs by using the restore disk option. 此选项会将 VHD 复制到指定的存储帐户,然后,你可以根据配置,使用内部外部负载均衡器、多个 NIC多个保留 IP 地址创建 VM。This option makes a copy of the VHDs into the specified storage account, and you can then create a VM with an internal or external load balancer, multiple NICS, or multiple reserved IP addresses, in accordance with your configuration.
NIC/子网上的网络安全组 (NSG)Network Security Group (NSG) on NIC/Subnet Azure VM 备份支持在 VNet、子网和 NIC 级别备份和还原 NSG 信息。Azure VM backup supports Backup and Restore of NSG information at vnet, subnet, and NIC level.

跟踪还原操作Track the restore operation

触发还原操作后,备份服务会创建一个作业用于跟踪。After you trigger the restore operation, the backup service creates a job for tracking. Azure 备份在门户中显示有关作业的通知。Azure Backup displays notifications about the job in the portal. 如果未显示通知,请选择“通知”符号,然后选择“查看所有作业”,此时即可看到“还原过程状态”。 If they aren't visible, select the Notifications symbol, and then select View all Jobs to see the Restore Process Status.

已触发还原

按如下所述跟踪还原:Track restore as follows:

  1. 若要查看针对作业的操作,请单击通知超链接。To view operations for the job, click the notifications hyperlink. 或者,在保管库中单击“备份作业”,然后单击相关的 VM。Alternatively, in the vault, click Backup jobs, and then click the relevant VM.

    保管库中的 VM 列表

  2. 若要监视还原进度,请单击状态为“正在进行”的任何还原作业。To monitor restore progress, click any restore job with a status of In-progress. 此时会出现进度栏,其中显示了有关还原进度的信息:This displays the progress bar, which displays information about the restore progress:

    • 还原估计所需时间:最初提供完成还原操作所需的时间。Estimated time of restore: Initially provides the time taken to complete the restore operation. 随着操作的不断进行,该时间会不断减少,还原操作完成后,将显示为 0。As the operation progresses, the time taken reduces and reaches zero when the restore operation finishes.
    • 还原百分比Percentage of restore. 显示还原操作的完成百分比。Shows the percentage of restore operation that's done.
    • 传输的字节数:如果通过创建新的 VM 进行还原,此字段将显示已传输的字节数,以及有待传输的字节总数。Number of bytes transferred: If you're restoring by creating a new VM, it shows the bytes that were transferred against the total number of bytes to be transferred.

还原后的步骤Post-restore steps

还原 VM 之后,还需要注意一些事项:There are a number of things to note after restoring a VM:

  • 将安装备份配置期间存在的扩展,但不会启用这些扩展。Extensions present during the backup configuration are installed, but not enabled. 如果出现问题,请重新安装这些扩展。If you see an issue, reinstall the extensions.

  • 如果备份的 VM 使用了静态 IP 地址,则还原的 VM 将使用动态 IP 地址,以避免冲突。If the backed-up VM had a static IP address, the restored VM will have a dynamic IP address to avoid conflict. 将静态 IP 地址添加到还原的 VMYou can add a static IP address to the restored VM.

  • 还原的 VM 没有可用性集。A restored VM doesn't have an availability set. 如果使用了还原磁盘选项,则使用提供的模板或 PowerShell 从磁盘创建 VM 时,可以指定可用性集If you use the restore disk option, then you can specify an availability set when you create a VM from the disk using the provided template or PowerShell.

  • 如果使用基于 cloud-init 的 Linux 分发版(例如 Ubuntu),出于安全原因,还原后将阻止密码。If you use a cloud-init-based Linux distribution, such as Ubuntu, for security reasons the password is blocked after the restore. 请在还原的 VM 上使用 VMAccess 扩展 重置密码Use the VMAccess extension on the restored VM to reset the password. 我们建议在这些分发版中使用 SSH 密钥,这样,在还原后就无需重置密码。We recommend using SSH keys on these distributions, so you don't need to reset the password after the restore.

  • 如果在还原后因 VM 与域控制器的关系被破坏而无法访问 VM,请执行以下步骤,以便启动 VM:If you're unable to access a VM once restored due to the VM having a broken relationship with the domain controller, then follow the steps below to bring up the VM:

    • 将 OS 磁盘作为数据磁盘附加到恢复的 VM。Attach OS disk as a data disk to a recovered VM.
    • 如果发现 Azure 代理无响应,请按此链接的要求手动安装 VM 代理。Manually install VM agent if Azure Agent is found to be unresponsive by following this link.
    • 在 VM 上启用串行控制台访问,以便通过命令行访问 VMEnable Serial Console access on VM to allow command-line access to VM
      bcdedit /store <drive letter>:\boot\bcd /enum
      bcdedit /store <VOLUME LETTER WHERE THE BCD FOLDER IS>:\boot\bcd /set {bootmgr} displaybootmenu yes
      bcdedit /store <VOLUME LETTER WHERE THE BCD FOLDER IS>:\boot\bcd /set {bootmgr} timeout 5
      bcdedit /store <VOLUME LETTER WHERE THE BCD FOLDER IS>:\boot\bcd /set {bootmgr} bootems yes
      bcdedit /store <VOLUME LETTER WHERE THE BCD FOLDER IS>:\boot\bcd /ems {<<BOOT LOADER IDENTIFIER>>} ON
      bcdedit /store <VOLUME LETTER WHERE THE BCD FOLDER IS>:\boot\bcd /emssettings EMSPORT:1 EMSBAUDRATE:115200
    
    • 重新生成 VM 后,请通过 Azure 门户重置本地管理员帐户和密码When the VM is rebuilt use Azure portal to reset local administrator account and password

    • 使用串行控制台访问和 CMD,使 VM 从域中脱离Use Serial console access and CMD to disjoin VM from domain

      cmd /c "netdom remove <<MachineName>> /domain:<<DomainName>> /userD:<<DomainAdminhere>> /passwordD:<<PasswordHere>> /reboot:10 /Force"
      
  • VM 脱离并重启后,即可使用本地管理员凭据成功地通过 RDP 连接到 VM,并将 VM 成功地重新加入域。Once the VM is disjoined and restarted, you will be able to successfully RDP to the VM with local admin credentials and rejoin VM back to domain successfully.

备份已还原的 VMBacking up restored VMs

  • 如果将 VM 还原到了与最初备份 VM 时所在的资源组同名的资源组,则还原之后,会继续备份该 VM。If you restored a VM to the same resource group with the same name as the originally backed-up VM, backup continues on the VM after restore.
  • 如果将 VM 还原到了其他资源组或者为还原的 VM 指定了其他名称,则需要为还原的 VM 设置备份。If you restored the VM to a different resource group or you specified a different name for the restored VM, you need to set up backup for the restored VM.

后续步骤Next steps

  • 如果在还原过程中遇到难题,请查看常见问题和错误。If you experience difficulties during the restore process, review common issues and errors.
  • 还原 VM 后,请了解如何管理虚拟机After the VM is restored, learn about managing virtual machines