我尝试使用Recovery Services Vault在Azure中启用IaaS VM备份,并且在尝试使用Azure New-AzureRmRecoveryServicesBackupProtectionPolicy
创建新的保护策略时失败。
该脚本适用于以前的订阅和虚拟机,所以我不清楚为什么它不能用于此订阅。我运行Azure New-AzureRmRecoveryServicesBackupProtectionPolicy -Debug
会返回以下附加信息,遗憾的是,这还不足以突出显示并解决问题:
"error": {
"code": "InvalidRestApiParameter",
"message": "stampId parameter is invalid.\r\nPlease provide a valid stampId",
"target": null,
"details": null,
"innerError": null
}
以下是尝试创建保护政策的代码:
# Create Retention Policy object. Has to be modified from existing 'default' values provided by Azure
$RetPol = Get-AzureRmRecoveryServicesBackupRetentionPolicyObject -WorkloadType "AzureVM"
$BackupTime = (Get-Date).ToUniversalTime().Date.AddHours(23)
$Day = $true
$DayTime = $BackupTime
$DayRet = 7
$Week = $true
$WeekDay = 'Sunday'
$WeekTime = $BackupTime
$WeekRet = 5
$Month = $true
$MonthType = 'Daily'
$MonthTime = $BackupTime
$MonthDay = New-Object -TypeName PSObject -Property @{
Date = 0;
IsLast = $true;
}
$MonthRet = 3
$Year = $false
$RetPol.IsDailyScheduleEnabled = $Day
$RetPol.DailySchedule.DurationCountInDays = $DayRet
$RetPol.DailySchedule.RetentionTimes[0] = $DayTime
$RetPol.IsWeeklyScheduleEnabled = $Week
$RetPol.WeeklySchedule.DaysOfTheWeek = $WeekDay
$RetPol.WeeklySchedule.DurationCountInWeeks = $WeekRet
$RetPol.WeeklySchedule.RetentionTimes[0] = $WeekTime
$RetPol.IsMonthlyScheduleEnabled = $Month
$RetPol.MonthlySchedule.RetentionScheduleFormatType = $MonthType
$RetPol.MonthlySchedule.RetentionScheduleDaily.DaysOfTheMonth = $MonthDay
$RetPol.MonthlySchedule.DurationCountInMonths = $MonthRet
$RetPol.MonthlySchedule.RetentionScheduleWeekly = $null
$RetPol.MonthlySchedule.RetentionTimes[0] = $MonthTime
$RetPol.IsYearlyScheduleEnabled = $Year
$RetPol.YearlySchedule = $null
# Create Schedule Policy object.
$SchPol = Get-AzureRmRecoveryServicesBackupSchedulePolicyObject -WorkloadType "AzureVM"
$SchPol.ScheduleRunFrequency = "Daily"
$SchPol.ScheduleRunDays = $null
$SchPol.ScheduleRunTimes[0] = $BackupTime
#Create the new Backup Policy
$BackupPolicy = New-AzureRmRecoveryServicesBackupProtectionPolicy -WorkloadType AzureVM -Name 'MyPolicy' -RetentionPolicy $RetPol -SchedulePolicy $SchPol
非常感谢任何帮助或想法。
答案 0 :(得分:1)
TL;DR: Deleted and re-created the Recovery Services Vault via PowerShell
Full Description
Turned-out that something had previously gone wrong with the creation of the Recovery Services Vault, which wasn't clear when I'd run New-AzureRmRecoveryServicesVault
but had resulted in the following view of the RSV when opened via the Portal:
The RSV wouldn't delete via the portal so I had to use Remove-AzureRmRecoveryServicesVault
to remove it. I then re-created it, which resolved the error and allowed me to backup the VMs