Edit

Share via


Set-AzSqlDatabaseBackupShortTermRetentionPolicy

Sets a backup short term retention policy.

Syntax

PolicyByResourceServerDatabaseSet (Default)

Set-AzSqlDatabaseBackupShortTermRetentionPolicy
    [-ResourceGroupName] <String>
    [-ServerName] <String>
    [-DatabaseName] <String>
    [-RetentionDays <Int32>]
    [-DiffBackupIntervalInHours <Int32>]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

PolicyByInputObjectSet

Set-AzSqlDatabaseBackupShortTermRetentionPolicy
    -AzureSqlDatabaseObject <AzureSqlDatabaseModel>
    [-RetentionDays <Int32>]
    [-DiffBackupIntervalInHours <Int32>]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

PolicyByResourceIdSet

Set-AzSqlDatabaseBackupShortTermRetentionPolicy
    -ResourceId <String>
    [-RetentionDays <Int32>]
    [-DiffBackupIntervalInHours <Int32>]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<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 ServerName DatabaseName RetentionDays DiffBackupIntervalInHours
----------------- ---------- ------------ ------------- -------------------------
resourcegroup01   server01   database01   6             24

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 ServerName DatabaseName RetentionDays DiffBackupIntervalInHours
----------------- ---------- ------------ ------------- ------------------------
resourcegroup01   server01   database01   5             12

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 ServerName DatabaseName RetentionDays DiffBackupIntervalInHours
----------------- ---------- ------------ ------------- -------------------------
resourcegroup01   server01   database01   7             12

This command sets the short term retention policy for database01 to 7 retention days only. DiffBackupIntervalInHours is unchanged.

Parameters

-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

-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

-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.

Inputs

AzureSqlDatabaseModel

String

Outputs

AzureSqlDatabaseBackupShortTermRetentionPolicyModel