Search code examples
azurecommand-line-interfacebackuppolicy

AZ CLI backup policy retentionDuration not save more than 7 days


I´m using the AZ CLI to configure Backups to my MVs.

I create the following backup policy:

{
  "eTag": null,
  "id": "/#############",
  "location": null,
  "name": "DefaultPolicy",
  "properties": {
    "backupManagementType": "AzureIaasVM",
    "instantRpDetails": {
      "azureBackupRgNamePrefix": null,
      "azureBackupRgNameSuffix": null
    },
    "instantRpRetentionRangeInDays": 2,
    "protectedItemsCount": 1,
    "retentionPolicy": {
      "dailySchedule": {
        "retentionDuration": {
          "count": 30,
          "durationType": "Days"
        },
        "retentionTimes": [
          "2021-07-30T18:30:00+00:00"
        ]
      },
      "monthlySchedule": null,
      "retentionPolicyType": "LongTermRetentionPolicy",
      "weeklySchedule": null,
      "yearlySchedule": null
    },
    "schedulePolicy": {
      "schedulePolicyType": "SimpleSchedulePolicy",
      "scheduleRunDays": null,
      "scheduleRunFrequency": "Daily",
      "scheduleRunTimes": [
        "2021-07-30T18:30:00+00:00"
      ],
      "scheduleWeeklyFrequency": 0
    },
    "timeZone": "UTC"
  },
  "resourceGroup": "RSGNAME",
  "tags": null,
  "type": "Microsoft.RecoveryServices/vaults/backupPolicies"
}

but, when I check the current backups available, only see the next 7 days.

$ az backup job list --resource-group $MYGROUP --vault-name $MYVAULT --output table

Name                                  Operation    Status     Item Name                Backup Management Type    Start Time UTC                    Duration
------------------------------------  -----------  ---------  -----------------------  ------------------------  --------------------------------  --------------
111111111111111111111111111111111111  Backup       Completed  VM000000000000000000001  AzureIaasVM               2021-08-22T18:34:17.278978+00:00  1:41:15.046246
111111111111111111111111111111111111  Backup       Completed  VM000000000000000000001  AzureIaasVM               2021-08-21T18:36:46.181912+00:00  0:51:15.567965
111111111111111111111111111111111111  Backup       Completed  VM000000000000000000001  AzureIaasVM               2021-08-20T18:33:07.149902+00:00  1:51:16.718326
111111111111111111111111111111111111  Backup       Completed  VM000000000000000000001  AzureIaasVM               2021-08-19T18:38:39.130984+00:00  1:41:15.183022
111111111111111111111111111111111111  Backup       Completed  VM000000000000000000001  AzureIaasVM               2021-08-18T18:39:26.770685+00:00  1:41:16.276962
111111111111111111111111111111111111  Backup       Completed  VM000000000000000000001  AzureIaasVM               2021-08-17T18:37:04.641265+00:00  1:41:16.294330
111111111111111111111111111111111111  Backup       Completed  VM000000000000000000001  AzureIaasVM               2021-08-16T18:37:37.795313+00:00  1:41:15.296275

What is the issue? As you can see, the policy has set in 30 days


Solution

  • As mentioned in the comments, please specify --start-date and --end-date parameters to get the list of backups between those dates.

    More information about the parameters can be found here: https://learn.microsoft.com/en-us/cli/azure/backup/job?view=azure-cli-latest#az_backup_job_list.