Skip to content

Commit 0d75a4f

Browse files
committed
staging changes
1 parent 83cd87b commit 0d75a4f

File tree

2 files changed

+220
-3
lines changed

2 files changed

+220
-3
lines changed

articles/sql-database/sql-database-long-term-retention.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ ms.date: 05/18/2019
1414
---
1515
# Store Azure SQL Database backups for up to 10 years
1616

17-
Many applications have regulatory, compliance, or other business purposes that require you to retain database backups beyond the 7-35 days provided by Azure SQL Database [automatic backups](sql-database-automated-backups.md). By using the long-term retention (LTR) feature, you can store specified SQL database full backups in Azure Blob storage with read-access geo-redundant storage for up to 10 years. You can then restore any backup as a new database. For more information about Azure Storage redundancy, see [Azure Storage redundancy](../storage/common/storage-redundancy.md).
17+
Many applications have regulatory, compliance, or other business purposes that require you to retain database backups beyond the 7-35 days provided by Azure SQL Database [automatic backups](sql-database-automated-backups.md). By using the long-term retention (LTR) feature, you can store specified SQL database full backups in Azure Blob storage with read-access geo-redundant storage for up to 10 years. You can then restore any backup as a new database. For more information about Azure Storage redundancy, see [Azure Storage redundancy](../storage/common/storage-redundancy.md).
18+
19+
Long time retention can be enabled for single and pooled databases, and is in limited public preview for Azure SQL Database managed instances.
1820

1921
> [!NOTE]
20-
> LTR can be enabled for single and pooled databases. It is not yet available for instance databases in Managed Instances. You can use SQL Agent jobs to schedule [copy-only database backups](https://docs.microsoft.com/sql/relational-databases/backup-restore/copy-only-backups-sql-server) as an alternative to LTR beyond 35 days.
21-
>
22+
> You can use SQL Agent jobs to schedule [copy-only database backups](https://docs.microsoft.com/sql/relational-databases/backup-restore/copy-only-backups-sql-server) as an alternative to LTR beyond 35 days.
23+
2224

2325
## How SQL Database long-term retention works
2426

@@ -69,6 +71,14 @@ If you are using active geo-replication or failover groups as your business cont
6971
> [!NOTE]
7072
> When the original primary database recovers from an outage that caused the failover, it will become a new secondary. Therefore, the backup creation will not resume and the existing LTR policy will not take effect until it becomes the primary again.
7173
74+
## Managed Instance support
75+
76+
Using long term retention with a Azure SQL Database managed instances has the following limitations:
77+
78+
- **Limited public preview** - Only whitelisted subscriptions have access to the LTR feature.
79+
- **PowerShell only** - There is currently no Azure portal support. LTR must be enabled using PowerShell.
80+
81+
7282
## Configure long-term backup retention
7383

7484
To learn how to configure long-term retention using the Azure portal or PowerShell, see [Manage Azure SQL Database long-term backup retention](sql-database-long-term-backup-retention-configure.md).
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
---
2+
title: Manage long-term backup retention (managed instance)
3+
description: "Learn how to store automated backups in the SQL Azure storage and then restore them"
4+
services: sql-database
5+
ms.service: sql-database
6+
ms.subservice: backup-restore
7+
ms.custom:
8+
ms.devlang:
9+
ms.topic: conceptual
10+
author: anosov1960
11+
ms.author: sashan
12+
ms.reviewer: mathoma, carlrab
13+
manager: craigg
14+
ms.date: 08/21/2019
15+
---
16+
17+
# Manage Azure SQL Database long-term backup retention
18+
19+
In Azure SQL Database, you can configure a single or a pooled database with a [long-term backup retention](sql-database-long-term-retention.md) policy (LTR) to automatically retain the database backups in separate Azure Blob storage containers for up to 10 years. You can then recover a database using these backups using the Azure portal or PowerShell.
20+
21+
> [!IMPORTANT]
22+
> [Azure SQL database managed instance](sql-database-managed-instance.md) does not currently support long-term backup retention.
23+
24+
## Using Azure portal
25+
26+
The following sections show you how to use the Azure portal to configure the long-term retention, view backups in long-term retention, and restore backup from long-term retention.
27+
28+
### Configure long-term retention policies
29+
30+
You can configure SQL Database to [retain automated backups](sql-database-long-term-retention.md) for a period longer than the retention period for your service tier.
31+
32+
1. In the Azure portal, select your SQL server and then click **Manage Backups**. On the **Configure policies** tab, select the checkbox for the database on which you want to set or modify long-term backup retention policies. If the checkbox next to the database is not selected, the changes for the policy will not apply to that database.
33+
34+
![manage backups link](./media/sql-database-long-term-retention/ltr-configure-ltr.png)
35+
36+
2. In the **Configure policies** pane, select if want to retain weekly, monthly or yearly backups and specify the retention period for each.
37+
38+
![configure policies](./media/sql-database-long-term-retention/ltr-configure-policies.png)
39+
40+
3. When complete, click **Apply**.
41+
42+
> [!IMPORTANT]
43+
> When you enable a long-term backup retention policy, it may take up to 7 days for the first backup to become visible and available to restore. For details of the LTR backup cadance, see [long-term backup retention](sql-database-long-term-retention.md).
44+
45+
### View backups and restore from a backup
46+
47+
View the backups that are retained for a specific database with a LTR policy, and restore from those backups.
48+
49+
1. In the Azure portal, select your SQL server and then click **Manage Backups**. On the **Available backups** tab, select the database for which you want to see available backups.
50+
51+
![select database](./media/sql-database-long-term-retention/ltr-available-backups-select-database.png)
52+
53+
1. In the **Available backups** pane, review the available backups.
54+
55+
![view backups](./media/sql-database-long-term-retention/ltr-available-backups.png)
56+
57+
1. Select the backup from which you want to restore, and then specify the new database name.
58+
59+
![restore](./media/sql-database-long-term-retention/ltr-restore.png)
60+
61+
1. Click **OK** to restore your database from the backup in Azure SQL storage to the new database.
62+
63+
1. On the toolbar, click the notification icon to view the status of the restore job.
64+
65+
![restore job progress](./media/sql-database-get-started-backup-recovery/restore-job-progress-long-term.png)
66+
67+
1. When the restore job is completed, open the **SQL databases** page to view the newly restored database.
68+
69+
> [!NOTE]
70+
> From here, you can connect to the restored database using SQL Server Management Studio to perform needed tasks, such as to [extract a bit of data from the restored database to copy into the existing database or to delete the existing database and rename the restored database to the existing database name](sql-database-recovery-using-backups.md#point-in-time-restore).
71+
72+
## Using PowerShell
73+
74+
[!INCLUDE [updated-for-az](../../includes/updated-for-az.md)]
75+
76+
> [!IMPORTANT]
77+
> The PowerShell Azure Resource Manager module is still supported by Azure SQL Database, but all future development is for the Az.Sql module. For these cmdlets, see [AzureRM.Sql](https://docs.microsoft.com/powershell/module/AzureRM.Sql/). The arguments for the commands in the Az module and in the AzureRm modules are substantially identical.
78+
79+
The following sections show you how to use PowerShell to configure the long-term backup retention, view backups in Azure SQL storage, and restore from a backup in Azure SQL storage.
80+
81+
### RBAC roles to manage long-term retention
82+
83+
For **Get-AzSqlDatabaseLongTermRetentionBackup** and **Restore-AzSqlDatabase**, you will need to have one of the following roles:
84+
85+
- Subscription Owner role or
86+
- SQL Server Contributor role or
87+
- Custom role with the following permissions:
88+
89+
Microsoft.Sql/locations/longTermRetentionBackups/read
90+
Microsoft.Sql/locations/longTermRetentionServers/longTermRetentionBackups/read
91+
Microsoft.Sql/locations/longTermRetentionServers/longTermRetentionDatabases/longTermRetentionBackups/read
92+
93+
For **Remove-AzSqlDatabaseLongTermRetentionBackup**, you will need to have one of the following roles:
94+
95+
- Subscription Owner role or
96+
- Custom role with the following permission:
97+
98+
Microsoft.Sql/locations/longTermRetentionServers/longTermRetentionDatabases/longTermRetentionBackups/delete
99+
100+
> [!NOTE]
101+
> The SQL Server Contributor role does not have permission to delete LTR backups.
102+
103+
RBAC permissions could be granted in either *subscription* or *resource group* scope. However, to access LTR backups that belong to a dropped server, the permission must be granted in the *subscription* scope of that server.
104+
105+
- Microsoft.Sql/locations/longTermRetentionServers/longTermRetentionDatabases/longTermRetentionBackups/delete
106+
107+
### Create an LTR policy
108+
109+
```powershell
110+
# get the SQL server
111+
$subId = "<subscriptionId>"
112+
$serverName = "<serverName>"
113+
$resourceGroup = "<resourceGroupName>"
114+
$dbName = "<databaseName>"
115+
116+
Connect-AzAccount
117+
Select-AzSubscription -SubscriptionId $subId
118+
119+
$server = Get-AzSqlServer -ServerName $serverName -ResourceGroupName $resourceGroup
120+
121+
# create LTR policy with WeeklyRetention = 12 weeks. MonthlyRetention and YearlyRetention = 0 by default.
122+
Set-AzSqlDatabaseBackupLongTermRetentionPolicy -ServerName $serverName -DatabaseName $dbName `
123+
-ResourceGroupName $resourceGroup -WeeklyRetention P12W
124+
125+
# create LTR policy with WeeklyRetention = 12 weeks, YearlyRetention = 5 years and WeekOfYear = 16 (week of April 15). MonthlyRetention = 0 by default.
126+
Set-AzSqlDatabaseBackupLongTermRetentionPolicy -ServerName $serverName -DatabaseName $dbName `
127+
-ResourceGroupName $resourceGroup -WeeklyRetention P12W -YearlyRetention P5Y -WeekOfYear 16
128+
```
129+
130+
### View LTR policies
131+
132+
This example shows how to list the LTR policies within a server
133+
134+
```powershell
135+
# get all LTR policies within a server
136+
$ltrPolicies = Get-AzSqlDatabase -ResourceGroupName Default-SQL-WestCentralUS -ServerName trgrie-ltr-server | `
137+
Get-AzSqlDatabaseLongTermRetentionPolicy -Current
138+
139+
# get the LTR policy of a specific database
140+
$ltrPolicies = Get-AzSqlDatabaseBackupLongTermRetentionPolicy -ServerName $serverName -DatabaseName $dbName `
141+
-ResourceGroupName $resourceGroup -Current
142+
```
143+
144+
### Clear an LTR policy
145+
146+
This example shows how to clear an LTR policy from a database
147+
148+
```powershell
149+
Set-AzSqlDatabaseBackupLongTermRetentionPolicy -ServerName $serverName -DatabaseName $dbName `
150+
-ResourceGroupName $resourceGroup -RemovePolicy
151+
```
152+
153+
### View LTR backups
154+
155+
This example shows how to list the LTR backups within a server.
156+
157+
```powershell
158+
# get the list of all LTR backups in a specific Azure region
159+
# backups are grouped by the logical database id, within each group they are ordered by the timestamp, the earliest backup first
160+
$ltrBackups = Get-AzSqlDatabaseLongTermRetentionBackup -Location $server.Location
161+
162+
# get the list of LTR backups from the Azure region under the named server
163+
$ltrBackups = Get-AzSqlDatabaseLongTermRetentionBackup -Location $server.Location -ServerName $serverName
164+
165+
# get the LTR backups for a specific database from the Azure region under the named server
166+
$ltrBackups = Get-AzSqlDatabaseLongTermRetentionBackup -Location $server.Location -ServerName $serverName -DatabaseName $dbName
167+
168+
# list LTR backups only from live databases (you have option to choose All/Live/Deleted)
169+
$ltrBackups = Get-AzSqlDatabaseLongTermRetentionBackup -Location $server.Location -DatabaseState Live
170+
171+
# only list the latest LTR backup for each database
172+
$ltrBackups = Get-AzSqlDatabaseLongTermRetentionBackup -Location $server.Location -ServerName $serverName -OnlyLatestPerDatabase
173+
```
174+
175+
### Delete LTR backups
176+
177+
This example shows how to delete an LTR backup from the list of backups.
178+
179+
```powershell
180+
# remove the earliest backup
181+
$ltrBackup = $ltrBackups[0]
182+
Remove-AzSqlDatabaseLongTermRetentionBackup -ResourceId $ltrBackup.ResourceId
183+
```
184+
185+
> [!IMPORTANT]
186+
> Deleting LTR backup is non-reversible. To delete an LTR backup after the server has been deleted you must have Subscription scope permission. You can set up notifications about each delete in Azure Monitor by filtering for operation 'Deletes a long term retention backup'. The activity log contains information on who and when made the request. See [Create activity log alerts](../azure-monitor/platform/alerts-activity-log.md) for detailed instructions.
187+
188+
### Restore from LTR backups
189+
190+
This example shows how to restore from an LTR backup. Note, this interface did not change but the resource id parameter now requires the LTR backup resource id.
191+
192+
```powershell
193+
# restore a specific LTR backup as an P1 database on the server $serverName of the resource group $resourceGroup
194+
Restore-AzSqlDatabase -FromLongTermRetentionBackup -ResourceId $ltrBackup.ResourceId -ServerName $serverName -ResourceGroupName $resourceGroup `
195+
-TargetDatabaseName $dbName -ServiceObjectiveName P1
196+
```
197+
198+
> [!IMPORTANT]
199+
> To restore from an LTR backup after the server has been deleted, you must have permissions scoped to the server's subscription and that subscription must be active. You must also omit the optional -ResourceGroupName parameter.
200+
201+
> [!NOTE]
202+
> From here, you can connect to the restored database using SQL Server Management Studio to perform needed tasks, such as to extract a bit of data from the restored database to copy into the existing database or to delete the existing database and rename the restored database to the existing database name. See [point in time restore](sql-database-recovery-using-backups.md#point-in-time-restore).
203+
204+
## Next steps
205+
206+
- To learn about service-generated automatic backups, see [automatic backups](sql-database-automated-backups.md)
207+
- To learn about long-term backup retention, see [long-term backup retention](sql-database-long-term-retention.md)

0 commit comments

Comments
 (0)