Triage and Remediation
Remediation
Using Console
Using Console
To remediate the misconfiguration of virtual machines not having backups in AZURE using the AZURE console, follow these steps:
- Log in to the AZURE portal.
- In the left-hand menu, click on “Virtual machines”.
- Select the virtual machine that needs to be backed up.
- In the virtual machine overview page, click on “Backup” under “Operations”.
- In the “Backup” page, click on “Configure Backup”.
- In the “Backup policy” page, click on “Create a new policy”.
- In the “New policy” page, select the backup frequency, retention range, and other backup settings.
- Click on “OK” to create the backup policy.
- In the “Backup” page, click on “Enable Backup” to enable backup for the virtual machine.
- Review the backup policy and click on “OK”.
Using CLI
Using CLI
To remediate the misconfiguration “Virtual Machines Should Have Backups” for Azure using Azure CLI, follow the below steps:
- Open the Azure CLI in your terminal or command prompt.
-
Login to your Azure account using the command below:
-
Once you are logged in, select the Azure subscription in which the virtual machines are present using the command below:
Replace
<subscription_id>
with the ID of your Azure subscription. -
To enable backups for a virtual machine, use the following command:
Replace
<resource_group_name>
with the name of the resource group in which the virtual machine is present,<vault_name>
with the name of the backup vault in which the backups will be stored, and<vm_name>
with the name of the virtual machine for which you want to enable backups. -
Once the backups are enabled, you can configure the backup policy for the virtual machine using the following command:
Replace
<policy_name>
with the name of the backup policy that you want to apply,<resource_group_name>
with the name of the resource group in which the virtual machine is present,<vault_name>
with the name of the backup vault in which the backups will be stored, and<vm_name>
with the name of the virtual machine for which you want to configure the backup policy. -
After the backup policy is set, you can trigger the backup of the virtual machine using the following command:
Replace
<resource_group_name>
with the name of the resource group in which the virtual machine is present,<vault_name>
with the name of the backup vault in which the backups will be stored,<policy_name>
with the name of the backup policy that you have configured, and<vm_name>
with the name of the virtual machine for which you want to trigger the backup. -
Once the backup is completed, you can verify the backup status of the virtual machine using the following command:
Replace
<resource_group_name>
with the name of the resource group in which the virtual machine is present, and<vault_name>
with the name of the backup vault in which the backups are stored.
Using Python
Using Python
To remediate the misconfiguration of virtual machines not having backups in Azure using Python, follow these steps:
- Import the necessary modules:
- Authenticate to Azure using Service Principal credentials:
- Create a Compute Management Client and a Recovery Services Backup Client:
- Get the list of virtual machines in the Azure subscription:
- For each virtual machine, check if it has a backup policy assigned. If not, create a backup policy and associate it with the virtual machine:
- Once the backup policy is assigned to the virtual machine, it will start taking backups automatically based on the schedule specified in the policy.