< Back
Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy
Post
NAME Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy
SYNOPSIS
Sets a server long term retention policy.
SYNTAX
Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy [-ResourceGroupName] <String> [-ServerName] <String> [-DatabaseName] <String>
[-MonthlyRetention] <String> [[-WeeklyRetention] <String>] [-DefaultProfile <IAzureContextContainer>] [-Confirm] [-WhatIf] [<CommonParameters>]
Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy [-ResourceGroupName] <String> [-ServerName] <String> [-DatabaseName] <String>
[[-MonthlyRetention] <String>] [[-WeeklyRetention] <String>] [-YearlyRetention] <String> [-WeekOfYear] <Int32> [-DefaultProfile
<IAzureContextContainer>] [-Confirm] [-WhatIf] [<CommonParameters>]
Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy [-ResourceGroupName] <String> [-ServerName] <String> [-DatabaseName] <String> [-DefaultProfile
<IAzureContextContainer>] -RemovePolicy [-Confirm] [-WhatIf] [<CommonParameters>]
Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy [-ResourceGroupName] <String> [-ServerName] <String> [-DatabaseName] <String> [-DefaultProfile
<IAzureContextContainer>] -ResourceId <String> -State <String> [-Confirm] [-WhatIf] [<CommonParameters>]
Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy [-ResourceGroupName] <String> [-ServerName] <String> [-DatabaseName] <String>
[-WeeklyRetention] <String> [-DefaultProfile <IAzureContextContainer>] [-Confirm] [-WhatIf] [<CommonParameters>]
DESCRIPTION
The Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy cmdlet sets the long term retention policy registered to this database. The policy is an
Azure Backup resource used to define backup storage policy.
PARAMETERS
-DatabaseName <String>
The name of the Azure SQL Database to use.
Required? true
Position? 2
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-DefaultProfile <IAzureContextContainer>
The credentials, account, tenant, and subscription used for communication with Azure.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-MonthlyRetention <String>
The Monthly Retention. If just a number is passed instead of an ISO 8601 string, days will be assumed as the units. There is a minumum of 7
days and a maximum of 10 years.
Required? true
Position? 3
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-RemovePolicy [<SwitchParameter>]
If provided, the policy for the database will be removed.
Required? true
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-ResourceGroupName <String>
The name of the resource group.
Required? true
Position? 0
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-ResourceId <String>
The Resource ID of the backup long term retention policy.
Required? true
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-ServerName <String>
The name of the Azure SQL Server the database is in.
Required? true
Position? 1
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-State <String>
The state of the long term retention backup policy, 'Enabled' or 'Disabled'
Required? true
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-WeeklyRetention <String>
The Weekly Retention. If just a number is passed instead of an ISO 8601 string, days will be assumed as the units. There is a minumum of 7
days and a maximum of 10 years.
Required? true
Position? 3
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-WeekOfYear <Int32>
The Week of Year, 1 to 52, to save for the Yearly Retention.
Required? true
Position? 4
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-YearlyRetention <String>
The Yearly Retention. If just a number is passed instead of an ISO 8601 string, days will be assumed as the units. There is a minumum of 7
days and a maximum of 10 years.
Required? true
Position? 3
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Confirm [<SwitchParameter>]
Prompts you for confirmation before running the cmdlet.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
None
This cmdlet does not accept any input.
OUTPUTS
Microsoft.Azure.Commands.Sql.Backup.Model.AzureSqlDatabaseBackupLongTermRetentionPolicyModel
NOTES
Example 1: Set the weekly retention for the current version of long term retention policy
PS C:\\> Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01
-WeeklyRetention P2W
ResourceGroupName : resourcegroup01
ServerName : server01
DatabaseName : database01
WeeklyRetention : P2W
MonthlyRetention : PT0S
YearlyRetention : PT0S
WeekOfYear : 0
State :
RecoveryServicesBackupPolicyResourceId :
Location :
This sets the long term retention policy of database01 to save every weekly full backup for 2 weeks
Example 2: Set the monthly retention for the current version of long term retention policy
PS C:\\> Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01
-MonthlyRetention P5Y
ResourceGroupName : resourcegroup01
ServerName : server01
DatabaseName : database01
WeeklyRetention : PT0S
MonthlyRetention : P5Y
YearlyRetention : PT0S
WeekOfYear : 0
State :
RecoveryServicesBackupPolicyResourceId :
Location :
This sets the long term retention policy of database01 to save the first full backup of each month for 5 years
Example 3: Set the yearly retention for the current version of long term retention policy
PS C:\\> Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01
-YearlyRetention P10Y -WeekOfYear 26
ResourceGroupName : resourcegroup01
ServerName : server01
DatabaseName : database01
WeeklyRetention : PT0S
MonthlyRetention : PT0S
YearlyRetention : P10Y
WeekOfYear : 26
State :
RecoveryServicesBackupPolicyResourceId :
Location :
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
Example 4: Set each retention for the current version of long term retention policy
PS C:\\> Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01
-WeeklyRetention 14 -MonthlyRetention P24W -YearlyRetention P10Y -WeekOfYear 26
ResourceGroupName : resourcegroup01
ServerName : server01
DatabaseName : database01
WeeklyRetention : P14D
MonthlyRetention : P24W
YearlyRetention : P10Y
WeekOfYear : 26
State :
RecoveryServicesBackupPolicyResourceId :
Location :
This 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
Example 4: Remove the long term retention policy
PS C:\\> Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01
-RemovePolicy
ResourceGroupName : resourcegroup01
ServerName : server01
DatabaseName : database01
WeeklyRetention : PT0S
MonthlyRetention : PT0S
YearlyRetention : PT0S
WeekOfYear : 0
State :
RecoveryServicesBackupPolicyResourceId :
Location :
Removes the policy for database01 so it no longer saves any long term retention backups. This will not affect backups that have already been taken
Example 4: Remove the long term retention policy
PS C:\\> Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01
-WeeklyRetention P0D
ResourceGroupName : resourcegroup01
ServerName : server01
DatabaseName : database01
WeeklyRetention : PT0S
MonthlyRetention : PT0S
YearlyRetention : PT0S
WeekOfYear : 0
State :
RecoveryServicesBackupPolicyResourceId :
Location :
This is another way of removing the policy for database01 so it no longer saves any long term retention backups. This will not affect backups that
have already been taken
RELATED LINKS
Online Version: https://docs.microsoft.com/en-us/powers ... tionpolicy
Get-AzureRmSqlDatabaseBackupLongTermRetentionPolicy
Get-AzureRmSqlDatabaseLongTermRetentionBackup
Remove-AzureRmSqlDatabaseLongTermRetentionBackup
SQL Database Documentation https://docs.microsoft.com/azure/sql-database/
SYNOPSIS
Sets a server long term retention policy.
SYNTAX
Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy [-ResourceGroupName] <String> [-ServerName] <String> [-DatabaseName] <String>
[-MonthlyRetention] <String> [[-WeeklyRetention] <String>] [-DefaultProfile <IAzureContextContainer>] [-Confirm] [-WhatIf] [<CommonParameters>]
Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy [-ResourceGroupName] <String> [-ServerName] <String> [-DatabaseName] <String>
[[-MonthlyRetention] <String>] [[-WeeklyRetention] <String>] [-YearlyRetention] <String> [-WeekOfYear] <Int32> [-DefaultProfile
<IAzureContextContainer>] [-Confirm] [-WhatIf] [<CommonParameters>]
Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy [-ResourceGroupName] <String> [-ServerName] <String> [-DatabaseName] <String> [-DefaultProfile
<IAzureContextContainer>] -RemovePolicy [-Confirm] [-WhatIf] [<CommonParameters>]
Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy [-ResourceGroupName] <String> [-ServerName] <String> [-DatabaseName] <String> [-DefaultProfile
<IAzureContextContainer>] -ResourceId <String> -State <String> [-Confirm] [-WhatIf] [<CommonParameters>]
Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy [-ResourceGroupName] <String> [-ServerName] <String> [-DatabaseName] <String>
[-WeeklyRetention] <String> [-DefaultProfile <IAzureContextContainer>] [-Confirm] [-WhatIf] [<CommonParameters>]
DESCRIPTION
The Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy cmdlet sets the long term retention policy registered to this database. The policy is an
Azure Backup resource used to define backup storage policy.
PARAMETERS
-DatabaseName <String>
The name of the Azure SQL Database to use.
Required? true
Position? 2
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-DefaultProfile <IAzureContextContainer>
The credentials, account, tenant, and subscription used for communication with Azure.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-MonthlyRetention <String>
The Monthly Retention. If just a number is passed instead of an ISO 8601 string, days will be assumed as the units. There is a minumum of 7
days and a maximum of 10 years.
Required? true
Position? 3
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-RemovePolicy [<SwitchParameter>]
If provided, the policy for the database will be removed.
Required? true
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-ResourceGroupName <String>
The name of the resource group.
Required? true
Position? 0
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-ResourceId <String>
The Resource ID of the backup long term retention policy.
Required? true
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-ServerName <String>
The name of the Azure SQL Server the database is in.
Required? true
Position? 1
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-State <String>
The state of the long term retention backup policy, 'Enabled' or 'Disabled'
Required? true
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-WeeklyRetention <String>
The Weekly Retention. If just a number is passed instead of an ISO 8601 string, days will be assumed as the units. There is a minumum of 7
days and a maximum of 10 years.
Required? true
Position? 3
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-WeekOfYear <Int32>
The Week of Year, 1 to 52, to save for the Yearly Retention.
Required? true
Position? 4
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-YearlyRetention <String>
The Yearly Retention. If just a number is passed instead of an ISO 8601 string, days will be assumed as the units. There is a minumum of 7
days and a maximum of 10 years.
Required? true
Position? 3
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Confirm [<SwitchParameter>]
Prompts you for confirmation before running the cmdlet.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
None
This cmdlet does not accept any input.
OUTPUTS
Microsoft.Azure.Commands.Sql.Backup.Model.AzureSqlDatabaseBackupLongTermRetentionPolicyModel
NOTES
Example 1: Set the weekly retention for the current version of long term retention policy
PS C:\\> Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01
-WeeklyRetention P2W
ResourceGroupName : resourcegroup01
ServerName : server01
DatabaseName : database01
WeeklyRetention : P2W
MonthlyRetention : PT0S
YearlyRetention : PT0S
WeekOfYear : 0
State :
RecoveryServicesBackupPolicyResourceId :
Location :
This sets the long term retention policy of database01 to save every weekly full backup for 2 weeks
Example 2: Set the monthly retention for the current version of long term retention policy
PS C:\\> Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01
-MonthlyRetention P5Y
ResourceGroupName : resourcegroup01
ServerName : server01
DatabaseName : database01
WeeklyRetention : PT0S
MonthlyRetention : P5Y
YearlyRetention : PT0S
WeekOfYear : 0
State :
RecoveryServicesBackupPolicyResourceId :
Location :
This sets the long term retention policy of database01 to save the first full backup of each month for 5 years
Example 3: Set the yearly retention for the current version of long term retention policy
PS C:\\> Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01
-YearlyRetention P10Y -WeekOfYear 26
ResourceGroupName : resourcegroup01
ServerName : server01
DatabaseName : database01
WeeklyRetention : PT0S
MonthlyRetention : PT0S
YearlyRetention : P10Y
WeekOfYear : 26
State :
RecoveryServicesBackupPolicyResourceId :
Location :
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
Example 4: Set each retention for the current version of long term retention policy
PS C:\\> Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01
-WeeklyRetention 14 -MonthlyRetention P24W -YearlyRetention P10Y -WeekOfYear 26
ResourceGroupName : resourcegroup01
ServerName : server01
DatabaseName : database01
WeeklyRetention : P14D
MonthlyRetention : P24W
YearlyRetention : P10Y
WeekOfYear : 26
State :
RecoveryServicesBackupPolicyResourceId :
Location :
This 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
Example 4: Remove the long term retention policy
PS C:\\> Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01
-RemovePolicy
ResourceGroupName : resourcegroup01
ServerName : server01
DatabaseName : database01
WeeklyRetention : PT0S
MonthlyRetention : PT0S
YearlyRetention : PT0S
WeekOfYear : 0
State :
RecoveryServicesBackupPolicyResourceId :
Location :
Removes the policy for database01 so it no longer saves any long term retention backups. This will not affect backups that have already been taken
Example 4: Remove the long term retention policy
PS C:\\> Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01
-WeeklyRetention P0D
ResourceGroupName : resourcegroup01
ServerName : server01
DatabaseName : database01
WeeklyRetention : PT0S
MonthlyRetention : PT0S
YearlyRetention : PT0S
WeekOfYear : 0
State :
RecoveryServicesBackupPolicyResourceId :
Location :
This is another way of removing the policy for database01 so it no longer saves any long term retention backups. This will not affect backups that
have already been taken
RELATED LINKS
Online Version: https://docs.microsoft.com/en-us/powers ... tionpolicy
Get-AzureRmSqlDatabaseBackupLongTermRetentionPolicy
Get-AzureRmSqlDatabaseLongTermRetentionBackup
Remove-AzureRmSqlDatabaseLongTermRetentionBackup
SQL Database Documentation https://docs.microsoft.com/azure/sql-database/