Skip to content

Commit b663ee8

Browse files
Merge pull request #194682 from realAngryAnalytics/20220406-xsubrestore
20220406 xsubrestore
2 parents 20eb9e0 + fefe381 commit b663ee8

File tree

5 files changed

+226
-14
lines changed

5 files changed

+226
-14
lines changed

articles/synapse-analytics/backuprestore/restore-sql-pool-from-deleted-workspace.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: realAngryAnalytics
55
ms.service: synapse-analytics
66
ms.topic: how-to
77
ms.subservice: sql
8-
ms.date: 03/29/2022
8+
ms.date: 04/11/2022
99
ms.author: stevehow
1010
ms.reviewer: wiassaf
1111
---
@@ -24,11 +24,17 @@ In this article, you learn how to restore a dedicated SQL pool in Azure Synapse
2424
## Restore the SQL pool from the dropped workspace
2525

2626
1. Open PowerShell
27+
2728
2. Connect to your Azure account.
29+
2830
3. Set the context to the subscription that contains the workspace that was dropped.
31+
2932
4. Specify the approximate datetime the workspace was dropped.
33+
3034
5. Construct the resource ID for the database you wish to recover from the dropped workspace.
35+
3136
6. Restore the database from the dropped workspace
37+
3238
7. Verify the status of the recovered database as 'online'.
3339

3440

articles/synapse-analytics/backuprestore/restore-sql-pool.md

Lines changed: 150 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
---
22
title: Restore an existing dedicated SQL pool
33
description: How-to guide for restoring an existing dedicated SQL pool.
4-
author: joannapea
5-
manager: igorstan
4+
author: realAngryAnalytics
5+
manager: joannapea
66
ms.service: synapse-analytics
77
ms.topic: how-to
88
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
1212
ms.custom: seo-lt-2019
1313
---
1414

1515
# Restore an existing dedicated SQL pool
1616

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.
1818

1919
## Restore an existing dedicated SQL pool through the Synapse Studio
2020

@@ -56,6 +56,150 @@ In this article, you learn how to restore an existing dedicated SQL pool in Azur
5656

5757
5. Select **Review + Create**.
5858

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+
59203
## Next Steps
60204

61205
- [Create a restore point](sqlpool-create-restore-point.md)

articles/synapse-analytics/sql-data-warehouse/sql-data-warehouse-restore-active-paused-dw.md

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
title: Restore an existing dedicated SQL pool (formerly SQL DW)
33
description: How-to guide for restoring an existing dedicated SQL pool in Azure Synapse Analytics.
4-
author: anumjs
5-
manager: craigg
4+
author: realAngryAnalytics
5+
manager: joannapea
66
ms.service: synapse-analytics
77
ms.topic: conceptual
88
ms.subservice: sql-dw
9-
ms.date: 11/13/2020
10-
ms.author: joanpo
11-
ms.reviewer: igorstan
9+
ms.date: 04/11/2022
10+
ms.author: stevehow
11+
ms.reviewer: joannapea
1212
ms.custom: seo-lt-2019, devx-track-azurepowershell
1313
---
1414

@@ -42,7 +42,7 @@ To restore an existing dedicated SQL pool (formerly SQL DW) from a restore point
4242
6. Restore the dedicated SQL pool (formerly SQL DW) 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.
4343

4444
1. To restore the dedicated SQL pool (formerly SQL DW) to a different server, make sure to specify the other server name. This server can also be in a different resource group and region.
45-
2. To restore to a different subscription, use the 'Move' button to move the server to another subscription.
45+
2. To restore to a different subscription, see the [below section](#restore-an-existing-dedicated-sql-pool-formerly-sql-dw-to-a-different-subscription-through-powershell).
4646

4747
7. Verify that the restored dedicated SQL pool (formerly SQL DW) is online.
4848

@@ -94,6 +94,62 @@ $RestoredDatabase.status
9494

9595
![Automatic Restore Points](./media/sql-data-warehouse-restore-active-paused-dw/restoring-11.png)
9696

97+
## Restore an existing dedicated SQL pool (formerly SQL DW) to a different subscription through PowerShell
98+
This is similar guidance to restoring an existing dedicated SQL pool, however the below instructions show that [Get-AzSqlDatabase](/powershell/module/az.sql/Get-AzSqlDatabase?toc=/azure/synapse-analytics/sql-data-warehouse/toc.json&bc=/azure/synapse-analytics/sql-data-warehouse/breadcrumb/toc.json) PowerShell cmdlet should be performed in the originating subscription while the [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 should be performed in the destination subscription. Note that the user performing the restore must have proper permissions in both the source and target subscriptions.
99+
100+
1. Open PowerShell.
101+
102+
2. Update Az.Sql Module to 3.8.0 (or greater) if needed
103+
104+
3. Connect to your Azure account and list all the subscriptions associated with your account.
105+
106+
4. Select the subscription that contains the database to be restored.
107+
108+
5. List the restore points for the dedicated SQL pool (formerly SQL DW).
109+
110+
6. Pick the desired restore point using the RestorePointCreationDate.
111+
112+
7. Select the destination subscription in which the database should be restored.
113+
114+
8. Restore the dedicated SQL pool (formerly SQL DW) 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.
115+
116+
9. Verify that the restored dedicated SQL pool (formerly SQL DW) is online.
117+
118+
```powershell
119+
$SourceSubscriptionName="<YourSubscriptionName>"
120+
$SourceResourceGroupName="<YourResourceGroupName>"
121+
$SourceServerName="<YourServerNameWithoutURLSuffixSeeNote>" # Without database.windows.net
122+
$SourceDatabaseName="<YourDatabaseName>"
123+
$TargetSubscriptionName="<YourTargetSubscriptionName>"
124+
$TargetResourceGroupName="<YourTargetResourceGroupName>"
125+
$TargetServerName="<YourTargetServerNameWithoutURLSuffixSeeNote>" # Without database.windows.net
126+
$TargetDatabaseName="<YourDatabaseName>"
127+
128+
# Update Az.Sql module to the latest version (3.8.0 or above)
129+
# Update-Module -Name Az.Sql -RequiredVersion 3.8.0
130+
131+
Connect-AzAccount
132+
Get-AzSubscription
133+
Select-AzSubscription -SubscriptionName $SourceSubscriptionName
134+
135+
# Pick desired restore point using RestorePointCreationDate "xx/xx/xxxx xx:xx:xx xx"
136+
$PointInTime="<RestorePointCreationDate>"
137+
# Or list all restore points
138+
Get-AzSqlDatabaseRestorePoint -ResourceGroupName $SourceResourceGroupName -ServerName $SourceServerName -DatabaseName $SourceDatabaseName
139+
140+
# Get the specific database to restore
141+
$Database = Get-AzSqlDatabase -ResourceGroupName $SourceResourceGroupName -ServerName $SourceServerName -DatabaseName $SourceDatabaseName
142+
143+
# Switch context to the destination subscription
144+
Select-AzSubscription -SubscriptionName $TargetSubscriptionName
145+
146+
# Restore database from a desired restore point of the source database to the target server in the desired subscription
147+
$RestoredDatabase = Restore-AzSqlDatabase –FromPointInTimeBackup –PointInTime $PointInTime -ResourceGroupName $TargetResourceGroupName -ServerName $TargetServerName -TargetDatabaseName $TargetDatabaseName –ResourceId $Database.ResourceID
148+
149+
# Verify the status of restored database
150+
$RestoredDatabase.status
151+
```
152+
97153
## Next Steps
98154

99155
- [Restore a deleted dedicated SQL pool (formerly SQL DW)](sql-data-warehouse-restore-deleted-dw.md)

articles/synapse-analytics/sql-data-warehouse/sql-data-warehouse-restore-from-deleted-server.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,17 @@ In this article, you learn how to restore a dedicated SQL pool (formerly SQL DW)
2424
## Restore the SQL pool from the deleted server
2525

2626
1. Open PowerShell
27+
2728
2. Connect to your Azure account.
29+
2830
3. Set the context to the subscription that contains the server that was dropped.
31+
2932
4. Specify the approximate datetime the server was dropped.
33+
3034
5. Construct the resource ID for the database you wish to recover from the dropped server.
35+
3136
6. Restore the database from the dropped server
37+
3238
7. Verify the status of the recovered database as 'online'.
3339

3440

articles/synapse-analytics/sql-data-warehouse/toc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ items:
367367
href: sql-data-warehouse-restore-active-paused-dw.md
368368
- name: Restore a deleted data warehouse
369369
href: sql-data-warehouse-restore-deleted-dw.md
370-
- name: Restore a data warehouse from a deleted Server
370+
- name: Restore a data warehouse from a deleted server
371371
href: sql-data-warehouse-restore-from-deleted-server.md
372372
- name: Restore from a geo-backup
373373
href: sql-data-warehouse-restore-from-geo-backup.md

0 commit comments

Comments
 (0)