< Back
New-AzureRmRecoveryServicesBackupProtectionPolicy
Post
NAME New-AzureRmRecoveryServicesBackupProtectionPolicy
SYNOPSIS
Creates a Backup protection policy.
SYNTAX
New-AzureRmRecoveryServicesBackupProtectionPolicy [-Name] <String> [-WorkloadType] {AzureVM | AzureSQLDatabase} [[-BackupManagementType] {AzureVM
| MARS | SCDPM | AzureBackupServer | AzureSQL}] [[-RetentionPolicy] <RetentionPolicyBase>] [[-SchedulePolicy] <SchedulePolicyBase>]
[-DefaultProfile <IAzureContextContainer>] [-Confirm] [-WhatIf] [<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.
PARAMETERS
-BackupManagementType <BackupManagementType>
Specifies the Backup management type. The acceptable values for this parameter are:
- AzureVM
- AzureSQLDatabase
Required? false
Position? 3
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-DefaultProfile <IAzureContextContainer>
The credentials, account, tenant, and subscription used for communication with azure.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Name <String>
Specifies the name of the policy.
Required? true
Position? 1
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-RetentionPolicy <RetentionPolicyBase>
Specifies the base RetentionPolicy object. You can use the Get-AzureRmRecoveryServicesBackupRetentionPolicyObject cmdlet to get a
RetentionPolicy object.
Required? false
Position? 4
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-SchedulePolicy <SchedulePolicyBase>
Specifies the base SchedulePolicy object. You can use the Get-AzureRmRecoveryServicesBackupSchedulePolicyObject cmdlet to get a SchedulePolicy
object.
Required? false
Position? 5
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-WorkloadType <WorkloadType>
Specifies the workload type. The acceptable values for this parameter are:
- AzureVM
- AzureSQLDatabase
Required? true
Position? 2
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Confirm [<SwitchParameter>]
Prompts you for confirmation before running the cmdlet.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
None
This cmdlet does not accept any input.
OUTPUTS
Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.PolicyBase
NOTES
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.
RELATED LINKS
Online Version:
https://docs.microsoft.com/en-us/powers ... tionpolicy
Enable-AzureRmRecoveryServicesBackupProtection
Get-AzureRmRecoveryServicesBackupProtectionPolicy
Get-AzureRmRecoveryServicesBackupRetentionPolicyObject
Get-AzureRmRecoveryServicesBackupSchedulePolicyObject
Remove-AzureRmRecoveryServicesBackupProtectionPolicy
Set-AzureRmRecoveryServicesBackupProtectionPolicy
SYNOPSIS
Creates a Backup protection policy.
SYNTAX
New-AzureRmRecoveryServicesBackupProtectionPolicy [-Name] <String> [-WorkloadType] {AzureVM | AzureSQLDatabase} [[-BackupManagementType] {AzureVM
| MARS | SCDPM | AzureBackupServer | AzureSQL}] [[-RetentionPolicy] <RetentionPolicyBase>] [[-SchedulePolicy] <SchedulePolicyBase>]
[-DefaultProfile <IAzureContextContainer>] [-Confirm] [-WhatIf] [<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.
PARAMETERS
-BackupManagementType <BackupManagementType>
Specifies the Backup management type. The acceptable values for this parameter are:
- AzureVM
- AzureSQLDatabase
Required? false
Position? 3
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-DefaultProfile <IAzureContextContainer>
The credentials, account, tenant, and subscription used for communication with azure.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Name <String>
Specifies the name of the policy.
Required? true
Position? 1
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-RetentionPolicy <RetentionPolicyBase>
Specifies the base RetentionPolicy object. You can use the Get-AzureRmRecoveryServicesBackupRetentionPolicyObject cmdlet to get a
RetentionPolicy object.
Required? false
Position? 4
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-SchedulePolicy <SchedulePolicyBase>
Specifies the base SchedulePolicy object. You can use the Get-AzureRmRecoveryServicesBackupSchedulePolicyObject cmdlet to get a SchedulePolicy
object.
Required? false
Position? 5
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-WorkloadType <WorkloadType>
Specifies the workload type. The acceptable values for this parameter are:
- AzureVM
- AzureSQLDatabase
Required? true
Position? 2
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Confirm [<SwitchParameter>]
Prompts you for confirmation before running the cmdlet.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
None
This cmdlet does not accept any input.
OUTPUTS
Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.PolicyBase
NOTES
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.
RELATED LINKS
Online Version:
https://docs.microsoft.com/en-us/powers ... tionpolicy
Enable-AzureRmRecoveryServicesBackupProtection
Get-AzureRmRecoveryServicesBackupProtectionPolicy
Get-AzureRmRecoveryServicesBackupRetentionPolicyObject
Get-AzureRmRecoveryServicesBackupSchedulePolicyObject
Remove-AzureRmRecoveryServicesBackupProtectionPolicy
Set-AzureRmRecoveryServicesBackupProtectionPolicy