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

Modifies a Backup protection policy.

Syntax

Set-AzureRmRecoveryServicesBackupProtectionPolicy
   [-Policy] <PolicyBase>
   [[-RetentionPolicy] <RetentionPolicyBase>]
   [[-SchedulePolicy] <SchedulePolicyBase>]
   [<CommonParameters>]

Description

The Set-AzureRmBackupProtectionPolicy cmdlet modifies an existing Azure Backup protection policy. You can modify the Backup schedule and retention policy components.

Any changes you make affect the backup and retention of the items associated with the policy.

Set the vault context by using the Set-AzureRmRecoveryServicesVaultContext cmdlet before you use the current cmdlet.

Examples

Example 1: Modify 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:\> $Pol = Get-AzureRmRecoveryServicesBackupProtectionPolicy -Name "NewPolicy"
PS C:\> Set-AzureRmRecoveryServicesBackupProtectionPolicy -Policy $Pol -SchedulePolicy $SchPol -RetentionPolicy $RetPol

The first command gets a base SchedulePolicy object, 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, and then stores it in the $DT variable.

The fourth command adds the date and time in $DT to the schedule run time for the schedule policy.

The fifth command gets a base retention policy object, and then stores it in the $RetPol variable.

The sixth command sets the retention duration to 365 days.

The seventh command gets the Backup protection policy named NewPolicy, and then stores it in the $Pol variable.

The final command modifies the Backup protection policy in $Pol using schedule policy in $SchPol and the retention policy in $RetPol.

Required Parameters

-Policy

Specifies the Backup protection policy that this cmdlet modifies. To obtain a BackupProtectionPolicy object, use the Get-AzureRmRecoveryServicesBackupProtectionPolicy cmdlet.

Type:PolicyBase
Position:1
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False

Optional Parameters

-RetentionPolicy

Specifies the base retention policy. To obtain a RetentionPolicy object, use the Get-AzureRmRecoveryServicesBackupRetentionPolicyObject cmdlet.

Type:RetentionPolicyBase
Position:2
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-SchedulePolicy

Specifies the base schedule policy object. To obtain a SchedulePolicy object, use the Get-AzureRmRecoveryServicesBackupSchedulePolicyObject object.

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