You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Run the following commands in Cloud Shell. Enter a complex password and, at the prompt, enter your local public IP address, which you obtained in the preceding step. Replace "[sandbox resource group name]" with "<rgn>[sandbox resource group name]</rgn>".
15
+
1. Run the following commands in Cloud Shell. Enter a complex password and, at the prompt, enter your local public IP address, which you obtained in the preceding step.
16
16
17
17
```powershell
18
18
$adminSqlLogin = "cloudadmin"
19
19
$password = Read-Host "Your username is 'cloudadmin'. Enter a password for your Azure SQL Database server that meets the password requirements"
20
20
# Prompt for local ip address
21
21
$ipAddress = Read-Host "Disconnect your VPN, open PowerShell on your machine and run '(Invoke-WebRequest -Uri "https://ipinfo.io/ip").Content'. Enter the value (include periods) next to 'Address' "
22
22
# Get resource group and location and random string
23
-
$resourceGroup = Get-AzResourceGroup | Where ResourceGroupName -like "[sandbox resource group name]"
24
-
$resourceGroupName = "[sandbox resource group name]"
23
+
$resourceGroup = Get-AzResourceGroup | Where ResourceGroupName -like "<rgn>[sandbox resource group name]</rgn>"
Copy file name to clipboardExpand all lines: learn-pr/azure/backup-restore-azure-sql/includes/6-restore-database.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,4 +42,4 @@ In the portal, go to the database server's **Overview** page. Then, in the **Ope
42
42
43
43
Azure SQL Database automatically replicates backed-up databases to datacenters in other regions. If the database in the original region is unavailable—for example, because of a datacenter outage—you can restore from one of these replicated backup copies. You can restore up to the point in time when Azure SQL Database made the backup. The latest backup might not have fully replicated to your region, so you might lose some recent changes.
44
44
45
-
To perform a geo-restore in the Azure portal, add a new database to an Azure SQL Database server, then select **Backup** in the **Select source**drop-down list and choose the backup from which to restore.
45
+
To perform a geo-restore in the Azure portal, add a new database to an Azure SQL Database server, then select **Backup** in the **Select source**dropdown list and choose the backup from which to restore.
Trial restores are a key component of any disaster recovery strategy.
2
2
3
-
You want to familiarize yourself with the steps to restore a backed-up database to a specific point in time, in case it becomes necessary. You also want to investigate how long a restore operation takes. That way, you can plan for this time in your guidance for your organization.
3
+
You want to familiarize yourself with the steps to restore a backed-up database to a specific point in time, in case it becomes necessary. You also want to investigate how long a restore operation takes, a key part of the calculation of Recovery Time Objection (RTO). You can plan for this time in your guidance for your organization.
4
+
5
+
You can treat the restored database as a replacement for the original database or use it as a data source to update the original database. Though you can overwrite and replace a database in a SQL Server instance or Azure SQL Managed Instance, you cannot overwrite an Azure SQL Database with a restore.
4
6
5
7
Let's perform a restore from automated Azure SQL Database backups.
6
8
7
9
## Confirm that backups are active
8
10
9
-
It can take up to 15 minutes for the first successful backup to finish. We need to make sure that backups are running before we continue the exercise.
11
+
> [!TIP]
12
+
> It can take up to 15 minutes after database creation for the first successful backup to finish.
13
+
14
+
Let's look at the backups Azure SQL takes for us, automatically.
10
15
11
16
1. In Azure Cloud Shell, run the following PowerShell command to set a variable to the value of your SQL Server instance:
12
17
13
18
```powershell
14
19
$sqlserver=Get-AzSqlServer
15
20
```
16
21
17
-
1. Validate that continuous backups are running by using this command:
22
+
1. View the available restore points, based on backups, with the `Get-AzSqlDatabaseRestorePoint` PowerShell cmdlet:
18
23
19
24
```powershell
20
25
Get-AzSqlDatabaseRestorePoint `
@@ -23,7 +28,7 @@ It can take up to 15 minutes for the first successful backup to finish. We need
23
28
-ServerName $sqlserver.ServerName
24
29
```
25
30
26
-
You should get an output similar to the following code if your backups are running. If the command returns no value, a backup hasn't started yet. Rerun this command in a couple of minutes.
31
+
You should get an output similar to the following code. If the command returns no value, a backup hasn't started yet. Rerun this command in a couple of minutes.
27
32
28
33
```output
29
34
ResourceGroupName : <rgn>[sandbox resource group name]</rgn>
@@ -42,11 +47,11 @@ It can take up to 15 minutes for the first successful backup to finish. We need
42
47
43
48
Let's start by simulating a mistaken database modification.
44
49
45
-
1. On the [Azure portal](https://portal.azure.com/learn.docs.microsoft.com?azure-portal=true) menu or from the **Home** page, select **All resources**, select **erpserver-NNNN**, select **SQL databases**, and then select the **sql-erp-db** database.
50
+
1. On the [Azure portal](https://portal.azure.com/learn.docs.microsoft.com?azure-portal=true) menu or from the **Home** page, select **All resources**, select **erpserver-NNNN**, select **SQL databases**, and then select the **sql-erp-db** database.
46
51
47
-
1. Select **Query editor (preview)**, then sign in with the **dbadmin** user and the password that you specified for this account.
52
+
1. We'll use the T-SQL query editor built into the Azure portal. Select **Query editor (preview)**, then sign in with the **dbadmin** user and the password that you specified for this account. The following T-SQL commands would also work in SQL Server Management Studio, or the mssql extension for Visual Studio Code, or other T-SQL query tools.
48
53
49
-
1. Let's drop the **Person** table that we created earlier. In a new query window, run this command.
54
+
1. Let's drop the `Person` table that we created earlier. In a new query window, run this command. Note the time on your clock.
50
55
51
56
```sql
52
57
DROP TABLE Person
@@ -57,43 +62,43 @@ Let's start by simulating a mistaken database modification.
57
62
```sql
58
63
SELECT schema_name(t.schema_id) as schema_name,
59
64
t.name as table_name
60
-
FROM sys.tables t
65
+
FROM sys.tables AS t
61
66
ORDER BY schema_name, table_name;
62
67
```
63
68
64
-
You should see **No results** returned, because we deleted the **Person** table.
69
+
You should see **No results** returned, because we deleted the `Person` table.
65
70
66
71
:::image type="content" source="../media/7-no-results.png" alt-text="Screenshot that shows no results returned after querying for the tables in the database.":::
67
72
68
-
## Run a point-in-time restore
73
+
## Create a point-in-time restore
69
74
70
-
The **Person** table was mistakenly deleted. Now, let's restore the database to its previous state.
75
+
The `Person` table was mistakenly deleted. Now, let's restore the database to its previous state.
71
76
72
77
1. On the [Azure portal](https://portal.azure.com/learn.docs.microsoft.com?azure-portal=true) menu or from the **Home** page, select **All resources**, and then select the **sql-erp-db** database.
73
78
74
79
1. At the top of the **Overview** page, select **Restore**.
75
80
76
-
1. Complete the **Basics** tab on the **Restore database** page with these values, and then select **Review + create**.
81
+
1. Complete the **Basics** tab on the **Restore database** page with these values, and then select **Review + create**. Here, you provide a new database name for the restored version of the database.
77
82
78
83
| Setting | Value |
79
84
| --- | --- |
80
85
| Select source | **Point-in-time** |
81
-
| Database name | sql-erp-db-xxxxx |
82
-
| Restore point | Select a time 10 minutes ago, before you dropped the **Person** table |
86
+
| Database name | `sql-erp-db-restored` |
87
+
| Restore point | Select a time before you dropped the `Person` table, perhaps 10 minutes ago. |
:::image type="content" source="../media/7-restore-sql-database-pitr.png" alt-text="Screenshot that shows the restore database page with the Review + create button selected." lightbox="../media/7-restore-sql-database-pitr.png":::
93
+
:::image type="content" source="../media/7-restore-sql-database-point-in-time-recovery.png" alt-text="Screenshot that shows the restore database page with the Review + create button selected." lightbox="../media/7-restore-sql-database-point-in-time-recovery.png":::
89
94
90
95
1. Select **Create**. The database restore takes several minutes to complete.
91
96
92
97
## View the restored database
93
98
94
-
The restored database should contain the **Person** table. You can check that in the portal.
99
+
The restored database contains the `Person` table.
95
100
96
-
1. In the [Azure portal](https://portal.azure.com/learn.docs.microsoft.com?azure-portal=true) menu or from the **Home** page, select **All resources**, and then select the **sql-erp-db-restored** database.
101
+
1. In the [Azure portal](https://portal.azure.com/learn.docs.microsoft.com?azure-portal=true) menu or from the **Home** page, select **All resources**, and then select the `sql-erp-db-restored` database.
97
102
98
103
1. Select **Query editor (preview)**, and then sign in with the **dbadmin** user and the password that you specified for this account.
99
104
@@ -102,22 +107,22 @@ The restored database should contain the **Person** table. You can check that in
102
107
```sql
103
108
SELECT schema_name(t.schema_id) as schema_name,
104
109
t.name as table_name
105
-
FROM sys.tables t
110
+
FROM sys.tables AS t
106
111
ORDER BY schema_name, table_name;
107
112
```
108
113
109
-
The **Person** table should now be present.
114
+
The database has been restore to the state it was, including the `Person` table.
110
115
111
-
:::image type="content" source="../media/7-query-after-restore-1.png" alt-text="Screenshot showing results after querying for the tables in the database.":::
116
+
:::image type="content" source="../media/7-query-after-restore-person-table.png" alt-text="Screenshot showing results after querying for the tables in the database.":::
112
117
113
118
1. Confirm that the data is in the table by running this command:
114
119
115
120
```sql
116
-
SELECT * FROM Person
121
+
SELECT * FROM Person;
117
122
```
118
123
119
124
You should see the data that you entered previously.
120
125
121
-
:::image type="content" source="../media/7-query-after-restore-2.png" alt-text="Screenshot showing confirmed results after querying for the tables in the database.":::
126
+
:::image type="content" source="../media/7-query-after-restore-select.png" alt-text="Screenshot showing confirmed results after querying for the tables in the database.":::
122
127
123
128
You've now learned how you can restore a database if something unintended happens to the data. You've familiarized yourself with the restore process. You can now assure your organization that you've properly defined the backup and restore procedures.
0 commit comments