New-AzureRmBackupProtectionPolicy

Creates a Backup policy.

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-AzureRmBackupProtectionPolicy
   [-Name] <String>
   [-Type] <String>
   [-BackupTime] <DateTime>
   [[-DaysOfWeek] <String[]>]
   [-RetentionPolicy] <AzureRMBackupRetentionPolicy[]>
   [-Vault] <AzureRMBackupVault>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
New-AzureRmBackupProtectionPolicy
   [-Name] <String>
   [-Type] <String>
   [-Daily]
   [-BackupTime] <DateTime>
   [-RetentionPolicy] <AzureRMBackupRetentionPolicy[]>
   [-Vault] <AzureRMBackupVault>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
New-AzureRmBackupProtectionPolicy
   [-Name] <String>
   [-Type] <String>
   [-Weekly]
   [-BackupTime] <DateTime>
   [-DaysOfWeek] <String[]>
   [-RetentionPolicy] <AzureRMBackupRetentionPolicy[]>
   [-Vault] <AzureRMBackupVault>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

The New-AzureRmBackupProtectionPolicy cmdlet creates an Azure Backup policy as an Azure PowerShell object. A backup policy defines when and how often Backup backs up an item. The Enable-AzureRmBackupProtection cmdlet uses a backup policy.

Examples

Example 1: Create a daily backup policy with daily and monthly retention

PS C:\>$Vault = Get-AzureRmBackupVault -Name "Vault03"
PS C:\> $Daily = New-AzureRmBackupRetentionPolicyObject -DailyRetention -Retention 30
PS C:\> $Monthly = New-AzureRmBackupRetentionPolicyObject -MonthlyRetentionInDailyFormat -DaysOfMonth (10, 20) -Retention 12
PS C:\> $ProtectionPolicy = New-AzureRmBackupProtectionPolicy -Name DailyBackup01 -Type AzureVM -Daily -BackupTime ([datetime]"3:30 PM") -RetentionPolicy ($Daily,$Monthly) -Vault $Vault
Name                      Type               ScheduleType       BackupTime
----                      ----               ------------       ----------
DailyBkp                  AzureVM            Daily              26-Aug-15 3:00:00 PM

The first command gets the vault named Vault03 by using the Get-AzureRmBackupVault cmdlet. The command stores that object in the $Vault variable. The second command creates a retention policy for 30 days of daily retention, and then stores it in the $Daily variable. The third command creates a retention policy that keeps the backup on the tenth and the twentieth of each month for twelve months. The command stores the retention policy in the $Monthly variable. The final command creates a backup policy for the vault in $Vault that has a daily backup time of 3:00 PM. The command assigns the retention policies stored in $Daily and $Monthly. The command stores the result in the $ProtectionPolicy variable.

Parameters

-BackupTime

Specifies the time of day, as a DateTime object, for the backup operation. To obtain a DateTime, use the Get-Date cmdlet. For information about DateTime objects, type Get-Help Get-Date.

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

-Daily

Indicates that the backup operation runs on a Daily schedule.

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

-DaysOfWeek

Specifies an array of days of the week. This policy runs backups on the days specified by this parameter. The acceptable values for this parameter are:

  • Monday
  • Tuesday
  • Wednesday
  • Thursday
  • Friday
  • Saturday
  • Sunday If you specify the Weekly parameter, specify this parameter.
Type:String[]
Accepted values:Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
Position:6
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:AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Name

Specifies a name for the backup policy. Select a name that is unique in the vault.

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

-RetentionPolicy

Specifies an array of retention policies for the backup policy. To obtain an AzureRmBackupRetentionPolicy, use the New-AzureRmBackupRetentionPolicyObject cmdlet.

Type:AzureRMBackupRetentionPolicy[]
Position:7
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Type

Specifies the type of backup item to which the policy applies. Currently, the only supported value is AzureVM.

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

-Vault

Specifies the Azure Backup vault to which the backup policy belongs. To obtain an AzureRmBackupVault object, use the Get-AzureRmBackupVault cmdlet.

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

-Weekly

Indicates that the backup policy is triggered weekly on one or more days of the week.

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

Inputs

String

DateTime

String[]

AzureRMBackupRetentionPolicy[]

AzureRMBackupVault

Parameters: Vault (ByValue)

Outputs

AzureRMBackupProtectionPolicy

Notes

  • None