Using Console
Using CLI
az login
.
az vm list --query "[].{name:name, resourceGroup:resourceGroup, backup:provisioningState}"
to list all the virtual machines and their backup status.
az backup protection enable-for-vm --resource-group <resource-group-name> --vault-name <vault-name> --vm <vm-name> --policy-name <policy-name>
to enable backup protection for the virtual machine.
<resource-group-name>
, <vault-name>
, <vm-name>
, and <policy-name>
with the appropriate values.az backup policy list --vault-name <vault-name> --query "[].{name:name, backupSchedule:backupSchedule}"
to list all the backup policies and their backup schedules.
az backup protection backup-now --resource-group <resource-group-name> --vault-name <vault-name> --container-name <container-name> --item-name <item-name> --retain-until <date-time>
to initiate a backup for the virtual machine.
<resource-group-name>
, <vault-name>
, <container-name>
, <item-name>
, and <date-time>
with the appropriate values.az backup job list --vault-name <vault-name> --query "[].{name:name, status:status}"
.
az backup policy set --vault-name <vault-name> --name <policy-name> --backup-schedule '{"scheduleFrequencyInMins":1440,"retentionPolicy":{"dailySchedule":{"retentionDuration":{"count":<count>,"durationType":"Days"}}}}'
to set the backup policy with the required daily backup retention period.
<vault-name>
, <policy-name>
, and <count>
with the appropriate values.By following these steps, you can remediate the misconfiguration “Virtual Machines Should Have Sufficient Daily Backup Retention Period” for AZURE using AZURE CLI.Using Python
your_subscription_id
, your_client_id
, your_secret
, your_tenant
, and your_vault_name
with your Azure subscription details. Also, make sure to provide the appropriate permissions to the Service Principal used for authentication.