New-AzureRmVMSqlServerAutoBackupConfig

Creates a configuration object for SQL Server automatic backup.

Warning

The AzureRM PowerShell module has been officially deprecated as of February 29, 2024. Users are advised to migrate from AzureRM to the Az PowerShell module to ensure continued support and updates.

Although the AzureRM module may still function, it's no longer maintained or supported, placing any continued use at the user's discretion and risk. Please refer to our migration resources for guidance on transitioning to the Az module.

Syntax

New-AzureRmVMSqlServerAutoBackupConfig
   [-ResourceGroupName] <String>
   [-Enable]
   [[-RetentionPeriodInDays] <Int32>]
   [-EnableEncryption]
   [[-CertificatePassword] <SecureString>]
   [[-StorageUri] <Uri>]
   [[-StorageKey] <SecureString>]
   [-BackupSystemDbs]
   [-BackupScheduleType <String>]
   [-FullBackupFrequency <String>]
   [-FullBackupStartHour <Int32>]
   [-FullBackupWindowInHours <Int32>]
   [-LogBackupFrequencyInMinutes <Int32>]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
New-AzureRmVMSqlServerAutoBackupConfig
   [-ResourceGroupName] <String>
   [-Enable]
   [[-RetentionPeriodInDays] <Int32>]
   [-EnableEncryption]
   [[-CertificatePassword] <SecureString>]
   [[-StorageContext] <IStorageContext>]
   [[-StorageUri] <Uri>]
   [[-StorageKey] <SecureString>]
   [-BackupSystemDbs]
   [-BackupScheduleType <String>]
   [-FullBackupFrequency <String>]
   [-FullBackupStartHour <Int32>]
   [-FullBackupWindowInHours <Int32>]
   [-LogBackupFrequencyInMinutes <Int32>]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

The New-AzureRmVMSqlServerAutoBackupConfig cmdlet creates a configuration object for SQL Server automatic backup.

Examples

Example 1: Create an automatic backup configuration using storage URI and account key

PS C:\> $AutoBackupConfig = New-AzureRmVMSqlServerAutoBackupConfig -Enable -RetentionPeriod 10 -StorageUri "\\contoso\StorageGeneral" -StorageKey "< Storage Key for ContosoGeneral >"
Enable                : True
EnableEncryption      : False
RetentionPeriodInDays : 10

This command creates an automatic backup configuration object by specifying storage URI and account key. Automatic backup is enabled and automatic backups are kept for 10 days. The command stores the result in the $AutoBackupConfig variable. You can specify this configuration item for other cmdlets, such as the Set-AzureRmVMSqlServerExtension cmdlet.

Example 2: Create an automatic backup configuration using storage context

PS C:\> $StorageContext = New-AzureStorageContext -StorageAccountName "ContosoGeneral" -StorageAccountKey "< Storage Key for ContosoGeneral >"
PS C:\> $AutoBackupConfig = New-AzureRmVMSqlServerAutoBackupConfig -StorageContext $StorageContext -Enable -RetentionPeriod 10
Enable                : True
EnableEncryption      : False
RetentionPeriodInDays : 10

The first command creates a storage context, and then stores it in the $StorageContext variable. For more information, see New-AzureStorageContext. The second command creates an automatic backup configuration object by specifying the storage context in $StorageContext. Automatic backup is enabled and automatic backups are kept for 10 days.

Example 3: Create an automatic backup configuration using storage context with encryption and password

PS C:\> $StorageContext = New-AzureRmVMSqlServerAutoBackupConfig -StorageContext $StorageContext -Enable -RetentionPeriod 10 -EnableEncryption -CertificatePassword $CertificatePassword
Enable                : True
EnableEncryption      : True
RetentionPeriodInDays : 10

This command creates and stores an automatic backup configuration object. The command specifies the storage context created in a previous example. The command enables encryption with password. The password was previously stored as a secure string in the $CertificatePassword variable. To create a secure string, use the ConvertTo-SecureString cmdlet.

Parameters

-BackupScheduleType

Backup schedule type, manual or automated

Type:String
Accepted values:Manual, Automated
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-BackupSystemDbs

Backup system databases

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

-CertificatePassword

Specifies a password to encrypt the certificate that is used to perform SQL Server encrypted backups.

Type:SecureString
Position:4
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

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

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

-Enable

Indicates that automated backup for the SQL Server virtual machine is enabled. If you specify this parameter, automated backup sets a backup schedule for all current and new databases. This updates your Managed Backup settings to follow this schedule.

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

-EnableEncryption

Indicates that this cmdlet enables encryption.

Type:SwitchParameter
Position:3
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-FullBackupFrequency

Sql Server Full Backup frequency, daily or weekly

Type:String
Accepted values:Daily, Weekly
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-FullBackupStartHour

Hour of the day (0-23) when the Sql Server Full Backup should start

Type:Nullable<T>[Int32]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-FullBackupWindowInHours

Sql Server Full Backup window in hours

Type:Nullable<T>[Int32]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-LogBackupFrequencyInMinutes

Sql Server Log Backup frequency, once every 1-60 minutes

Type:Nullable<T>[Int32]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-ResourceGroupName

Specifies the name of the resource group of the virtual machine.

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

-RetentionPeriodInDays

Specifies the number of days to retain a backup.

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

-StorageContext

Specifies the storage account that will be used to store backups. To obtain an AzureStorageContext object, use the New-AzureStorageContext cmdlet. The default is the storage account that is associated with the SQL Server virtual machine.

Type:IStorageContext
Position:5
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-StorageKey

Specifies the storage key of the blob storage account.

Type:SecureString
Position:5
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-StorageUri

Specifies the Uniform Resource Identifier (URI) of the blob storage account.

Type:Uri
Position:4
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

Inputs

String

SwitchParameter

Int32

IStorageContext

Uri

SecureString

Nullable<T>[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]

Outputs

AutoBackupSettings