Set-AzSqlDatabaseBackupShortTermRetentionPolicy

Sets a backup short term retention policy.

Syntax

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

Description

The Set-AzSqlDatabaseBackupShortTermRetentionPolicy cmdlet gets the short term retention policy registered to this database. The policy is the retention period, in days, for point-in-time restore backups.

Examples

Example 1

PS C:\> Set-AzSqlDatabaseBackupShortTermRetentionPolicy -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01 -RetentionDays 35
 ResourceGroupName ServerName  DatabaseName RetentionDays
----------------- ----------  ------------ -------------
resourcegroup01   server01    database01   35

This command sets the short term retention policy for database01 to 35 days.

Example 2

PS C:\> Get-AzSqlDatabase -ResourceGroupName resourcegroup01 -ServerName server01 -DatabaseName database01 | Set-AzSqlDatabaseBackupShortTermRetentionPolicy -RetentionDays 35
 ResourceGroupName ServerName  DatabaseName RetentionDays
----------------- ----------  ------------ -------------
resourcegroup01   server01    database01   35

This command sets the short term retention policy for database01 to 35 days via piping in a database object.

Parameters

-AzureSqlDatabaseObject

The database object to get the policy for.

Type:AzureSqlDatabaseModel
Aliases:AzureSqlDatabase
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
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
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-DefaultProfile

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

Type:Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ResourceGroupName

The name of the resource group.

Type:String
Position:0
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ResourceId

The short term retention policy resource Id.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-RetentionDays

The backup retention setting, in days.

Type:Int32
Position:3
Default value:None
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
Accept pipeline input:True (ByPropertyName)
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
Accept pipeline input:False
Accept wildcard characters:False

Inputs

AzureSqlDatabaseModel

String

Outputs

Microsoft.Azure.Commands.Sql.Backup.Model.AzureSqlDatabaseBackupShortTermRetentionPolicyModel