Skip to content

Commit f4364df

Browse files
Merge pull request #76663 from dcurwin/davidc-may14
SQL Backup Tutorial New Article
2 parents 41ee76c + f52e115 commit f4364df

File tree

2 files changed

+247
-0
lines changed

2 files changed

+247
-0
lines changed

articles/backup/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
href: tutorial-restore-disk.md
2222
- name: Restore individual files
2323
href: tutorial-restore-files.md
24+
- name: Back up SQL Server on Azure VM
25+
href: tutorial-sql-backup.md
2426
- name: Back up Windows Server
2527
href: tutorial-backup-windows-server-to-azure.md
2628
- name: Restore files to Windows Server
Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
---
2+
title: Back up SQL Server databases to Azure | Microsoft Docs
3+
description: This tutorial explains how to back up SQL Server to Azure.
4+
services: backup
5+
author: dcurwin
6+
manager:
7+
ms.service: backup
8+
ms.topic: tutorial
9+
ms.date: 05/22/2019
10+
ms.author: dacurwin
11+
12+
13+
---
14+
# Back up SQL Server databases in Azure VMs
15+
16+
17+
18+
This article shows you how to back up a SQL Server database running on an Azure VM to an Azure Backup Recovery Services vault. In this article, you learn how to:
19+
20+
> [!div class="checklist"]
21+
> * Create and configure a vault.
22+
> * Discover databases, and set up backups.
23+
> * Set up auto-protection for databases.
24+
> * Run an ad-hoc backup.
25+
26+
27+
## Prerequisites
28+
29+
Before you back up your SQL Server database, check the following conditions:
30+
31+
1. Identify or [create](backup-sql-server-database-azure-vms.md#create-a-recovery-services-vault) a Recovery Services vault in the same region or locale as the VM hosting the SQL Server instance.
32+
2. [Check the VM permissions](backup-azure-sql-database.md#fix-sql-sysadmin-permissions) needed to back up the SQL databases.
33+
3. Verify that the VM has [network connectivity](backup-sql-server-database-azure-vms.md#establish-network-connectivity).
34+
4. Check that the SQL Server databases are named in accordance with [naming guidelines](#verify-database-naming-guidelines-for-azure-backup) for Azure Backup.
35+
5. Verify that you don't have any other backup solutions enabled for the database. Disable all other SQL Server backups before you set up this scenario. You can enable Azure Backup for an Azure VM along with Azure Backup for a SQL Server database running on the VM without any conflict.
36+
37+
38+
### Establish network connectivity
39+
40+
For all operations, the SQL Server VM virtual machine needs connectivity to Azure public IP addresses. VM operations (database discovery, configure backups, schedule backups, restore recovery points, and so on) fail without connectivity to the public IP addresses. Establish connectivity with one of these options:
41+
42+
- **Allow the Azure datacenter IP ranges**: Allow the [IP ranges](https://www.microsoft.com/download/details.aspx?id=41653) in the download. To access network security group (NSG), use the **Set-AzureNetworkSecurityRule** cmdlet.
43+
- **Deploy an HTTP proxy server to route traffic**: When you back up a SQL Server database on an Azure VM, the backup extension on the VM uses the HTTPS APIs to send management commands to Azure Backup, and data to Azure Storage. The backup extension also uses Azure Active Directory (Azure AD) for authentication. Route the backup extension traffic for these three services through the HTTP proxy. The extensions are the only component that's configured for access to the public internet.
44+
45+
Each option has advantages and disadvantages
46+
47+
**Option** | **Advantages** | **Disadvantages**
48+
--- | --- | ---
49+
Allow IP ranges | No additional costs. | Complex to manage because the IP address ranges change over time. <br/><br/> Provides access to the whole of Azure, not just Azure Storage.
50+
Use an HTTP proxy | Granular control in the proxy over the storage URLs is allowed. <br/><br/> Single point of internet access to VMs. <br/><br/> Not subject to Azure IP address changes. | Additional costs to run a VM with the proxy software.
51+
52+
### Set VM permissions
53+
54+
Azure Backup does a number of things when you configure backup for a SQL Server database:
55+
56+
- Adds the **AzureBackupWindowsWorkload** extension.
57+
- To discover databases on the virtual machine, Azure Backup creates the account **NT SERVICE\AzureWLBackupPluginSvc**. This account is used for backup and restore, and requires SQL sysadmin permissions.
58+
- Azure Backup leverages the **NT AUTHORITY\SYSTEM** account for database discovery/inquiry, so this account need to be a public login on SQL.
59+
60+
If you didn't create the SQL Server VM from the Azure Marketplace, you might receive an error **UserErrorSQLNoSysadminMembership**. If this occurs [follow these instructions](backup-azure-sql-database.md#fix-sql-sysadmin-permissions).
61+
62+
### Verify database naming guidelines for Azure Backup
63+
64+
Avoid the below for database names:
65+
66+
* Trailing/Leading spaces
67+
* Trailing ‘!’
68+
* Close square bracket ‘]
69+
* Databases names starting with ‘F:\’
70+
71+
We do have aliasing for Azure table unsupported characters, but we recommend avoiding them. [Learn more](https://docs.microsoft.com/rest/api/storageservices/Understanding-the-Table-Service-Data-Model?redirectedfrom=MSDN).
72+
73+
74+
[!INCLUDE [How to create a Recovery Services vault](../../includes/backup-create-rs-vault.md)]
75+
76+
## Discover SQL Server databases
77+
78+
Discover databases running on the VM.
79+
80+
1. In the [Azure portal](https://portal.azure.com), open the Recovery Services vault you use to back up the database.
81+
82+
2. On the **Recovery Services vault** dashboard, select **Backup**.
83+
84+
![Select Backup to open the Backup Goal menu](./media/backup-azure-sql-database/open-backup-menu.png)
85+
86+
3. In **Backup Goal**, set **Where is your workload running** to **Azure** (the default).
87+
88+
4. In **What do you want to backup**, select **SQL Server in Azure VM**.
89+
90+
![Select SQL Server in Azure VM for the backup](./media/backup-azure-sql-database/choose-sql-database-backup-goal.png)
91+
92+
5. In **Backup Goal** > **Discover DBs in VMs**, select **Start Discovery** to search for unprotected VMs in the subscription. It can take a while, depending on the number of unprotected virtual machines in the subscription.
93+
94+
- Unprotected VMs should appear in the list after discovery, listed by name and resource group.
95+
- If a VM isn't listed as you expect, check whether it's already backed up in a vault.
96+
- Multiple VMs can have the same name but they'll belong to different resource groups.
97+
98+
![Backup is pending during search for DBs in VMs](./media/backup-azure-sql-database/discovering-sql-databases.png)
99+
100+
6. In the VM list, select the VM running the SQL Server database > **Discover DBs**.
101+
102+
7. Track database discovery in the **Notifications** area. It can take a while for the job to complete, depending on how many databases are on the VM. When the selected databases are discovered, a success message appears.
103+
104+
![Deployment success message](./media/backup-azure-sql-database/notifications-db-discovered.png)
105+
106+
8. Azure Backup discovers all SQL Server databases on the VM. During discovery the below occurs in the background:
107+
108+
- Azure Backup register the VM with the vault for workload backup. All databases on the registered VM can only be backed up to this vault.
109+
- Azure Backup installs the **AzureBackupWindowsWorkload** extension on the VM. No agent is installed on the SQL database.
110+
- Azure Backup creates the service account **NT Service\AzureWLBackupPluginSvc** on the VM.
111+
- All backup and restore operations use the service account.
112+
- **NT Service\AzureWLBackupPluginSvc** needs SQL sysadmin permissions. All SQL Server VMs created in the Azure Marketplace come with the **SqlIaaSExtension** installed. The **AzureBackupWindowsWorkload** extension uses the **SQLIaaSExtension** to automatically get the required permissions.
113+
- If you didn't create the VM from the marketplace, then the VM doesn't have the **SqlIaaSExtension** installed, and the discovery operation fails with the error message **UserErrorSQLNoSysAdminMembership**. Follow the [instructions](backup-azure-sql-database.md#fix-sql-sysadmin-permissions) to fix this issue.
114+
115+
![Select the VM and database](./media/backup-azure-sql-database/registration-errors.png)
116+
117+
## Configure backup
118+
119+
Configure backup as follows:
120+
121+
1. In **Backup Goal** select **Configure Backup**.
122+
123+
![Select Configure Backup](./media/backup-azure-sql-database/backup-goal-configure-backup.png)
124+
125+
2. Click **Configure Backup**, the **Select items to backup** blade appears. This lists all the registered availability groups and standalone SQL Servers. Expand the chevron to the left of the row to see all the unprotected databases in that instance or Always on AG.
126+
127+
![Displaying all SQL Server instances with standalone databases](./media/backup-azure-sql-database/list-of-sql-databases.png)
128+
129+
3. Select all the databases you want to protect > **OK**.
130+
131+
![Protecting the database](./media/backup-azure-sql-database/select-database-to-protect.png)
132+
133+
To optimize backup loads, Azure Backup sets a maximum number of databases in one backup job to 50.
134+
135+
136+
* Alternatively, you can enable auto-protection on the entire instance or Always On Availability group by selecting the **ON** option in the corresponding dropdown in the **AUTOPROTECT** column. The auto-protection feature not only enables protection on all the existing databases in one go but also automatically protects any new databases that will be added to that instance or the availability group in future.
137+
138+
4. Click **OK** to open the **Backup policy** blade.
139+
140+
![Enable auto-protection on the Always On availability group](./media/backup-azure-sql-database/enable-auto-protection.png)
141+
142+
5. In **Choose backup policy**, select a policy, then click **OK**.
143+
144+
- Select the default policy: HourlyLogBackup.
145+
- Choose an existing backup policy previously created for SQL.
146+
- Define a new policy based on your RPO and retention range.
147+
148+
![Select Backup policy](./media/backup-azure-sql-database/select-backup-policy.png)
149+
150+
6. On **Backup** menu, select **Enable backup**.
151+
152+
![Enable the chosen backup policy](./media/backup-azure-sql-database/enable-backup-button.png)
153+
154+
7. Track the configuration progress in the **Notifications** area of the portal.
155+
156+
![Notification area](./media/backup-azure-sql-database/notifications-area.png)
157+
158+
### Create a backup policy
159+
160+
A backup policy defines when backups are taken and how long they're retained.
161+
162+
- A policy is created at the vault level.
163+
- Multiple vaults can use the same backup policy, but you must apply the backup policy to each vault.
164+
- When you create a backup policy, a daily full backup is the default.
165+
- You can add a differential backup, but only if you configure full backups to occur weekly.
166+
- [Learn about](backup-architecture.md#sql-server-backup-types) different types of backup policies.
167+
168+
To create a backup policy:
169+
170+
1. In the vault, click **Backup policies** > **Add**.
171+
2. In **Add** menu, click **SQL Server in Azure VM**. To defines the policy type.
172+
173+
![Choose a policy type for the new backup policy](./media/backup-azure-sql-database/policy-type-details.png)
174+
175+
3. In **Policy name**, enter a name for the new policy.
176+
4. In **Full Backup policy**, select a **Backup Frequency**, choose **Daily** or **Weekly**.
177+
178+
- For **Daily**, select the hour and time zone when the backup job begins.
179+
- You must run a full backup as you can't turn off the **Full Backup** option.
180+
- Click **Full Backup** to view the policy.
181+
- You can't create differential backups for daily full backups.
182+
- For **Weekly**, select the day of the week, hour, and time zone when the backup job begins.
183+
184+
![New backup policy fields](./media/backup-azure-sql-database/full-backup-policy.png)
185+
186+
5. For **Retention Range**, by default all options are selected. Clear any undesired retention range limits you don't want to use, and set the intervals to use.
187+
188+
- Minimum retention period for any type of backup (full/differential/log) is 7 days.
189+
- Recovery points are tagged for retention based on their retention range. For example, if you select a daily full backup, only one full backup is triggered each day.
190+
- The backup for a specific day is tagged and retained based on the weekly retention range and your weekly retention setting.
191+
- The monthly and yearly retention ranges behave in a similar way.
192+
193+
![Retention range interval settings](./media/backup-azure-sql-database/retention-range-interval.png)
194+
195+
6. In the **Full Backup policy** menu, select **OK** to accept the settings.
196+
7. To add a differential backup policy, select **Differential Backup**.
197+
198+
![Retention range interval settings](./media/backup-azure-sql-database/retention-range-interval.png)
199+
![Open the differential backup policy menu](./media/backup-azure-sql-database/backup-policy-menu-choices.png)
200+
201+
8. In **Differential Backup policy**, select **Enable** to open the frequency and retention controls.
202+
203+
- At most, you can trigger one differential backup per day.
204+
- Differential backups can be retained for a maximum of 180 days. If you need longer retention, you must use full backups.
205+
206+
9. Select **OK** to save the policy and return to the main **Backup policy** menu.
207+
208+
10. To add a transactional log backup policy, select **Log Backup**.
209+
11. In **Log Backup**, select **Enable**, and then set the frequency and retention controls. Log backups can occur as often as every 15 minutes, and can be retained for up to 35 days.
210+
12. Select **OK** to save the policy and return to the main **Backup policy** menu.
211+
212+
![Edit the log backup policy](./media/backup-azure-sql-database/log-backup-policy-editor.png)
213+
214+
13. On the **Backup policy** menu, choose whether to enable **SQL Backup Compression**.
215+
- Compression is disabled by default.
216+
- On the back end, Azure Backup uses SQL native backup compression.
217+
218+
14. After you complete the edits to the backup policy, select **OK**.
219+
220+
## Run an ad-hoc backup
221+
222+
1. In your Recovery Services vault, choose Backup items.
223+
2. Click on "SQL in Azure VM".
224+
3. Right click on a database, and choose "Backup now".
225+
4. Choose the Backup Type (Full/Differential/Log/Copy Only Full) and Compression (Enable/Disable)
226+
5. Select OK to begin the backup.
227+
6. Monitor the backup job by going to your Recovery Services vault and choosing "Backup Jobs".
228+
229+
230+
## Next steps
231+
232+
In this tutorial you used the Azure portal to:
233+
234+
> [!div class="checklist"]
235+
> * Create and configure a vault.
236+
> * Discover databases, and set up backups.
237+
> * Set up auto-protection for databases.
238+
> * Run an ad-hoc backup.
239+
240+
Continue to the next tutorial to restore an Azure virtual machine from disk.
241+
242+
> [!div class="nextstepaction"]
243+
> [Restore SQL Server databases on Azure VMs](./restore-sql-database-azure-vm.md)
244+
245+

0 commit comments

Comments
 (0)