We are excited to announce that you can now use Azure CLI to easily manage your Windows and Linux Azure VM backups using Azure Backup. With Azure Backup, you can backup Azure Windows and Linux VMs, VMs running on Premium storage, and on Managed Disks as well with application-consistency. Now with CLI support, take advantage of CLI features such as smart defaults for most common operations, tab completion and pipe-able outputs to simply and quickly manage your VM backup and recovery operations. Azure Backup is supported with Azure CLI 2.0 only and is currently in preview.
How CLI will help
- Cross-platform support: With Azure CLI, start managing your Azure VM backups from anywhere, irrespective of the platform you use.
- Managing at scale: Easily handle operations at scale by including CLI commands in scripts and programs.
- Automation: In conjunction with the command line tools, query on command outputs to identify important triggers and program subsequent actions. For example, backup health information can be programmatically retrieved, and subsequent operations can be initiated based on the health status.
Enabling Backup on a VM:
To protect a previously unprotected VMto a Recovery Services vault (within the same location and Resource group) with a default policy, use this command:
az backup protection enable-for-vm \ --resource-group myResourceGroup \ --vault-name myRecoveryServicesVault \ --vm myVM \ --policy-name DefaultPolicy
For more information, refer to this quick start article to start backing up your VMs.
You can restore files from VM backups without setting up any additional infrastructure and with a single command.
Use az backup recoverypoint list command to get recovery point name and then
az backup restore files mount-rp \ --resource-group myResourceGroup \ --vault-name myRecoveryServicesVault \ --container-name myVM \ --item-name myVM \ --rp-name myRecoveryPointName
This will download a script to mount the recovery point. Run the script on the machine where you want to copy the files.
You can also restore disks from your VM backups and create your VMs from restored disks.
View your backup items’ health status using az backup item list command.
Azure Backup looks out for any configuration issues that might adversely impact VM backups and provides corresponding corrective measures. This is known as Backup pre-check. In CLI, this information is provided via “healthStatus” and “healthDetails” in az backup item list command’s JSON output. For example, in the image below, the health details section points out that the next backup might not be successful since the agent on the Linux machine is not up to date and it is recommended to have the agent upgraded.
You can use “--query” option along with az backup item list to extract health status and health details, and perform the recommended action, as suggested in the health details section, to ensure continuity of backups.
az backup item list \ --resource-group myResourceGroup \ --vault-name myRecoveryServicesVault \ --container-name myVM \ --query “.properties.healthDetails \
Install or upgrade to Azure CLI 2.0 to start using backup CLI commands.
Just type “az backup -h” to get more information related to backup CLI commands and start to manage your Azure VM backups
Related links and additional content
- Azure backup CLI commands reference documentation.
- New to Azure Backup? Sign up for a free Azure trial subscription.
- Need help? Reach out to Azure Backup forum for support.
- Tell us how we can improve Azure Backup by contributing new ideas and voting up existing ones.
- Follow us on Twitter @AzureBackup for latest news and updates.