New-AzureRmRecoveryServicesBackupProtectionPolicy

Creates a Backup protection policy.

Caution

Because Az PowerShell modules now have all the capabilities of AzureRM PowerShell modules and more, we'll retire AzureRM PowerShell modules on 29 February 2024.

To avoid service interruptions, update your scripts that use AzureRM PowerShell modules to use Az PowerShell modules by 29 February 2024. To automatically update your scripts, follow the quickstart guide.

Syntax

New-AzureRmRecoveryServicesBackupProtectionPolicy
   [-Name] <String>
   [-WorkloadType] <WorkloadType>
   [[-BackupManagementType] <BackupManagementType>]
   [[-RetentionPolicy] <RetentionPolicyBase>]
   [[-SchedulePolicy] <SchedulePolicyBase>]
   [-VaultId <String>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

The New-AzureRmRecoveryServicesBackupProtectionPolicy cmdlet creates a Backup protection policy in a vault. A protection policy is associated with at least one retention policy. The retention policy defines how long a recovery point is kept with Azure Backup. You can use the Get-AzureRmRecoveryServicesBackupRetentionPolicyObject cmdlet to get the default retention policy. And you can use the Get-AzureRmRecoveryServicesBackupSchedulePolicyObject cmdlet to get the default schedule policy. The SchedulePolicy and RetentionPolicy objects are used as inputs to the New-AzureRmRecoveryServicesBackupProtectionPolicy cmdlet. Set the vault context by using the Set-AzureRmRecoveryServicesVaultContext cmdlet before you use the current cmdlet.

Examples

Example 1: Create a Backup protection policy

PS C:\> $SchPol = Get-AzureRmRecoveryServicesBackupSchedulePolicyObject -WorkloadType "AzureVM" 
PS C:\> $SchPol.ScheduleRunTimes.Clear()
PS C:\> $Dt = Get-Date
PS C:\> $SchPol.ScheduleRunTimes.Add($Dt.ToUniversalTime())
PS C:\> $RetPol = Get-AzureRmRecoveryServicesBackupRetentionPolicyObject -WorkloadType "AzureVM" 
PS C:\> $RetPol.DailySchedule.DurationCountInDays = 365
PS C:\> New-AzureRmRecoveryServicesBackupProtectionPolicy -Name "NewPolicy" -WorkloadType AzureVM -RetentionPolicy $RetPol -SchedulePolicy $SchPol

The first command gets a base SchedulePolicyObject, and then stores it in the $SchPol variable. The second command removes all scheduled run times from the schedule policy in $SchPol. The third command uses the Get-Date cmdlet to get the current date and time. The fourth command adds the current date and time in $Dt as the scheduled run time to the schedule policy. The fifth command gets a base RetentionPolicy object, and then stores it in the $RetPol variable. The sixth command sets the retention duration policy to 365 days. The final command creates a BackupProtectionPolicy object based on the schedule and retention policies created by the previous commands.

Parameters

-BackupManagementType

Specifies the Backup management type. The acceptable values for this parameter are:

  • AzureVM
  • AzureSQLDatabase
Type:Nullable<T>[BackupManagementType]
Accepted values:AzureVM, MARS, SCDPM, AzureBackupServer, AzureSQL
Position:3
Default value:None
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
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
Accept pipeline input:False
Accept wildcard characters:False

-Name

Specifies the name of the policy.

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

-RetentionPolicy

Specifies the base RetentionPolicy object. You can use the Get-AzureRmRecoveryServicesBackupRetentionPolicyObject cmdlet to get a RetentionPolicy object.

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

-SchedulePolicy

Specifies the base SchedulePolicy object. You can use the Get-AzureRmRecoveryServicesBackupSchedulePolicyObject cmdlet to get a SchedulePolicy object.

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

-VaultId

ARM ID of the Recovery Services Vault.

Type:String
Position:Named
Default value:None
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
Accept pipeline input:False
Accept wildcard characters:False

-WorkloadType

Specifies the workload type. The acceptable values for this parameter are:

  • AzureVM
  • AzureSQLDatabase
Type:WorkloadType
Accepted values:AzureVM, AzureSQLDatabase
Position:2
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

Inputs

WorkloadType

Nullable<T>[[Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.BackupManagementType, Microsoft.Azure.Commands.RecoveryServices.Backup.Models, Version=4.3.1.0, Culture=neutral, PublicKeyToken=null]]

RetentionPolicyBase

SchedulePolicyBase

String

Parameters: VaultId (ByValue)

Outputs

PolicyBase