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.
- Do we really need dedicated storage disk to store the data or can you leverage temporary disk which Azure offers?
- If you are using dedicated disks, Do we really need those data in the future?
- What am I going to backup and how it’s going to be useful?
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:
- 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.
- 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.
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.
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.
Jam says
Microsoft article definitely not clear. Logged ticket with Microsoft and they cant get it working.
In summary my 30 + years with Microsoft has been very painful. This is one example
Why don’t people provide examples??
James says
The Microsoft article was not clear which is why I came here. If I currently backup a machine and all data disks I can simply run the script below to exclude right? Is this it?
# az backup protection enable-for-vm –resource-group {resourcegroup} –vault-name {vaultname} –vm {vmname} –policy-name {policyname} –disk-list-setting exclude –diskslist 0 1
Your article sound similar to my situation but then you have every script, include, exclude, restore etc. I can use the Azure portal to restore in the same way right?
Should really be in the Azure portal but that’s Miucrosoft. They still havent fixed the restore earlier than 30 days and need to really move faster