New-​Azure​Rm​Recovery​Services​Backup​Protection​Policy

Creates a Backup protection policy.

Syntax

New-AzureRmRecoveryServicesBackupProtectionPolicy
   [-Name] <String>
   [-WorkloadType] <WorkloadType>
   [[-BackupManagementType] <BackupManagementType>]
   [[-RetentionPolicy] <RetentionPolicyBase>]
   [[-SchedulePolicy] <SchedulePolicyBase>]
   [<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.RemoveAll()
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.

Required Parameters

-Name

Specifies the name of the policy.

Type:String
Position:1
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
Parameter Sets:AzureVM, AzureSQLDatabase
Position:2
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Optional Parameters

-BackupManagementType

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

  • AzureVM
  • AzureSQLDatabase
Type:BackupManagementType
Parameter Sets:AzureVM, MARS, SCDPM, AzureBackupServer, AzureSQL
Position:3
Default value:None
Accept pipeline input:True (ByPropertyName)
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 (ByPropertyName)
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 (ByPropertyName)
Accept wildcard characters:False