|
1 | 1 | ---
|
2 | 2 | title: Restore an existing dedicated SQL pool
|
3 | 3 | description: How-to guide for restoring an existing dedicated SQL pool.
|
4 |
| -author: joannapea |
5 |
| -manager: igorstan |
| 4 | +author: realAngryAnalytics |
| 5 | +manager: joannapea |
6 | 6 | ms.service: synapse-analytics
|
7 | 7 | ms.topic: how-to
|
8 | 8 | ms.subservice: sql
|
9 |
| -ms.date: 10/29/2020 |
10 |
| -ms.author: joanpo |
11 |
| -ms.reviewer: igorstan |
| 9 | +ms.date: 04/11/2022 |
| 10 | +ms.author: stevehow |
| 11 | +ms.reviewer: joanpo |
12 | 12 | ms.custom: seo-lt-2019
|
13 | 13 | ---
|
14 | 14 |
|
15 | 15 | # Restore an existing dedicated SQL pool
|
16 | 16 |
|
17 |
| -In this article, you learn how to restore an existing dedicated SQL pool in Azure Synapse Analytics using Azure portal and Synapse Studio. This article applies to both restores and geo-restores. |
| 17 | +In this article, you learn how to restore an existing dedicated SQL pool in Azure Synapse Analytics using Azure portal, Synapse Studio, and PowerShell. This article applies to both restores and geo-restores. |
18 | 18 |
|
19 | 19 | ## Restore an existing dedicated SQL pool through the Synapse Studio
|
20 | 20 |
|
@@ -56,6 +56,150 @@ In this article, you learn how to restore an existing dedicated SQL pool in Azur
|
56 | 56 |
|
57 | 57 | 5. Select **Review + Create**.
|
58 | 58 |
|
| 59 | +## Restore an existing dedicated SQL pool through PowerShell |
| 60 | + |
| 61 | +1. Open PowerShell. |
| 62 | + |
| 63 | +2. Connect to your Azure account and list all the subscriptions associated with your account. |
| 64 | + |
| 65 | +3. Select the subscription that contains the SQL pool to be restored. |
| 66 | + |
| 67 | +4. List the restore points for the dedicated SQL pool. |
| 68 | + |
| 69 | +5. Pick the desired restore point using the RestorePointCreationDate. |
| 70 | + |
| 71 | +6. Restore the dedicated SQL pool to the desired restore point using [Restore-AzSynapseSqlPool](/powershell/module/az.synapse/restore-azsynapsesqlpool?toc=/azure/synapse-analytics/toc.json&bc=/azure/synapse-analytics/breadcrumb/toc.json) PowerShell cmdlet. |
| 72 | + |
| 73 | + 1. To restore the dedicated SQL pool to a different workspace, make sure to specify the other workspace name. This workspace can also be in a different resource group and region. |
| 74 | + 2. To restore to a different subscription, see the [below section](#restore-an-existing-dedicated-sql-pool-to-a-different-subscription-through-powershell). |
| 75 | + |
| 76 | +7. Verify that the restored dedicated SQL pool is online. |
| 77 | + |
| 78 | +```powershell |
| 79 | +
|
| 80 | +$SubscriptionName="<YourSubscriptionName>" |
| 81 | +$ResourceGroupName="<YourResourceGroupName>" |
| 82 | +$WorkspaceName="<YourWorkspaceNameWithoutURLSuffixSeeNote>" # Without sql.azuresynapse.net |
| 83 | +#$TargetResourceGroupName="<YourTargetResourceGroupName>" # uncomment to restore to a different workspace. |
| 84 | +#$TargetWorkspaceName="<YourtargetWorkspaceNameWithoutURLSuffixSeeNote>" |
| 85 | +$SQLPoolName="<YourDatabaseName>" |
| 86 | +$NewSQLPoolName="<YourDatabaseName>" |
| 87 | +
|
| 88 | +Connect-AzAccount |
| 89 | +Get-AzSubscription |
| 90 | +Select-AzSubscription -SubscriptionName $SubscriptionName |
| 91 | +
|
| 92 | +# list all restore points |
| 93 | +Get-AzSynapseSqlPoolRestorePoint -ResourceGroupName $ResourceGroupName -WorkspaceName $WorkspaceName -Name $SQLPoolName |
| 94 | +# Pick desired restore point using RestorePointCreationDate "xx/xx/xxxx xx:xx:xx xx" |
| 95 | +$PointInTime="<RestorePointCreationDate>" |
| 96 | +
|
| 97 | +# Get the specific SQL pool to restore |
| 98 | +$SQLPool = Get-AzSynapseSqlPool -ResourceGroupName $ResourceGroupName -WorkspaceName $WorkspaceName -Name $SQLPoolName |
| 99 | +# Transform Synapse SQL pool resource ID to SQL database ID because currently the restore command only accepts the SQL database ID format. |
| 100 | +$DatabaseID = $SQLPool.Id -replace "Microsoft.Synapse", "Microsoft.Sql" ` |
| 101 | + -replace "workspaces", "servers" ` |
| 102 | + -replace "sqlPools", "databases" |
| 103 | +
|
| 104 | +# Restore database from a restore point |
| 105 | +$RestoredDatabase = Restore-AzSynapseSqlPool –FromRestorePoint -RestorePoint $PointInTime -ResourceGroupName $SQLPool.ResourceGroupName ` |
| 106 | + -WorkspaceName $SQLPool.WorkspaceName -TargetSqlPoolName $NewSQLPoolName –ResourceId $DatabaseID -PerformanceLevel DW100c |
| 107 | +
|
| 108 | +# Use the following command to restore to a different workspace |
| 109 | +#$TargetResourceGroupName = $SQLPool.ResourceGroupName # for restoring to different workspace in same resourcegroup |
| 110 | +#$RestoredDatabase = Restore-AzSynapseSqlPool –FromRestorePoint -RestorePoint $PointInTime -ResourceGroupName $TargetResourceGroupName ` |
| 111 | +# -WorkspaceName $TargetWorkspaceName -TargetSqlPoolName $NewSQLPoolName –ResourceId $DatabaseID -PerformanceLevel DW100c |
| 112 | +
|
| 113 | +# Verify the status of restored database |
| 114 | +$RestoredDatabase.status |
| 115 | +``` |
| 116 | + |
| 117 | +## Restore an existing dedicated SQL pool to a different subscription through PowerShell |
| 118 | +When performing a cross-subscription restore, a synapse workspace dedicated SQL pool can only restore to a standalone dedicated SQL pool (formerly SQL DW). The PowerShell below is similar to the above however there are three main differences: |
| 119 | +- After retrieving the SQL Pool object to be restored, the subscription context needs to be switched to the destination (or target) subscription name. |
| 120 | +- When performing the restore, use the Az.Sql modules instead of the Az.Synapse modules. |
| 121 | +- If it is required to restore the dedicated SQL pool to a Synapse workspace in the destination subscription, an additional restore step is required. |
| 122 | + |
| 123 | +Steps: |
| 124 | + |
| 125 | +1. Open PowerShell. |
| 126 | + |
| 127 | +2. Update Az.Sql Module to 3.8.0 (or greater) if needed |
| 128 | + |
| 129 | +3. Connect to your Azure account and list all the subscriptions associated with your account. |
| 130 | + |
| 131 | +4. Select the subscription that contains the SQL pool to be restored. |
| 132 | + |
| 133 | +5. List the restore points for the dedicated SQL pool. |
| 134 | + |
| 135 | +6. Pick the desired restore point using the RestorePointCreationDate. |
| 136 | + |
| 137 | +7. Select the destination subscription in which the SQL pool should be restored. |
| 138 | + |
| 139 | +8. Restore the dedicated SQL pool to the desired restore point using [Restore-AzSqlDatabase](/powershell/module/az.sql/restore-azsqldatabase?toc=/azure/synapse-analytics/sql-data-warehouse/toc.json&bc=/azure/synapse-analytics/sql-data-warehouse/breadcrumb/toc.json) PowerShell cmdlet. |
| 140 | + |
| 141 | +9. Verify that the restored dedicated SQL pool (formerly SQL DW) is online. |
| 142 | + |
| 143 | +10. If the desired destination is a Synapse Workspace, uncomment the code to perform the additional restore step. |
| 144 | + 1. Create a restore point for the newly created data warehouse. |
| 145 | + 2. Retrieve the last restore point created by using the "Select -Last 1" syntax. |
| 146 | + 3. Perform the restore to the desired Synapse workspace. |
| 147 | + |
| 148 | +```powershell |
| 149 | +$SourceSubscriptionName="<YourSubscriptionName>" |
| 150 | +$SourceResourceGroupName="<YourResourceGroupName>" |
| 151 | +$SourceWorkspaceName="<YourServerNameWithoutURLSuffixSeeNote>" # Without sql.azuresynapse.net |
| 152 | +$SourceSQLPoolName="<YourDatabaseName>" |
| 153 | +$TargetSubscriptionName="<YourTargetSubscriptionName>" |
| 154 | +$TargetResourceGroupName="<YourTargetResourceGroupName>" |
| 155 | +$TargetServerName="<YourTargetServerNameWithoutURLSuffixSeeNote>" # Without sql.azuresynapse.net |
| 156 | +$TargetDatabaseName="<YourDatabaseName>" |
| 157 | +#$TargetWorkspaceName="<YourTargetWorkspaceName>" # uncomment if restore to a synapse workspace is required |
| 158 | +
|
| 159 | +# Update Az.Sql module to the latest version (3.8.0 or above) |
| 160 | +# Update-Module -Name Az.Sql -RequiredVersion 3.8.0 |
| 161 | +
|
| 162 | +Connect-AzAccount |
| 163 | +Get-AzSubscription |
| 164 | +Select-AzSubscription -SubscriptionName $SourceSubscriptionName |
| 165 | +
|
| 166 | +# list all restore points |
| 167 | +Get-AzSynapseSqlPoolRestorePoint -ResourceGroupName $ResourceGroupName -WorkspaceName $WorkspaceName -Name $SQLPoolName |
| 168 | +# Pick desired restore point using RestorePointCreationDate "xx/xx/xxxx xx:xx:xx xx" |
| 169 | +$PointInTime="<RestorePointCreationDate>" |
| 170 | +
|
| 171 | +# Get the specific SQL pool to restore |
| 172 | +$SQLPool = Get-AzSynapseSqlPool -ResourceGroupName $ResourceGroupName -WorkspaceName $WorkspaceName -Name $SQLPoolName |
| 173 | +# Transform Synapse SQL pool resource ID to SQL database ID because currently the restore command only accepts the SQL database ID format. |
| 174 | +$DatabaseID = $SQLPool.Id -replace "Microsoft.Synapse", "Microsoft.Sql" ` |
| 175 | + -replace "workspaces", "servers" ` |
| 176 | + -replace "sqlPools", "databases" |
| 177 | +
|
| 178 | +# Switch context to the destination subscription |
| 179 | +Select-AzSubscription -SubscriptionName $TargetSubscriptionName |
| 180 | +
|
| 181 | +# Restore database from a desired restore point of the source database to the target server in the desired subscription |
| 182 | +$RestoredDatabase = Restore-AzSqlDatabase –FromPointInTimeBackup –PointInTime $PointInTime -ResourceGroupName $TargetResourceGroupName ` |
| 183 | + -ServerName $TargetServerName -TargetDatabaseName $TargetDatabaseName –ResourceId $Database.ID |
| 184 | +
|
| 185 | +# Verify the status of restored database |
| 186 | +$RestoredDatabase.status |
| 187 | +
|
| 188 | +# uncomment below cmdlets to perform one more restore to push the SQL Pool to an existing workspace in the destination subscription |
| 189 | +# # Create restore point |
| 190 | +# New-AzSqlDatabaseRestorePoint -ResourceGroupName $RestoredDatabase.ResourceGroupName -ServerName $RestoredDatabase.ServerName ` |
| 191 | +# -DatabaseName $RestoredDatabase.DatabaseName -RestorePointLabel "UD-001" |
| 192 | +# # Gets the last restore point of the sql dw (will use the RestorePointCreationDate property) |
| 193 | +# $RestorePoint = Get-AzSqlDatabaseRestorePoint -ResourceGroupName $RestoredDatabase.ResourceGroupName -ServerName $RestoredDatabase.ServerName ` |
| 194 | +# -DatabaseName $RestoredDatabase.DatabaseName | Select -Last 1 |
| 195 | +# # Restore to destination synapse workspace |
| 196 | +# $FinalRestore = Restore-AzSynapseSqlPool –FromRestorePoint -RestorePoint $RestorePoint.RestorePointCreationDate -ResourceGroupName $TargetResourceGroupName ` |
| 197 | +# -WorkspaceName $TargetWorkspaceName -TargetSqlPoolName $TargetDatabaseName –ResourceId $RestoredDatabase.ResourceID -PerformanceLevel DW100c |
| 198 | +
|
| 199 | +``` |
| 200 | + |
| 201 | + |
| 202 | + |
59 | 203 | ## Next Steps
|
60 | 204 |
|
61 | 205 | - [Create a restore point](sqlpool-create-restore-point.md)
|
0 commit comments