你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

从已删除的服务器还原专用 SQL 池(以前为 SQL DW)

Tip

Microsoft Fabric Data Warehouse是数据湖基础上的企业规模关系仓库,具有未来就绪的体系结构、内置 AI 和新功能。 如果不熟悉数据仓库,请从Fabric Data Warehouse开始。 现有的指定 SQL 池工作负荷可以升级到 Fabric,以跨数据科学、实时分析和报告访问新功能。

本文介绍如何在意外删除服务器后,使用 PowerShell 在 Azure Synapse Analytics 中还原专用 SQL 池(以前称为 SQL DW)。

注释

本指南仅适用于独立专用 SQL 池(以前称为 SQL DW)。 有关Azure Synapse Analytics工作区中的专用 SQL 池,请参阅从已删除的工作区中存储 SQL 池

在您开始之前

注释

建议使用 Azure Az PowerShell 模块与 Azure 交互。 若要开始,请参阅安装 Azure PowerShell。 若要了解如何迁移到 Az PowerShell 模块,请参阅 将 Azure PowerShell 从 AzureRM 迁移到 Az

从已删除的服务器还原 SQL 池

  1. 打开 PowerShell。

  2. 连接到 Azure 帐户。

  3. 将上下文设置为包含已删除的服务器的订阅。

  4. 指定删除服务器的大致日期时间。

  5. 为要从被删除的服务器中恢复的数据库构造资源标识符。

  6. 从已删除的服务器还原数据库

  7. 验证恢复的数据库的状态是否为“online”。

$SubscriptionID="<YourSubscriptionID>"
$ResourceGroupName="<YourResourceGroupName>"
$ServerName="<YourServerNameWithoutURLSuffixSeeNote>"  # Without database.windows.net
$DatabaseName="<YourDatabaseName>"
$TargetServerName="<YourtargetServerNameWithoutURLSuffixSeeNote>"  
$TargetDatabaseName="<YourDatabaseName>"

Connect-AzAccount
Set-AzContext -SubscriptionId $SubscriptionID

# Define the approximate point in time the server was dropped as DroppedDateTime "yyyy-MM-ddThh:mm:ssZ" (ex. 2022-01-01T16:15:00Z)
$PointInTime="<DroppedDateTime>" 
$DroppedDateTime = Get-Date -Date $PointInTime 

# construct the resource ID of the database you wish to recover. The format required Microsoft.Sql. This includes the approximate date time the server was dropped.
$SourceDatabaseID = "/subscriptions/"+$SubscriptionID+"/resourceGroups/"+$ResourceGroupName+"/providers/Microsoft.Sql/servers/"+$ServerName+"/restorableDroppedDatabases/"+$DatabaseName+","+$DroppedDateTime.ToUniversalTime().ToFileTimeUtc().ToString()

# Restore to target workspace with the source database.
$RestoredDatabase = Restore-AzSqlDatabase -FromDeletedDatabaseBackup -DeletionDate $DroppedDateTime -ResourceGroupName $ResourceGroupName -ServerName $TargetServerName -TargetDatabaseName $TargetDatabaseName -ResourceId $SourceDatabaseID 

# Verify the status of restored database
$RestoredDatabase.status

Troubleshooting

如果收到“处理请求时发生意外错误。”消息,则原始数据库可能由于原始服务器生存期较短而没有可用的恢复点。 通常情况下,这发生在服务器存在时间不到一小时的时候。