Editar

Partilhar via


Set-AzSqlDatabaseBackupShortTermRetentionPolicy

Sets a backup short term retention policy.

Syntax

Set-AzSqlDatabaseBackupShortTermRetentionPolicy
   [-RetentionDays <Int32>]
   [-DiffBackupIntervalInHours <Int32>]
   [-ResourceGroupName] <String>
   [-ServerName] <String>
   [-DatabaseName] <String>
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Set-AzSqlDatabaseBackupShortTermRetentionPolicy
   [-RetentionDays <Int32>]
   [-DiffBackupIntervalInHours <Int32>]
   -AzureSqlDatabaseObject <AzureSqlDatabaseModel>
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Set-AzSqlDatabaseBackupShortTermRetentionPolicy
   [-RetentionDays <Int32>]
   [-DiffBackupIntervalInHours <Int32>]
   -ResourceId <String>
   [-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.

Type:AzureSqlDatabaseModel
Aliases:AzureSqlDatabase
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DatabaseName

The name of the Azure SQL Database to use.

Type:String
Position:2
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DiffBackupIntervalInHours

Differential backup frequency in hours.

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ResourceGroupName

The name of the resource group.

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ResourceId

The short term retention policy resource Id.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-RetentionDays

The backup retention setting, in days.

Type:Int32
Position:Named
Default value:7
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ServerName

The name of the Azure SQL Server the database is in.

Type:String
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

AzureSqlDatabaseModel

String

Outputs

AzureSqlDatabaseBackupShortTermRetentionPolicyModel