Creating an incremental snapshot (preview) for managed disks

Incremental snapshots (preview) are point in time backups for managed disks that, when taken, consist only of all the changes since the last snapshot. When you attempt to download or otherwise use an incremental snapshot, the full VHD is used. This new capability for managed disk snapshots can potentially allow them to be more cost effective, since you are no longer required to store the entire disk with each individual snapshot, unless you choose to. Just like regular snapshots, incremental snapshots can be used to create a full managed disk or, to make a regular snapshot.

There are a few differences between an incremental snapshot and a regular snapshot. Incremental snapshots will always use standard HDDs storage, irrespective of the storage type of the disk, whereas regular snapshots can use premium SSDs. If you are using regular 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 to 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, which is uniquely 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.

If you haven't yet signed up for the preview and you'd like to start using incremental snapshots, email us at AzureDisks@microsoft.com to get access to the public preview.

Restrictions

  • Incremental snapshots are currently only available in East US, Central US, Canada Central, West Central US and North Europe.
  • Incremental snapshots currently cannot be created after you've changed the size of a disk.
  • 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.

PowerShell

You can use Azure PowerShell to create an incremental snapshot. You will need the latest version of Azure PowerShell, the following command will either install it or update your existing installation to latest:

Install-Module -Name Az -AllowClobber -Scope CurrentUser

Once that is installed, login to your PowerShell session with az login.

To create an incremental snapshot with Azure PowerShell, set the configuration with New-AzSnapShotConfig with the -Incremental parameter and then pass that as a variable to New-AzSnapshot through the -Snapshot parameter.

Replace <yourDiskNameHere>, <yourResourceGroupNameHere>, and <yourDesiredSnapShotNameHere> with your values, then you can use the following script to create an incremental snapshot:

# Get the disk that you need to backup by creating an incremental snapshot
$yourDisk = Get-AzDisk -DiskName <yourDiskNameHere> -ResourceGroupName <yourResourceGroupNameHere>

# Create an incremental snapshot by setting the SourceUri property with the value of the Id property of the disk
$snapshotConfig=New-AzSnapshotConfig -SourceUri $yourDisk.Id -Location $yourDisk.Location -CreateOption Copy -Incremental 
New-AzSnapshot -ResourceGroupName <yourResourceGroupNameHere> -SnapshotName <yourDesiredSnapshotNameHere> -Snapshot $snapshotConfig 

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. Replace <yourResourceGroupNameHere> with your value and then you can use the following example to list your existing incremental snapshots:

$snapshots = Get-AzSnapshot -ResourceGroupName <yourResourceGroupNameHere>

$incrementalSnapshots = New-Object System.Collections.ArrayList
foreach ($snapshot in $snapshots)
{
    
    if($snapshot.Incremental -and $snapshot.CreationData.SourceResourceId -eq $yourDisk.Id -and $snapshot.CreationData.SourceUniqueId -eq $yourDisk.UniqueId){

        $incrementalSnapshots.Add($snapshot)
    }
}

$incrementalSnapshots

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

  1. If you haven't yet signed up for the preview and you'd like to start using incremental snapshots, email us at AzureDisks@microsoft.com to get access to the public preview.

  2. Explore the following samples for cross-region copy of incremental snapshots using differential capability