在 Azure 中还原应用Restore an app in Azure

本文演示如何在 Azure 应用服务中还原已事先备份的应用(请参阅在 Azure 中备份应用)。This article shows you how to restore an app in Azure App Service that you have previously backed up (see Back up your app in Azure). 可以根据需要将应用及其链接的数据库还原到以前的状态,或者基于原始应用的备份之一创建新的应用。You can restore your app with its linked databases on-demand to a previous state, or create a new app based on one of your original app's backups. Azure 应用服务支持用于备份和还原的以下数据库:Azure App Service supports the following databases for backup and restore:

从备份还原适用于在标准高级层中运行的应用。Restoring from backups is available to apps running in Standard and Premium tier. 有关向上缩放应用的信息,请参阅在 Azure 中向上缩放应用For information about scaling up your app, see Scale up an app in Azure. 相比于标准层,高级层允许执行更多的每日备份量。Premium tier allows a greater number of daily backups to be performed than Standard tier.

从现有备份还原应用Restore an app from an existing backup

  1. 在 Azure 门户中应用的“设置”页上,单击“备份”以显示“备份”页 。On the Settings page of your app in the Azure portal, click Backups to display the Backups page. 然后,单击“还原” 。Then click Restore.

    选择“立即还原”

  2. 在“还原”页中,首先选择备份源 。In the Restore page, first select the backup source.

    “应用备份” 选项显示当前应用的所有现有备份,使你能够轻松地选择一个。The App backup option shows you all the existing backups of the current app, and you can easily select one. “存储” 选项使你能够从任何现有 Azure 存储帐户和订阅中的容器中选择任何备份 ZIP 文件。The Storage option lets you select any backup ZIP file from any existing Azure Storage account and container in your subscription. 如果正在尝试还原其他应用的备份,请使用“存储” 选项。If you're trying to restore a backup of another app, use the Storage option.

  3. 然后,在“还原目标” 中指定应用还原的目标。Then, specify the destination for the app restore in Restore destination.

    Warning

    如果选择“覆盖” ,则会清除并覆盖当前应用中所有的现有数据。If you choose Overwrite, all existing data in your current app is erased and overwritten. 在单击“确定” 之前,请确保该操作正是想要执行的操作。Before you click OK, make sure that it is exactly what you want to do.

    Warning

    如果应用服务在还原数据库时正在向数据库写入数据,则可能会导致违反主键和数据丢失等症状。If the App Service is writing data to the database while you are restoring it, it may result in symptoms such as violation of PRIMARY KEY and data loss. 建议在开始还原数据库之前先停止应用服务。It is suggested to stop the App Service first before you start to restore the database.

    可选择“现有应用”将应用备份还原到同一资源组中的其他应用 。You can select Existing App to restore the app backup to another app in the same resource group. 使用此选项之前,应已使用应用备份中定义的镜像数据库配置在资源组中创建了其他应用。Before you use this option, you should have already created another app in your resource group with mirroring database configuration to the one defined in the app backup. 还可以创建一个应用,以便将内容还原到其中。You can also Create a New app to restore your content to.

  4. 单击 “确定”Click OK.

从存储帐户中下载或删除备份Download or delete a backup from a storage account

  1. 在 Azure 门户的主“浏览”页中,选择“存储帐户” 。From the main Browse page of the Azure portal, select Storage accounts. 会显示现有存储帐户的列表。A list of your existing storage accounts is displayed.

  2. 选择包含要下载或删除的备份的存储帐户。Select the storage account that contains the backup that you want to download or delete. 此时显示存储帐户页。The page for the storage account is displayed.

  3. 在存储帐户页中,选择所需的容器In the storage account page, select the container you want

    查看容器

  4. 选择要下载或删除的备份文件。Select backup file you want to download or delete.

    ViewContainers

  5. 单击“下载” 或“删除” ,具体取决于要执行的操作。Click Download or Delete depending on what you want to do.

监视还原操作Monitor a restore operation

若要查看有关应用还原操作成功与否的详细信息,请导航到 Azure 门户中的“活动日志”页 。To see details about the success or failure of the app restore operation, navigate to the Activity Log page in the Azure portal.

向下滚动以查找所需的还原操作,并单击以选中。Scroll down to find the desired restore operation and click to select it.

“详细信息”页会显示与还原操作相关的可用信息。The details page displays the available information related to the restore operation.

使用脚本自动执行Automate with scripts

可以使用 Azure CLIAzure PowerShell 通过脚本自动备份管理。You can automate backup management with scripts, using the Azure CLIor Azure PowerShell. ) 或 Azure PowerShell) or Azure PowerShell.

相关示例如下所示:For samples, see: