az backup policy create with custom yearly policy json

az backup policy create with custom yearly policy json

我正在尝试使用我创建的以下策略为单个年度备份创建一个 AZURE 备份策略:

{
  "properties": {
    "backupManagementType": "AzureIaasVM",
    "schedulePolicy": {
      "schedulePolicyType": "SimpleSchedulePolicy",
      "scheduleRunFrequency": "Weekly",
      "scheduleRunTimes": [
        "2018-01-24T10:00:00Z"
      ]
    },
    "retentionPolicy": {
      "retentionPolicyType": "LongTermRetentionPolicy",
      "yearlySchedule": {
        "retentionScheduleFormatType": "Weekly",
        "monthsOfYear": [
          "February"
        ],
        "retentionScheduleWeekly": {
          "daysOfTheWeek": [
            "Monday"
          ],
          "weeksOfTheMonth": [
            "Fourth"
          ]
        },
        "retentionTimes": [
          "2018-01-24T10:00:00Z"
        ],
        "retentionDuration": {
          "count": 1,
          "durationType": "Years"
        }
      }
    }
  }
}

通过 CLI 使用以下命令:

az backup policy create \
 --backup-management-type AzureIaasVM \
                        --policy _POCBKP/policy-test.json \
                        --name SimpleRetentionPolicy \
                        --resource-group $(RESOURCE_GROUP) \
                        --vault-name $(RESOURCE_GROUP)-Backup-Vault

我正在尝试各种方式和文档,但我没有正确理解某些内容。

输出:

2022-03-17T12:35:18.4460214Z ERROR: (BMSUserErrorInvalidPolicyInput) Input for create or update policy is not in proper format. Please check format of parameters like schedule time, schedule days, retention time and retention days 
2022-03-17T12:35:18.4461562Z Code: BMSUserErrorInvalidPolicyInput
2022-03-17T12:35:18.4462379Z Message: Input for create or update policy is not in proper format. Please check format of parameters like schedule time, schedule days, retention time and retention days 

@RCat 在您的策略中,您已将备份计划设置为每周,但未设置每周保留计划。这是供您参考的示例政策。

{
    "properties": {
    "backupManagementType": "AzureIaasVM",
    "schedulePolicy": {
      "schedulePolicyType": "SimpleSchedulePolicy",
      "scheduleRunFrequency": "Weekly",
      "scheduleRunDays": [
        "Monday"
      ],
      "scheduleRunTimes": [
        "2018-01-24T10:00:00Z"
      ],
      "scheduleWeeklyFrequency": 0
    },
    "retentionPolicy": {
      "retentionPolicyType": "LongTermRetentionPolicy",
      "weeklySchedule": {
        "daysOfTheWeek": [
          "Monday"
        ],
        "retentionTimes": [
          "2018-01-24T10:00:00Z"
        ],
        "retentionDuration": {
          "count": 1,
          "durationType": "Weeks"
        }
      },
      "yearlySchedule": {
        "retentionScheduleFormatType": "Weekly",
        "monthsOfYear": [
          "February"
        ],
        "retentionScheduleWeekly": {
          "daysOfTheWeek": [
            "Monday"
          ],
          "weeksOfTheMonth": [
            "Fourth"
          ]
        },
        "retentionTimes": [
          "2018-01-24T10:00:00Z"
        ],
        "retentionDuration": {
          "count": 4,
          "durationType": "Years"
        }
      }
    },
    "timeZone": "Pacific Standard Time",
    "protectedItemsCount": 0
  }
}