虚拟机的软删除Soft delete for virtual machines

VM 的软删除可保护 VM 的备份免遭意外删除。Soft delete for VMs protects the backups of your VMs from unintended deletion. 即使删除了备份,这些备份也会以软删除状态再保留 14 天。Even after the backups are deleted, they're preserved in soft-delete state for 14 additional days.

备注

软删除只是保护已删除的备份数据。Soft delete only protects deleted backup data. 如果删除未备份的 VM,则软删除功能不会保留数据。If a VM is deleted without a backup, the soft-delete feature won't preserve the data. 应使用 Azure 备份保护所有资源,以确保能够完全复原。All resources should be protected with Azure Backup to ensure full resilience.

使用 Azure 门户对 VM 进行软删除Soft delete for VMs using Azure portal

  1. 若要删除 VM 的备份数据,必须停止备份。To delete the backup data of a VM, the backup must be stopped. 在 Azure 门户中,转到“恢复服务保管库”,右键单击备份项,然后选择“停止备份”。In the Azure portal, go to your Recovery Services vault, right-click on the backup item and choose Stop backup.

    Azure 门户中备份项的屏幕截图

  2. 在接下来的窗口中,会提供用于删除或保留备份数据的选项。In the following window, you'll be given a choice to delete or retain the backup data. 如果依次选择“删除备份数据”、“停止备份”,则不会永久删除 VM 备份,**** ****If you choose Delete backup data and then Stop backup, the VM backup won't be permanently deleted. 而是将备份数据以软删除状态保留 14 天。Rather, the backup data will be retained for 14 days in the soft deleted state. 如果选择“删除备份数据”,则会将一封“删除”警报电子邮件发送到配置的电子邮件 ID,告知用户备份数据将延期保留 14 天。****If Delete backup data is chosen, a delete email alert is sent to the configured email ID informing the user that 14 days remain of extended retention for backup data. 在第 12 天时也会发送一封警报电子邮件,告知还有两天时间可以恢复已删除的数据。Also, an email alert is sent on the 12th day informing that there are two more days left to resurrect the deleted data. 删除会推迟到第 15 天,到时数据将永久删除,同时系统会发送最后一封警报电子邮件,告知数据已永久删除。The deletion is deferred until the 15th day, when permanent deletion will occur and a final email alert is sent informing about the permanent deletion of the data.

    Azure 门户中“停止备份”屏幕的屏幕截图

  3. 在这 14 天内,恢复服务保管库中已软删除的 VM 旁边会显示一个红色的“软删除”图标。During those 14 days, in the Recovery Services vault, the soft deleted VM will appear with a red "soft-delete" icon next to it.

    Azure 门户中处于软删除状态的 VM 的屏幕截图

    备注

    如果保管库中存在任何已软删除的备份项,此时无法删除该保管库。If any soft-deleted backup items are present in the vault, the vault can't be deleted at that time. 请在永久删除了备份项且保管库中未留下任何处于软删除状态的项之后,尝试删除保管库。Try deleting the vault after the backup items are permanently deleted, and there are no items in soft deleted state left in the vault.

  4. 若要还原软删除的 VM,必须先将其取消删除。To restore the soft-deleted VM, it must first be undeleted. 若要取消删除,请选择软删除的 VM,然后选择“取消删除”选项。****To undelete, choose the soft-deleted VM, and then select the option Undelete.

    Azure 门户中“取消删除 VM”的屏幕截图

    窗口中会显示一条警告,指出如果选择取消删除,将取消删除 VM 的所有还原点,这些还原点可用于执行还原操作。A window will appear warning that if undelete is chosen, all restore points for the VM will be undeleted and available for performing a restore operation. VM 将保留为“停止保护并保留数据”状态,备份将会暂停,备份数据将永久保留,且没有任何生效的备份策略。The VM will be retained in a "stop protection with retain data" state with backups paused and backup data retained forever with no backup policy effective.

    Azure 门户中“确认取消删除 VM”的屏幕截图

    此时,还可以通过从选定还原点中选择“还原 VM”来还原 VM。****At this point, you can also restore the VM by selecting Restore VM from the chosen restore point.

    Azure 门户中“还原 VM”选项的屏幕截图

    备注

    只有在用户执行“恢复备份”操作后,垃圾回收器才会运行并清理已过期的恢复点。****Garbage collector will run and clean expired recovery points only after the user performs the Resume backup operation.

  5. 取消删除操作完成后,状态将恢复为“停止备份并保留数据”,然后,你可以选择“恢复备份”。****After the undelete process is completed, the status will return to "Stop backup with retain data" and then you can choose Resume backup. “恢复备份”操作会恢复处于活动状态的、与定义备份和保留计划的用户所选的备份策略相关联的备份项。****The Resume backup operation brings back the backup item in the active state, associated with a backup policy selected by the user defining the backup and retention schedules.

    Azure 门户中“恢复备份”选项的屏幕截图

使用 Azure PowerShell 对 VM 进行软删除Soft delete for VMs using Azure PowerShell

重要

使用 Azure PowerShell 进行软删除所需的 Az.RecoveryServices 版本最低为 2.2.0。The Az.RecoveryServices version required to use soft-delete using Azure PowerShell is minimum 2.2.0. 可使用 Install-Module -Name Az.RecoveryServices -Force 获取最新版本。Use Install-Module -Name Az.RecoveryServices -Force to get the latest version.

如上所述 Azure 门户,使用 Azure PowerShell 时,步骤顺序是相同的。As outlined above for Azure portal, the sequence of steps is same while using Azure PowerShell as well.

使用 Azure PowerShell 删除备份项Delete the backup item using Azure PowerShell

使用 Disable-AzRecoveryServicesBackupProtection PowerShell cmdlet 删除备份项。Delete the backup item using the Disable-AzRecoveryServicesBackupProtection PowerShell cmdlet.

Disable-AzRecoveryServicesBackupProtection -Item $myBkpItem -RemoveRecoveryPoints -VaultId $myVaultID -Force

WorkloadName     Operation            Status               StartTime                 EndTime                   JobID
------------     ---------            ------               ---------                 -------                   -----
AppVM1           DeleteBackupData     Completed            12/5/2019 12:44:15 PM     12/5/2019 12:44:50 PM     0488c3c2-accc-4a91-a1e0-fba09a67d2fb

备份项的“DeleteState”将从“NotDeleted”更改为“ToBeDeleted”。The 'DeleteState' of the backup item will change from 'NotDeleted' to 'ToBeDeleted'. 备份数据会保留 14 天。The backup data will be retained for 14 days. 如果要还原删除操作,则应执行撤消-删除操作。If you wish to revert the delete operation, then undo-delete should be performed.

使用 Azure PowerShell 撤销删除操作Undoing the deletion operation using Azure PowerShell

首先,提取处于软删除状态(也就是即将删除)的相关备份项。First, fetch the relevant backup item that's in soft-delete state (that is, about to be deleted).


Get-AzRecoveryServicesBackupItem -BackupManagementType AzureVM -WorkloadType AzureVM -VaultId $myVaultID | Where-Object {$_.DeleteState -eq "ToBeDeleted"}

Name                                     ContainerType        ContainerUniqueName                      WorkloadType         ProtectionStatus     HealthStatus         DeleteState
----                                     -------------        -------------------                      ------------         ----------------     ------------         -----------
VM;iaasvmcontainerv2;selfhostrg;AppVM1    AzureVM             iaasvmcontainerv2;selfhostrg;AppVM1       AzureVM              Healthy              Passed               ToBeDeleted

$myBkpItem = Get-AzRecoveryServicesBackupItem -BackupManagementType AzureVM -WorkloadType AzureVM -VaultId $myVaultID -Name AppVM1

然后,使用 Undo-AzRecoveryServicesBackupItemDeletion PowerShell cmdlet 执行撤消删除操作。Then, perform the undo-deletion operation using the Undo-AzRecoveryServicesBackupItemDeletion PowerShell cmdlet.

Undo-AzRecoveryServicesBackupItemDeletion -Item $myBKpItem -VaultId $myVaultID -Force

WorkloadName     Operation            Status               StartTime                 EndTime                   JobID
------------     ---------            ------               ---------                 -------                   -----
AppVM1           Undelete             Completed            12/5/2019 12:47:28 PM     12/5/2019 12:47:40 PM     65311982-3755-46b5-8e53-c82ea4f0d2a2

备份项的“DeleteState”将还原为“NotDeleted”。The 'DeleteState' of the backup item will revert to 'NotDeleted'. 但保护仍处于停止状态。But the protection is still stopped. 恢复备份以重新启用保护。Resume the backup to re-enable the protection.

使用 REST API 对 VM 进行软删除Soft delete for VMs using REST API

  • 此处所述,使用 REST API 删除备份。Delete the backups using REST API as mentioned here.
  • 如果你想要撤消这些删除操作,请参阅此处所述的步骤。If you wish to undo these delete operations, refer to steps mentioned here.

如何禁用软删除How to disable soft delete

建议不要禁用此功能。Disabling this feature isn't recommended. 唯一应该考虑禁用软删除的情况是,你打算将受保护的项移到新保管库,需要在删除后重新进行保护,因此等不及要求的 14 天(例如在测试环境中)。有关如何禁用软删除的说明,请参阅启用和禁用软删除The only circumstance where you should consider disabling soft delete is if you're planning on moving your protected items to a new vault, and can't wait the 14 days required before deleting and reprotecting (such as in a test environment.) For instructions on how to disable soft delete, see Enabling and disabling soft delete.

后续步骤Next steps