New-AzureRmBackupRetentionPolicyObject

Creates a Backup retention policy.

Warning

The AzureRM PowerShell module has been officially deprecated as of February 29, 2024. Users are advised to migrate from AzureRM to the Az PowerShell module to ensure continued support and updates.

Although the AzureRM module may still function, it's no longer maintained or supported, placing any continued use at the user's discretion and risk. Please refer to our migration resources for guidance on transitioning to the Az module.

Syntax

New-AzureRmBackupRetentionPolicyObject
   [-DailyRetention]
   -Retention <Int32>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
New-AzureRmBackupRetentionPolicyObject
   [-WeeklyRetention]
   -DaysOfWeek <String[]>
   -Retention <Int32>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
New-AzureRmBackupRetentionPolicyObject
   [-MonthlyRetentionInDailyFormat]
   -DaysOfMonth <System.Collections.Generic.List`1[System.String]>
   -Retention <Int32>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
New-AzureRmBackupRetentionPolicyObject
   [-MonthlyRetentionInWeeklyFormat]
   -DaysOfWeek <String[]>
   -WeekNumber <String[]>
   -Retention <Int32>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
New-AzureRmBackupRetentionPolicyObject
   [-YearlyRetentionInDailyFormat]
   -DaysOfMonth <System.Collections.Generic.List`1[System.String]>
   -MonthsOfYear <String[]>
   -Retention <Int32>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
New-AzureRmBackupRetentionPolicyObject
   [-YearlyRetentionInWeeklyFormat]
   -DaysOfWeek <String[]>
   -WeekNumber <String[]>
   -MonthsOfYear <String[]>
   -Retention <Int32>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

The New-AzureRmBackupRetentionPolicyObject cmdlet creates an Azure Backup retention policy. A retention policy defines how long Backup keeps a recovery point. The types of retention are the following:

  • Daily
  • Weekly
  • Monthly
  • Yearly Create one retention policy for each type of retention that you plan to use. A backup policy is associated with at least one retention policy. To create a backup policy, use the New-AzureRmBackupProtectionPolicy cmdlet. You can instead provide a retention policy to the Enable-AzureRmBackupProtection cmdlet.

Examples

Example 1: Create a retention policy for daily retention

PS C:\>$Daily = New-AzureRmBackupRetentionPolicyObject -DailyRetention -Retention 30
PS C:\> $Daily
RetentionType      Retention          RetentionTimes
-------------      ---------          --------------
Daily              30

The first command creates a retention policy for 30 days of daily retention, and then stores it in the $Daily variable. The second command displays the contents of $Daily.

Example 2: Create a monthly retention policy

PS C:\>$Monthly = New-AzureRmBackupRetentionPolicyObject -MonthlyRetentionInDailyFormat -DaysOfMonth (10, 20) -Retention 12
PS C:\> $Monthly | select *
RetentionFormat : Daily
DaysOfMonth     : {10, 20}
WeekNumber      : 
DaysOfWeek      : 
RetentionType   : Monthly
Retention       : 12
RetentionTimes  :

The first command creates a retention policy that keeps the backup on the tenth and the twentieth of each month for twelve months. The command stores the retention policy in the $Monthly variable. The second command displays the contents of $Monthly.

Parameters

-DailyRetention

Indicates that this cmdlet creates a Daily retention policy.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DaysOfMonth

Specifies the days of the month that identify which recovery points Backup retains and for how long. The acceptable values for this parameter are: integers from 1 through 28 and Last. Specify this parameter if you specify the DailyRetention, MonthlyRetentionInDailyFormat, and YearlyRetentionInDailyFormat parameters.

Type:List<T>[String]
Accepted values:1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, Last
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-DaysOfWeek

Specifies an array of days of the week. The days that this cmdlet specifies identify which recovery points that Backup retains and for how long. The acceptable values for this parameter are:

  • Monday
  • Tuesday
  • Wednesday
  • Thursday
  • Friday
  • Saturday
  • Sunday Specify this parameter if you specify the WeeklyRetention, MonthlyRetentionInWeeklyFormat, and YearlyRetentionInWeeklyFormat parameters. Be sure that the days of the week you select for backup and for retention are aligned. For example, if your backup is set for Saturdays, the retention policies must also use Saturday.
Type:String[]
Accepted values:Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
Position:Named
Default value:None
Required:True
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
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-MonthlyRetentionInDailyFormat

Indicates that this cmdlet creates a Monthly policy in Daily format.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-MonthlyRetentionInWeeklyFormat

Indicates that this cmdlet creates a Monthly policy in Weekly format.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-MonthsOfYear

Specifies which months of the year have the recovery points that Backup retains on a yearly basis. The acceptable values for this parameter are: names of months, such as January or February.

Type:String[]
Accepted values:January, February, March, April, May, June, July, August, September, October, November, December
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Retention

Specifies the retention period, in days, months, or years, for which Backup stores a backup point. The unit depends on whether this cmdlet selects a daily, monthly, or yearly retention option. For example, if specify the DailyRetention parameter, the cmdlet interprets the current parameter as a number of days.

Type:Int32
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-WeeklyRetention

Indicates that this cmdlet creates a Weekly retention policy.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WeekNumber

Specifies the weeks of the month that identify which recovery points Backup retains and for how long. The acceptable values for this parameter are:

  • First
  • Second
  • Third
  • Fourth
  • Last
Type:String[]
Accepted values:First, Second, Third, Fourth, Last
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-YearlyRetentionInDailyFormat

Indicates that this cmdlet creates a Yearly retention policy in Daily format.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-YearlyRetentionInWeeklyFormat

Indicates that this cmdlet creates a Yearly retention policy in Weekly format.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

None

Outputs

AzureRMBackupRetentionPolicy

Notes

  • None