11---
22external help file : Microsoft.Azure.PowerShell.Cmdlets.Sql.dll-Help.xml
33Module Name : Az.Sql
4- online version : https://learn.microsoft.com/powershell/module/az.sql/set-azsqldatabasebackuplongtermretentionpolicy
4+ online version :
55schema : 2.0.0
66---
77
@@ -14,31 +14,35 @@ Sets a server long term retention policy.
1414
1515### WeeklyRetentionRequired (Default)
1616```
17- Set-AzSqlDatabaseBackupLongTermRetentionPolicy -WeeklyRetention <String> [-ServerName] <String>
18- [-DatabaseName] <String> [-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
19- [-Confirm] [<CommonParameters>]
17+ Set-AzSqlDatabaseBackupLongTermRetentionPolicy -WeeklyRetention <String> [-TimeBasedImmutability <String>]
18+ [-TimeBasedImmutabilityMode <String>] [-ServerName] <String> [-DatabaseName] <String>
19+ [-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-ProgressAction <ActionPreference>]
20+ [-WhatIf] [-Confirm] [<CommonParameters>]
2021```
2122
2223### RemovePolicy
2324```
24- Set-AzSqlDatabaseBackupLongTermRetentionPolicy [-RemovePolicy] [-ServerName] <String> [-DatabaseName] <String>
25- [-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
26- [<CommonParameters>]
25+ Set-AzSqlDatabaseBackupLongTermRetentionPolicy [-RemovePolicy] [-TimeBasedImmutability <String>]
26+ [-TimeBasedImmutabilityMode <String>] [-ServerName] <String> [-DatabaseName] <String>
27+ [-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-ProgressAction <ActionPreference>]
28+ [-WhatIf] [-Confirm] [<CommonParameters>]
2729```
2830
2931### MonthlyRetentionRequired
3032```
3133Set-AzSqlDatabaseBackupLongTermRetentionPolicy [-WeeklyRetention <String>] -MonthlyRetention <String>
32- [-ServerName] <String> [-DatabaseName] <String> [-ResourceGroupName] <String>
33- [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
34+ [-TimeBasedImmutability <String>] [-TimeBasedImmutabilityMode <String>] [-ServerName] <String>
35+ [-DatabaseName] <String> [-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>]
36+ [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
3437```
3538
3639### YearlyRetentionRequired
3740```
3841Set-AzSqlDatabaseBackupLongTermRetentionPolicy [-WeeklyRetention <String>] [-MonthlyRetention <String>]
39- -YearlyRetention <String> -WeekOfYear <Int32> [-ServerName] <String> [-DatabaseName] <String>
40- [-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
41- [<CommonParameters>]
42+ -YearlyRetention <String> -WeekOfYear <Int32> [-TimeBasedImmutability <String>]
43+ [-TimeBasedImmutabilityMode <String>] [-ServerName] <String> [-DatabaseName] <String>
44+ [-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-ProgressAction <ActionPreference>]
45+ [-WhatIf] [-Confirm] [<CommonParameters>]
4246```
4347
4448## DESCRIPTION
@@ -61,6 +65,8 @@ MonthlyRetention : PT0S
6165YearlyRetention : PT0S
6266WeekOfYear : 0
6367Location :
68+ TimeBasedImmutability : Disabled
69+ TimeBasedImmutabilityMode : Unlocked
6470```
6571
6672This sets the long term retention policy of database01 to save every weekly full backup for 2 weeks
@@ -79,6 +85,8 @@ MonthlyRetention : P5Y
7985YearlyRetention : PT0S
8086WeekOfYear : 0
8187Location :
88+ TimeBasedImmutability : Disabled
89+ TimeBasedImmutabilityMode : Unlocked
8290```
8391
8492This sets the long term retention policy of database01 to save the first full backup of each month for 5 years
@@ -97,11 +105,57 @@ MonthlyRetention : PT0S
97105YearlyRetention : P10Y
98106WeekOfYear : 26
99107Location :
108+ TimeBasedImmutability : Disabled
109+ TimeBasedImmutabilityMode : Unlocked
100110```
101111
102112This sets the long term retention policy of database01 to save the full backup taken on the 26th week of the year for 10 years
103113
104- ### Example 4: Set each retention for the current version of long term retention policy
114+ ### Example 4: Set the yearly retention for the current version of long term retention policy with an unlocked time-based immutability enabled
115+ ``` powershell
116+ Set-AzSqlDatabaseBackupLongTermRetentionPolicy -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01 -YearlyRetention P10Y -WeekOfYear 26 -TimeBasedImmutability Enabled
117+ ```
118+
119+ ``` output
120+ ResourceGroupName : resourcegroup01
121+ ServerName : server01
122+ DatabaseName : database01
123+ WeeklyRetention : PT0S
124+ MonthlyRetention : PT0S
125+ YearlyRetention : P10Y
126+ WeekOfYear : 26
127+ Location :
128+ TimeBasedImmutability : Enabled
129+ TimeBasedImmutabilityMode : Unlocked
130+ ```
131+
132+ This sets the long term retention policy of database01 to save the full backup taken on the 26th week of the year for 10 years.
133+ Additionally, the backups will be created with an unlocked time-based immutability policy.
134+ These backups can later have their immutability locked or removed.
135+
136+ ### Example 5: Set the yearly retention for the current version of long term retention policy with a locked time-based immutability enabled
137+ ``` powershell
138+ Set-AzSqlDatabaseBackupLongTermRetentionPolicy -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01 -YearlyRetention P10Y -WeekOfYear 26 -TimeBasedImmutability Enabled -TimeBasedImmutabilityMode Locked
139+ ```
140+
141+ ``` output
142+ ResourceGroupName : resourcegroup01
143+ ServerName : server01
144+ DatabaseName : database01
145+ WeeklyRetention : PT0S
146+ MonthlyRetention : PT0S
147+ YearlyRetention : P10Y
148+ WeekOfYear : 26
149+ Location :
150+ TimeBasedImmutability : Enabled
151+ TimeBasedImmutabilityMode : Locked
152+ ```
153+
154+ This sets the long term retention policy of database01 to save the full backup taken on the 26th week of the year for 10 years.
155+ Additionally, the backups will be created with a locked time-based immutability policy.
156+ These backups can not be deleted manually and will only be dropped on expiration.
157+
158+ ### Example 6: Set each retention for the current version of long term retention policy
105159``` powershell
106160Set-AzSqlDatabaseBackupLongTermRetentionPolicy -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01 -WeeklyRetention 14 -MonthlyRetention P24W -YearlyRetention P10Y -WeekOfYear 26
107161```
@@ -115,11 +169,13 @@ MonthlyRetention : P24W
115169YearlyRetention : P10Y
116170WeekOfYear : 26
117171Location :
172+ TimeBasedImmutability : Disabled
173+ TimeBasedImmutabilityMode : Unlocked
118174```
119175
120176This sets the long term retention policy of database01 to save each full backup for 14 days, the first full backup of each month for 24 weeks, and the full backup taken on the 26th week of the year for 10 years
121177
122- ### Example 5 : Remove the long term retention policy
178+ ### Example 7 : Remove the long term retention policy
123179``` powershell
124180Set-AzSqlDatabaseBackupLongTermRetentionPolicy -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01 -RemovePolicy
125181```
@@ -133,12 +189,14 @@ MonthlyRetention : PT0S
133189YearlyRetention : PT0S
134190WeekOfYear : 0
135191Location :
192+ TimeBasedImmutability : Disabled
193+ TimeBasedImmutabilityMode : Unlocked
136194```
137195
138196Removes the policy for database01 so it no longer saves any long term retention backups.
139- This will not affect backups that have already been taken
197+ This will not affect backups that have already been taken.
140198
141- ### Example 6 : Remove the long term retention policy
199+ ### Example 8 : Remove the long term retention policy
142200``` powershell
143201Set-AzSqlDatabaseBackupLongTermRetentionPolicy -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01 -WeeklyRetention P0D
144202```
@@ -152,6 +210,8 @@ MonthlyRetention : PT0S
152210YearlyRetention : PT0S
153211WeekOfYear : 0
154212Location :
213+ TimeBasedImmutability : Disabled
214+ TimeBasedImmutabilityMode : Unlocked
155215```
156216
157217This is another way of removing the policy for database01 so it no longer saves any long term retention backups.
@@ -218,8 +278,23 @@ Accept pipeline input: True (ByPropertyName)
218278Accept wildcard characters : False
219279` ` `
220280
281+ ### -ProgressAction
282+ {{ Fill ProgressAction Description }}
283+
284+ ` ` ` yaml
285+ Type : System.Management.Automation.ActionPreference
286+ Parameter Sets : (All)
287+ Aliases : proga
288+
289+ Required : False
290+ Position : Named
291+ Default value : None
292+ Accept pipeline input : False
293+ Accept wildcard characters : False
294+ ` ` `
295+
221296### -RemovePolicy
222- If provided, the policy for the database will be removed .
297+ If provided, the policy for the database will be cleared .
223298
224299` ` ` yaml
225300Type : System.Management.Automation.SwitchParameter
@@ -263,6 +338,41 @@ Accept pipeline input: True (ByPropertyName)
263338Accept wildcard characters : False
264339` ` `
265340
341+ ### -TimeBasedImmutability
342+ When set, future backups will have TimeBasedImmutability enabled.
343+
344+ ` ` ` yaml
345+ Type : System.String
346+ Parameter Sets : (All)
347+ Aliases :
348+ Accepted values : Enabled, Disabled
349+
350+ Required : False
351+ Position : Named
352+ Default value : None
353+ Accept pipeline input : True (ByPropertyName)
354+ Accept wildcard characters : False
355+ ` ` `
356+
357+ ### -TimeBasedImmutabilityMode
358+ The setting for time-based immutability mode for future backups.
359+ Only effective if TimeBasedImmutability is enabled.
360+ Value can be either Locked or Unlocked.
361+ Caution: Immutability of LTR backup cannot be removed if TimeBasedImmutabilityMode is Locked.
362+
363+ ` ` ` yaml
364+ Type : System.String
365+ Parameter Sets : (All)
366+ Aliases :
367+ Accepted values : Unlocked, Locked
368+
369+ Required : False
370+ Position : Named
371+ Default value : None
372+ Accept pipeline input : True (ByPropertyName)
373+ Accept wildcard characters : False
374+ ` ` `
375+
266376### -WeeklyRetention
267377The Weekly Retention.
268378If just a number is passed instead of an ISO 8601 string, days will be assumed as the units.
@@ -334,7 +444,7 @@ Aliases: cf
334444
335445Required : False
336446Position : Named
337- Default value : False
447+ Default value : None
338448Accept pipeline input : False
339449Accept wildcard characters : False
340450` ` `
@@ -350,7 +460,7 @@ Aliases: wi
350460
351461Required : False
352462Position : Named
353- Default value : False
463+ Default value : None
354464Accept pipeline input : False
355465Accept wildcard characters : False
356466` ` `
@@ -373,13 +483,8 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
373483## RELATED LINKS
374484
375485[Get-AzSqlDatabaseLongTermRetentionBackup](./Get-AzSqlDatabaseLongTermRetentionBackup.md)
376-
377486[Update-AzSqlDatabaseLongTermRetentionBackup](./Update-AzSqlDatabaseLongTermRetentionBackup.md)
378-
379487[Copy-AzSqlDatabaseLongTermRetentionBackup](./Copy-AzSqlDatabaseLongTermRetentionBackup.md)
380-
381488[Remove-AzSqlDatabaseLongTermRetentionBackup](./Remove-AzSqlDatabaseLongTermRetentionBackup.md)
382-
383489[Get-AzSqlDatabaseBackupLongTermRetentionPolicy](./Get-AzSqlDatabaseBackupLongTermRetentionPolicy.md)
384-
385490[SQL Database Documentation](https://learn.microsoft.com/azure/sql-database/)
0 commit comments