• 2 min read

Manage your Azure VM backups with Azure CLI 2.0 – Preview

We are excited to announce that you can now use Azure CLI 2.0 to easily manage your Windows and Linux Azure VM backups. Take advantage of CLI 2.0 features such as smart defaults for the most common operations, tab completion and pipe-able outputs to simply and quickly manage your VM backup and recovery operations.

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.

Sample Scenarios:

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.

Restore:

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.

Management:

View your backup items’ health status using az backup item list command.

Now, just type the az backup item list command with the output in the table format (-o table) and view the backup status, health status and recommended actions to take, in case of backup failures, for all items within the vault.

image

The JSON output (-o json) gives more comprehensive information about the backup item and you can extract relevant details using command line tools.

Getting Started

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