| external help file | |
|---|---|
| Module Name | Az.DataProtection |
| online version | https://learn.microsoft.com/powershell/module/az.dataprotection/edit-azdataprotectionpolicyretentionruleclientobject |
| schema | 2.0.0 |
Adds or removes Retention Rule to an existing backup policy.
Edit-AzDataProtectionPolicyRetentionRuleClientObject -Name <RetentionRuleName> -Policy <IBackupPolicy>
-RemoveRule [<CommonParameters>]
Edit-AzDataProtectionPolicyRetentionRuleClientObject -IsDefault <Boolean> -LifeCycles <ISourceLifeCycle[]>
-Name <RetentionRuleName> -Policy <IBackupPolicy> [-OverwriteLifeCycle <Boolean?>] [<CommonParameters>]
Adds or removes Retention Rule to an existing backup policy.
$pol = Get-AzDataProtectionPolicyTemplate
$lifecycle = New-AzDataProtectionRetentionLifeCycleClientObject -SourceDataStore OperationalStore -SourceRetentionDurationType Weeks -SourceRetentionDurationCount 5
Edit-AzDataProtectionPolicyRetentionRuleClientObject -Policy $pol -Name Weekly -LifeCycles $lifecycle -IsDefault $falseDatasourceType ObjectType
-------------- ----------
{Microsoft.Compute/disks} BackupPolicy
The first command gets the default policy template. The second command creates a weekly lifecycle object. The third command adds a weekly retention rule to the default policy.
Edit-AzDataProtectionPolicyRetentionRuleClientObject -Policy $pol -Name Weekly -RemoveRuleDatasourceType ObjectType
-------------- ----------
{Microsoft.Compute/disks} BackupPolicy
This command removes weekly retention rule if it exists in given backup policy.
$pol = Get-AzDataProtectionPolicyTemplate -DatasourceType AzureBlob
$opLifecycle = New-AzDataProtectionRetentionLifeCycleClientObject -SourceDataStore OperationalStore -SourceRetentionDurationType Days -SourceRetentionDurationCount 30
Edit-AzDataProtectionPolicyRetentionRuleClientObject -Policy $pol -Name Default_OperationalStore -LifeCycles $opLifecycle -IsDefault $trueDatasourceType ObjectType
-------------- ----------
{Microsoft.Storage/storageAccounts/blobServices} BackupPolicy
For AzureBlob, OperationalStore retention rules must be named Default_OperationalStore. The rule is added additively — the existing Default (VaultStore) retention rule on the policy template is preserved. Passing -Name Default with an OperationalStore lifecycle is rejected by validation.
Note: -OverwriteLifeCycle is deprecated and will be removed in an upcoming release. Setting -OverwriteLifeCycle $false blocks updating an existing retention rule; when $true or omitted, the existing rule's lifecycles are replaced in place — the default behavior once this parameter is removed.
Specifies if retention rule is default retention rule.
Type: System.Boolean
Parameter Sets: AddRetention
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseLife cycles associated with the retention rule.
Type: Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.ISourceLifeCycle[]
Parameter Sets: AddRetention
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseRetention Rule Name.
Note: "Default" retention rules cannot be removed, regardless of lifecycle.
Type: Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Support.RetentionRuleName
Parameter Sets: (All)
Aliases:
Accepted values: Default, Daily, Weekly, Monthly, Yearly, Default_OperationalStore
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False[Deprecated] Optional; this parameter will be removed in an upcoming release. Setting -OverwriteLifeCycle $false blocks updating an existing retention rule; when $true or omitted, the existing rule's lifecycles are replaced in place — the default behavior once this parameter is removed.
Type: System.Nullable`1[[System.Boolean, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
Parameter Sets: AddRetention
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseBackup Policy Object
Type: Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.IBackupPolicy
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies whether to remove the retention rule.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: RemoveRetention
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
"Default"retention rules cannot be removed, regardless of lifecycle.-RemoveRule -Name DefaultthrowsRemoving Default Retention Rule is not allowed. Please try again with different rule name.-OverwriteLifeCycleis deprecated and will be removed in an upcoming release. Setting-OverwriteLifeCycle $falseblocks updating an existing retention rule; when$trueor omitted, the existing rule's lifecycles are replaced in place — the default behavior once this parameter is removed.