New-​Azure​Rm​Backup​Retention​Policy​Object

Creates a Backup retention policy.

Syntax

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

Required Parameters

-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:System.Collections.Generic.List`1[System.String]
Parameter Sets: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
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[]
Parameter Sets:Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
Position:Named
Default value:None
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[]
Parameter Sets:January, February, March, April, May, June, July, August, September, October, November, December
Position:Named
Default value:None
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
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[]
Parameter Sets:First, Second, Third, Fourth, Last
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Optional Parameters

-DailyRetention

Indicates that this cmdlet creates a Daily retention policy.

Type:SwitchParameter
Position:Named
Default value:None
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
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
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
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
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
Accept pipeline input:False
Accept wildcard characters:False

Inputs

None

Outputs

AzureRmBackupRetentionPolicy

Notes

  • None