還原現有的專用 SQL 集區(先前稱為 SQL DW)

在本文中,您將瞭解如何使用 Azure 入口網站 和 PowerShell 還原現有的專用 SQL 集區(先前稱為 SQL DW)。

注意

本指南僅適用於獨立專用 SQL 集區(先前稱為 SQL DW)。 如需 Azure Synapse Analytics 工作區中的專用 SQL 集區,請參閱 還原現有的專用 SQL 集區

開始之前

  1. 確認您的 DTU 容量。 每個集區都是由 具有預設 DTU 配額的邏輯 SQL 伺服器myserver.database.windows.net裝載。 確認伺服器有足夠的剩餘 DTU 配額可供還原的資料庫使用。 若要瞭解如何計算所需的 DTU 或要求更多 DTU,請參閱 要求 DTU 配額變更

  2. 請務必 安裝 Azure PowerShell

    注意

    建議您使用 Azure Az PowerShell 模組來與 Azure 互動。 請參閱安裝 Azure PowerShell 以開始使用。 若要了解如何移轉至 Az PowerShell 模組,請參閱將 Azure PowerShell 從 AzureRM 移轉至 Az

  3. 擁有您想要從中還原的現有還原點。 如果您想要建立新的還原,請參閱 教學課程以建立新的使用者定義還原點

透過 PowerShell 還原現有的專用 SQL 集區 (先前稱為 SQL DW)

若要從還原點還原現有的專用 SQL 集區(先前稱為 SQL DW),請使用 Restore-AzSqlDatabase PowerShell Cmdlet。

  1. 開啟 PowerShell。

  2. 連線 至您的 Azure 帳戶,並列出與您帳戶相關聯的所有訂用帳戶。

  3. 選取包含要還原之資料庫的訂用帳戶。

  4. 列出專用 SQL 集區的還原點(先前稱為 SQL DW)。

  5. 使用 RestorePointCreationDate 挑選所需的還原點。

  6. 使用 Restore-AzSqlDatabase PowerShell Cmdlet 將專用 SQL 集區 (先前稱為 SQL DW) 還原至所需的還原點。

    1. 若要將專用 SQL 集區(先前稱為 SQL DW)還原至不同的伺服器,請務必指定其他伺服器名稱。 此伺服器也可以位於不同的資源群組和區域中。
    2. 若要還原至不同的訂用帳戶,請參閱下 一節
  7. 確認還原的專用 SQL 集區 (先前稱為 SQL DW) 已上線。

  8. 還原完成後,您可以遵循 復原后設定資料庫,以設定復原的專用 SQL 集區(先前稱為 SQL DW)。

    
    $SubscriptionName="<YourSubscriptionName>"
    $ResourceGroupName="<YourResourceGroupName>"
    $ServerName="<YourServerNameWithoutURLSuffixSeeNote>"  # Without database.windows.net
    #$TargetResourceGroupName="<YourTargetResourceGroupName>" # uncomment to restore to a different server.
    #$TargetServerName="<YourtargetServerNameWithoutURLSuffixSeeNote>"  
    $DatabaseName="<YourDatabaseName>"
    $NewDatabaseName="<YourDatabaseName>"
    
    Connect-AzAccount
    Get-AzSubscription
    Select-AzSubscription -SubscriptionName $SubscriptionName
    
    # Or list all restore points
    Get-AzSqlDatabaseRestorePoint -ResourceGroupName $ResourceGroupName -ServerName $ServerName -DatabaseName $DatabaseName
    
    # Get the specific database to restore
    $Database = Get-AzSqlDatabase -ResourceGroupName $ResourceGroupName -ServerName $ServerName -DatabaseName $DatabaseName
    
    # Pick desired restore point using RestorePointCreationDate "xx/xx/xxxx xx:xx:xx xx"
    $PointInTime="<RestorePointCreationDate>"
    
    # Restore database from a restore point
    $RestoredDatabase = Restore-AzSqlDatabase –FromPointInTimeBackup –PointInTime $PointInTime -ResourceGroupName $Database.ResourceGroupName -ServerName $Database.ServerName -TargetDatabaseName $NewDatabaseName –ResourceId $Database.ResourceID
    
    # Use the following command to restore to a different server
    #$TargetResourceGroupName = $Database.ResourceGroupName # for restoring to different server in same resourcegroup 
    #$RestoredDatabase = Restore-AzSqlDatabase –FromPointInTimeBackup –PointInTime $PointInTime -ResourceGroupName $TargetResourceGroupName -ServerName $TargetServerName -TargetDatabaseName $NewDatabaseName –ResourceId $Database.ResourceID
    
    # Verify the status of restored database
    $RestoredDatabase.status
    

透過 Azure 入口網站還原現有的專用 SQL 集區 (先前稱為 SQL DW)

  1. 登入 Azure 入口網站

  2. 流覽至您想要從中還原的專用 SQL 集區。

  3. 在 [概觀] 頁面頂端,選取 [還原]

    Screenshot from the Azure portal, the Overview page navigation bar of a SQL pool, the Restore button is highlighted.

  4. 選取 [自動還原點] 或 [用戶定義的還原點]。 如果專用 SQL 集區 (先前稱為 SQL DW) 沒有任何自動還原點,請等候數小時或建立使用者定義的還原點,再還原。 針對 [用戶定義的還原點],選取現有的還原點或建立新的還原點。 針對 [伺服器],您可以在不同的資源群組和區域中挑選伺服器,或建立新的伺服器。 提供所有參數之後,請選取 [ 檢閱 + 還原]。

    Screenshot from the dedicated SQL pool Restore page of the Azure portal. For Restore point type, the radio button for User-defined restore points is selected.

透過 PowerShell 將現有的專用 SQL 集區 (先前稱為 SQL DW) 還原至不同的訂用帳戶

這是還原現有專用 SQL 集區的類似指引,但下列指示顯示,Get-AzSqlDatabase PowerShell Cmdlet 應該在原始訂用帳戶中執行,而 Restore-AzSqlDatabase PowerShell Cmdlet 應在目的地訂用帳戶中執行。 執行還原的用戶必須擁有來源和目標訂用帳戶的適當許可權。

  1. 開啟 PowerShell。

  2. 如果使用 舊版,請將 Az.Sql 模組更新為 3.8.0(或更新版本 Update-Module)。 否則,它會導致失敗。 若要使用 PowerShell 驗證版本:

    foreach ($i in (get-module -ListAvailable | ?{$_.name -eq 'az.sql'}).Version) { $version = [string]$i.Major + "." + [string]$i.Minor; if ($version -gt 3.7) {write-host "Az.Sql version $version installed. Prequisite met."} else {update-module az.sql} }
    
  3. 連線 至您的 Azure 帳戶,並列出與您帳戶相關聯的所有訂用帳戶。

  4. 選取包含要還原之資料庫的訂用帳戶。

  5. 列出專用 SQL 集區的還原點(先前稱為 SQL DW)。

  6. 使用 RestorePointCreationDate 挑選所需的還原點。

  7. 選取應還原資料庫的目的地訂用帳戶。

  8. 使用 Restore-AzSqlDatabase PowerShell Cmdlet 將專用 SQL 集區 (先前稱為 SQL DW) 還原至所需的還原點。

  9. 確認還原的專用 SQL 集區 (先前稱為 SQL DW) 已上線。

    $SourceSubscriptionName="<YourSubscriptionName>"
    $SourceResourceGroupName="<YourResourceGroupName>"
    $SourceServerName="<YourServerNameWithoutURLSuffixSeeNote>"  # Without database.windows.net
    $SourceDatabaseName="<YourDatabaseName>"
    $TargetSubscriptionName="<YourTargetSubscriptionName>"
    $TargetResourceGroupName="<YourTargetResourceGroupName>"
    $TargetServerName="<YourTargetServerNameWithoutURLSuffixSeeNote>"  # Without database.windows.net
    $TargetDatabaseName="<YourDatabaseName>"
    
    # Update Az.Sql module to the latest version (3.8.0 or above)
    # Update-Module -Name Az.Sql -RequiredVersion 3.8.0
    
    Connect-AzAccount
    Get-AzSubscription
    Select-AzSubscription -SubscriptionName $SourceSubscriptionName
    
    # Pick desired restore point using RestorePointCreationDate "xx/xx/xxxx xx:xx:xx xx"
    $PointInTime="<RestorePointCreationDate>"
    # Or list all restore points
    Get-AzSqlDatabaseRestorePoint -ResourceGroupName $SourceResourceGroupName -ServerName $SourceServerName -DatabaseName $SourceDatabaseName
    
    # Get the specific database to restore
    $Database = Get-AzSqlDatabase -ResourceGroupName $SourceResourceGroupName -ServerName $SourceServerName -DatabaseName $SourceDatabaseName
    
    # Switch context to the destination subscription
    Select-AzSubscription -SubscriptionName $TargetSubscriptionName
    
    # Restore database from a desired restore point of the source database to the target server in the desired subscription
    $RestoredDatabase = Restore-AzSqlDatabase –FromPointInTimeBackup –PointInTime $PointInTime -ResourceGroupName $TargetResourceGroupName -ServerName $TargetServerName -TargetDatabaseName $TargetDatabaseName –ResourceId $Database.ResourceID
    
    # Verify the status of restored database
    $RestoredDatabase.status