共用方式為


從已刪除的伺服器還原專用 SQL 集區 (之前稱為 SQL DW)

在本文中,您將了解如何在使用 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. 確認已復原資料庫的狀態為「連線」。

$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

疑難排解

如果收到「處理要求時發生未預期的錯誤」訊息,則原始資料庫可能因原始伺服器有效期過短而沒有可用的復原點。 通常是在伺服器存在時間不到一小時的情況下,才會發生此問題。