Create an incremental snapshot for managed disks - CLI

Incremental snapshots are point in time backups for managed disks that, when taken, consist only of the changes since the last snapshot. When you restore a disk from an incremental snapshot, the system reconstruct the full disk which represents the point in time backup of the disk when the incremental snapshot was taken. This new capability for managed disk snapshots potentially allows them to be more cost effective, since, unless you choose to, you do not have to store the entire disk with each individual snapshot. Just like full snapshots, incremental snapshots can be used to either create a full managed disk or a full snapshot.

There are a few differences between an incremental snapshot and a full snapshot. Incremental snapshots will always use standard HDDs storage, irrespective of the storage type of the disk, whereas full snapshots can use premium SSDs. If you are using full snapshots on Premium Storage to scale up VM deployments, we recommend you use custom images on standard storage in the Shared Image Gallery. It will help you achieve a more massive scale with lower cost. Additionally, incremental snapshots potentially offer better reliability with zone-redundant storage (ZRS). If ZRS is available in the selected region, an incremental snapshot will use ZRS automatically. If ZRS is not available in the region, then the snapshot will default to locally-redundant storage (LRS). You can override this behavior and select one manually but, we do not recommend that.

Incremental snapshots also offer a differential capability, only available to managed disks. They enable you to get the changes between two incremental snapshots of the same managed disks, down to the block level. You can use this capability to reduce your data footprint when copying snapshots across regions. For example, you can download the first incremental snapshot as a base blob in another region. For the subsequent incremental snapshots, you can copy only the changes since the last snapshot to the base blob. After copying the changes, you can take snapshots on the base blob that represent your point in time backup of the disk in another region. You can restore your disk either from the base blob or from a snapshot on the base blob in another region.

Diagram depicting incremental snapshots copied across regions. Snapshots make various API calls until eventually forming page blobs per each snapshot.

Incremental snapshots are billed for the used size only. You can find the used size of your snapshots by looking at the Azure usage report. For example, if the used data size of a snapshot is 10 GiB, the daily usage report will show 10 GiB/(31 days) = 0.3226 as the consumed quantity.

Restrictions

  • Incremental snapshots currently cannot be moved between subscriptions.
  • You can currently only generate SAS URIs of up to five snapshots of a particular snapshot family at any given time.
  • You cannot create an incremental snapshot for a particular disk outside of that disk's subscription.
  • Up to seven incremental snapshots per disk can be created every five minutes.
  • A total of 200 incremental snapshots can be created for a single disk.
  • You cannot get the changes between snapshots taken before and after you changed the size of the parent disk across 4 TB boundary. For example, You took an incremental snapshot snapshot-a when the size of a disk was 2 TB. Now you increased the size of the disk to 6 TB and then took another incremental snapshot snapshot-b. You cannot get the changes between snapshot-a and snapshot-b. You have to again download the full copy of snapshot-b created after the resize. Subsequently, you can get the changes between snapshot-b and snapshots created after snapshot-b.

CLI

You can create an incremental snapshot with the Azure CLI, you will need the latest version of Azure CLI.

On Windows, the following command will either install or update your existing installation to the latest version:

Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'

On Linux, the CLI installation will vary depending on operating system version. See Install the Azure CLI for your particular Linux version.

To create an incremental snapshot, use az snapshot create with the --incremental parameter.

The following example creates an incremental snapshot, replace <yourDesiredSnapShotNameHere>, <yourResourceGroupNameHere>,<exampleDiskName>, and <exampleLocation> with your own values, then run the example:

sourceResourceId=$(az disk show -g <yourResourceGroupNameHere> -n <exampleDiskName> --query '[id]' -o tsv)

az snapshot create -g <yourResourceGroupNameHere> \
-n <yourDesiredSnapShotNameHere> \
-l <exampleLocation> \
--source "$sourceResourceId" \
--incremental

You can identify incremental snapshots from the same disk with the SourceResourceId and the SourceUniqueId properties of snapshots. SourceResourceId is the Azure Resource Manager resource ID of the parent disk. SourceUniqueId is the value inherited from the UniqueId property of the disk. If you were to delete a disk and then create a new disk with the same name, the value of the UniqueId property changes.

You can use SourceResourceId and SourceUniqueId to create a list of all snapshots associated with a particular disk. The following example will list all incremental snapshots associated with a particular disk but, it requires some setup.

This example uses jq for querying the data. To run the example, you must install jq.

Replace <yourResourceGroupNameHere> and <exampleDiskName> with your values, then you can use the following example to list your existing incremental snapshots, as long as you've also installed jq:

sourceUniqueId=$(az disk show -g <yourResourceGroupNameHere> -n <exampleDiskName> --query '[uniqueId]' -o tsv)

 
sourceResourceId=$(az disk show -g <yourResourceGroupNameHere> -n <exampleDiskName> --query '[id]' -o tsv)

az snapshot list -g <yourResourceGroupNameHere> -o json \
| jq -cr --arg SUID "$sourceUniqueId" --arg SRID "$sourceResourceId" '.[] | select(.incremental==true and .creationData.sourceUniqueId==$SUID and .creationData.sourceResourceId==$SRID)'

Resource Manager template

You can also use Azure Resource Manager templates to create an incremental snapshot. You'll need to make sure the apiVersion is set to 2019-03-01 and that the incremental property is also set to true. The following snippet is an example of how to create an incremental snapshot with Resource Manager templates:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "diskName": {
      "type": "string",
      "defaultValue": "contosodisk1"
    },
  "diskResourceId": {
    "defaultValue": "<your_managed_disk_resource_ID>",
    "type": "String"
  }
  }, 
  "resources": [
  {
    "type": "Microsoft.Compute/snapshots",
    "name": "[concat( parameters('diskName'),'_snapshot1')]",
    "location": "[resourceGroup().location]",
    "apiVersion": "2019-03-01",
    "properties": {
      "creationData": {
        "createOption": "Copy",
        "sourceResourceId": "[parameters('diskResourceId')]"
      },
      "incremental": true
    }
  }
  ]
}

Next steps

If you'd like to see sample code demonstrating the differential capability of incremental snapshots, using .NET, see Copy Azure Managed Disks backups to another region with differential capability of incremental snapshots.