Site icon UnixArena

Exclude disks from Azure VM snapshot backup

How to exclude a specific set of disks from Azure native backup? I had the same question for a long time. Finally, Azure Backup now supports selective disk backup and restore. Why should I backup the disks which are not needed or not useful for any kind of recovery? System/applications might generate a lot of data but we might not need those at the point in time of recovery. When it comes to the cloud, we need to be very precious about every KB of storage that we consume. I would recommend every solution architect to ask the following questions before proposing any solutions.

Azure Backup supports backing up all the disks (OS+ data) in a VM together using a Virtual machine backup solution. This article will give the step by step procedure to exclude the disk from Azure backup. Using exclude disk functionality, you get an option to backup one/ few out of the many data disks in a VM. This provides an efficient and cost-effective solution for your backup and restores needs.

This solution is useful particularly in the following scenarios:

  1. Users who have critical data to be backed up in only one disk and don’t want a backup for the rest of the disks attached to a VM to minimize the backup storage costs.
  2. Users using other backup solutions for part of their VM/ data like they backup their databases/data using a different workload backup solution and they want to use Azure VM level backup for the rest of the data/ disks to build an efficient and a robust system utilizing the best capabilities available.

Note: At this time of writing the article, exclude disk option is in preview mode. You could able to exclude only on command line.

1. Login to azure CLI using cloud shell or use az login from any remote systems.

2. Here is my protected VM using azure native backup.

Snapshot – Application consistent Backup – Azure

3. UAvm1 has an OS disk and one data disk. Here, I will demonstrate how to exclude one of the data disks from Azure native snapshot.

Azure backup – excluded disks

Here is some quick command reference.

Enable Azure backup by excluding specific disks:

# az backup protection enable-for-vm --resource-group {resourcegroup} --vault-name {vaultname} --vm {vmname} --policy-name {policyname} --disk-list-setting include --diskslist {LUN number(s) separated by space}
# az backup protection enable-for-vm --resource-group {resourcegroup} --vault-name {vaultname} --vm {vmname} –policy-name {policyname} --disk-list-setting exclude --diskslist 0 1

If the VM is not in the same resource group as that of vault, then ResourceGroup refers to the resource group where vault was created. Instead of VM name, provide the VM ID as indicated below.

# az backup protection enable-for-vm  --resource-group {ResourceGroup} --vault-name {vaultname} --vm $(az vm show -g VMResourceGroup -n MyVm --query id | tr -d '"') --policy-name {policyname} --disk-list-setting include --diskslist {LUN number(s) separated by space}

Restore disks

# az backup restore restore-disks --resource-group {resourcegroup} --vault-name {vaultname} -c {vmname} -i {vmname} -r {restorepoint} --target-resource-group {targetresourcegroup} --storage-account {storageaccountname} --restore-to-staging-storage-account --diskslist {LUN number of the disk(s) to be restored}

Restore only OS-disks

# az backup restore restore-disks --resource-group {resourcegroup} –vault-name {vaultname} -c {vmname} -i {vmname} -r {restorepoint} } --target-resource-group {targetresourcegroup} --storage-account {storageaccountname} --restore-to-staging-storage-account --restore-only-osdisk

Get Protected Item to get disk exclusion details

# az backup item show -c {vmname} -n {vmname} --vault-name {vaultname} --resource-group {resourcegroup} --backup-management-type AzureIaasVM

Note: If data spans across disks, make sure all the dependent disks are included in the backup. If a user doesn’t backup all the dependent disks in a volume, during restore, volume comprising of some non-backed up disks will not be created.

Backups with Disk exclude setting ON only support the ‘Disk restore’ option. ‘VM restore’ or ‘replace existing’ restore options are not supported in this case.

OS disk is always restored.
Exit mobile version