如何在 Azure Cosmos DB 中从备份还原数据Restore data from a backup in Azure Cosmos DB

如果意外删除了数据库或容器,可以提交支持票证联系 Azure 支持,以便从自动联机备份中还原数据。If you accidentally delete your database or a container, you can file a support ticket or call Azure support to restore the data from automatic online backups. Azure 支持仅适用于选定计划(例如标准计划、开发人员计划以及更高级别的计划)。Azure support is available for selected plans only such as Standard, Developer, and plans higher than them. 不适用于基本计划 。Azure support is not available with Basic plan. 若要了解不同的支持方案,请参阅 Azure 支持计划页。To learn about different support plans, see the Azure support plans page.

若要还原备份的特定快照,Azure Cosmos DB 要求在该快照的备份周期的持续时间内可用。To restore a specific snapshot of the backup, Azure Cosmos DB requires that the data is available for the duration of the backup cycle for that snapshot.

请求还原Request a restore

在请求还原之前,应该了解以下详细信息:You should have the following details before requesting a restore:

  • 准备好订阅 ID。Have your subscription ID ready.

  • 应根据数据被意外删除或修改的方式,准备好提供其他信息。Based on how your data was accidentally deleted or modified, you should prepare to have additional information. 建议提前准备可用的信息,从而尽量减少可能在某些有时效的情况下造成不良影响的来回传输。It is advised that you have the information available ahead to minimize the back-and-forth that can be detrimental in some time sensitive cases.

  • 如果删除了整个 Azure Cosmos DB 帐户,则需要提供删除的帐户的名称。If the entire Azure Cosmos DB account is deleted, you need to provide the name of the deleted account. 如果创建了同名的另一个帐户,请与支持团队共享该帐户,因为这有助于确定要选择的正确帐户。If you create another account with the same name as the deleted account, share that with the support team because it helps to determine the right account to choose. 建议为删除的每个帐户提交不同的支持票证,因为这可以最大限度地减少还原状态的混乱。It's recommended to file different support tickets for each deleted account because it minimizes the confusion of the state of the restore.

  • 如果删除了一个或多个数据库,应提供 Azure Cosmos 帐户及 Azure Cosmos 数据库名,并指定是否存在同名的新数据库。If one or more databases are deleted, you should provide the Azure Cosmos account, as well as the Azure Cosmos database names and specify if a new database with the same name exists.

  • 如果删除了一个或多个容器,应提供 Azure Cosmos 帐户名、数据库名和容器名。If one or more containers are deleted, you should provide the Azure Cosmos account name, database names, and the container names. 并指定是否存在同名容器。And specify if a container with the same name exists.

  • 如果意外删除或损坏了数据,则应在 8 小时内联系 Azure 支持,以便 Azure Cosmos DB 团队帮助你从备份中还原数据。If you have accidentally deleted or corrupted your data, you should contact Azure support within 8 hours so that the Azure Cosmos DB team can help you restore the data from the backups.

    • 如果意外删除了数据库或容器,请提交一个严重性级别为 B 或 C 的 Azure 支持案例。If you have accidentally deleted your database or container, open a Sev B or Sev C Azure support case.
    • 如果意外删除或损坏了容器中的某些文档,请提交一个严重性级别为 A 的支持案例。If you have accidentally deleted or corrupted some documents within the container, open a Sev A support case.

发生数据损坏时,如果容器中的文档遭到修改或删除,请尽快删除容器 。When data corruption occurs and if the documents within a container are modified or deleted, delete the container as soon as possible. 这样就可以避免 Azure Cosmos DB 覆盖备份。By deleting the container, you can avoid Azure Cosmos DB from overwriting the backups. 如果因某种原因而无法删除,应尽快提交票证。If for some reason the deletion is not possible, you should file a ticket as soon as possible. 除了 Azure Cosmos 帐户名、数据库名、容器名以外,还应指定数据可以还原到的时间点。In addition to Azure Cosmos account name, database names, container names, you should specify the point in time to which the data can be restored to. 务必尽量精确,因为这有助于我们确定当时可用的最佳备份。It is important to be as precise as possible to help us determine the best available backups at that time. 指定 UTC 时间也很重要。It is also important to specify the time in UTC.

下面的屏幕截图说明如何为容器(集合/图/表)创建通过 Azure 门户还原数据的支持请求。The following screenshot illustrates how to create a support request for a container(collection/graph/table) to restore data by using Azure portal. 提供其他详细信息(例如数据类型、还原目的、删除数据的时间),以帮助我们设置请求的优先级。Provide additional details such as type of data, purpose of the restore, time when the data was deleted to help us prioritize the request.

使用 Azure 门户创建备份支持请求

还原后的操作Post-restore actions

还原数据后,你会收到有关新帐户名(通常采用 <original-name>-restored1 格式)和帐户要还原到的时间的通知。After you restore the data, you get a notification about the name of the new account (it's typically in the format <original-name>-restored1) and the time when the account was restored to. 还原的帐户与原始帐户具有相同的预配吞吐量、索引策略,并且二者位于同一区域。The restored account will have the same provisioned throughput, indexing policies and it is in same region as the original account. 角色为订阅管理员或共同管理员的用户可以看到还原的帐户。A user who is the subscription admin or a coadmin can see the restored account.

还原数据后,应检查并验证还原的帐户中的数据,确保其中包含你需要的版本。After the data is restored, you should inspect and validate the data in the restored account and make sure it contains the version that you are expecting. 如果一切正常,应该使用 Azure Cosmos DB 更改源Azure 数据工厂将数据迁移回原始帐户。If everything looks good, you should migrate the data back to your original account using Azure Cosmos DB change feed or Azure Data Factory.

建议在迁移数据之后立即删除容器或数据库。It is advised that you delete the container or database immediately after migrating the data. 如果不删除已还原的数据库或容器,它们将在请求单位、存储和流出量方面产生成本。If you don't delete the restored databases or containers, they will incur cost for request units, storage, and egress.

后续步骤Next steps

接下来,可以通过以下文章学习如何将数据迁移回原始帐户:Next you can learn about how to migrate the data back to your original account using the following articles: