Set-AzSqlDatabaseBackupShortTermRetentionPolicy
Sets a backup short term retention policy.
Syntax
PolicyByResourceServerDatabaseSet (Default)
Set-AzSqlDatabaseBackupShortTermRetentionPolicy
[-ResourceGroupName] <String>
[-ServerName] <String>
[-DatabaseName] <String>
[-RetentionDays <Int32>]
[-DiffBackupIntervalInHours <Int32>]
[-LockImmutability <Boolean>]
[-Force]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[-AcquirePolicyToken]
[-ChangeReference <String>]
[<CommonParameters>]
Set-AzSqlDatabaseBackupShortTermRetentionPolicy
-AzureSqlDatabaseObject <AzureSqlDatabaseModel>
[-RetentionDays <Int32>]
[-DiffBackupIntervalInHours <Int32>]
[-LockImmutability <Boolean>]
[-Force]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[-AcquirePolicyToken]
[-ChangeReference <String>]
[<CommonParameters>]
PolicyByResourceIdSet
Set-AzSqlDatabaseBackupShortTermRetentionPolicy
-ResourceId <String>
[-RetentionDays <Int32>]
[-DiffBackupIntervalInHours <Int32>]
[-LockImmutability <Boolean>]
[-Force]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[-AcquirePolicyToken]
[-ChangeReference <String>]
[<CommonParameters>]
Description
The Set-AzSqlDatabaseBackupShortTermRetentionPolicy cmdlet sets the short term retention policy for this database.
The policy is the retention period, in days, for point-in-time restore backups and differential backup frequency, in hours.
Examples
Example 1
Set-AzSqlDatabaseBackupShortTermRetentionPolicy -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01 -RetentionDays 6 -DiffBackupIntervalInHours 24
ResourceGroupName : resourcegroup01
ServerName : server01
DatabaseName : database01
RetentionDays : 6
DiffBackupIntervalInHours : 24
ImmutabilityStatus : Enabled
This command sets the short term retention policy for database01 to 6 retention days and 24 differential backup interval hours.
Example 2
Get-AzSqlDatabase -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01 | Set-AzSqlDatabaseBackupShortTermRetentionPolicy -RetentionDays 5 -DiffBackupIntervalInHours 12
ResourceGroupName : resourcegroup01
ServerName : server01
DatabaseName : database01
RetentionDays : 5
DiffBackupIntervalInHours : 12
ImmutabilityStatus : Enabled
This command sets the short term retention policy for database01 to 5 retention days and 12 differential backup interval hours via piping in a database object.
Example 3
Set-AzSqlDatabaseBackupShortTermRetentionPolicy -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01 -RetentionDays 7
ResourceGroupName : resourcegroup01
ServerName : server01
DatabaseName : database01
RetentionDays : 7
DiffBackupIntervalInHours : 12
ImmutabilityStatus : Enabled
This command sets the short term retention policy for database01 to 7 retention days only. DiffBackupIntervalInHours is unchanged.
Example 4
Set-AzSqlDatabaseBackupShortTermRetentionPolicy -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01 -RetentionDays 7 -LockImmutability $true -Force
ResourceGroupName : resourcegroup01
ServerName : server01
DatabaseName : database01
RetentionDays : 7
DiffBackupIntervalInHours : 12
ImmutabilityStatus : Locked
This command sets the short term retention policy for database01 to 7 days and locks backup immutability. The -Force parameter skips the confirmation prompt for this irreversible action.
Parameters
-AcquirePolicyToken
Acquire an Azure Policy token automatically for this resource operation.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-AzureSqlDatabaseObject
The database object to get the policy for.
Parameter properties
Type: AzureSqlDatabaseModel
Default value: None
Supports wildcards: False
DontShow: False
Aliases: AzureSqlDatabase
Parameter sets
PolicyByInputObjectSet
Position: Named
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: False
Value from remaining arguments: False
-ChangeReference
The change reference resource ID for this resource operation.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Aliases: cf
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-DatabaseName
The name of the Azure SQL Database to use.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
PolicyByResourceServerDatabaseSet
Position: 2
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.
Parameter properties
Type: IAzureContextContainer
Default value: None
Supports wildcards: False
DontShow: False
Aliases: AzContext, AzureRmContext, AzureCredential
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-DiffBackupIntervalInHours
Differential backup frequency in hours.
Parameter properties
Type: Int32
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Force
Skip confirmation when locking backup immutability.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-LockImmutability
Whether to lock the immutability of backups governed by this policy.
Parameter properties
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ResourceGroupName
The name of the resource group.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
PolicyByResourceServerDatabaseSet
Position: 0
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-ResourceId
The short term retention policy resource Id.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
PolicyByResourceIdSet
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-RetentionDays
The backup retention setting, in days.
Parameter properties
Type: Int32
Default value: 7
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ServerName
The name of the Azure SQL Server the database is in.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
PolicyByResourceServerDatabaseSet
Position: 1
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Aliases: wi
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters .
Outputs