为托管磁盘创建增量快照Create an incremental snapshot for managed disks

增量快照是托管磁盘的时间点备份;拍摄快照后,这些备份仅包含自上次快照以来的更改。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. 增量快照始终使用标准 HDD 存储,而不管磁盘的存储类型如何,而完整快照可使用高级 SSD。Incremental snapshots will always use standard HDDs storage, irrespective of the storage type of the disk, whereas full snapshots can use premium SSDs. 若要在高级存储上使用完整快照来纵向扩展 VM 部署,建议在共享映像库中的标准存储上使用自定义映像。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.

增量快照还提供差异功能,但仅适用于托管磁盘。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. 例如,可以将第一个增量快照下载为另一个区域中的基本 Blob。For example, you can download the first incremental snapshot as a base blob in another region. 对于后续增量快照,只需要将自上次快照以来的更改复制到基本 Blob 中。For the subsequent incremental snapshots, you can copy only the changes since the last snapshot to the base blob. 复制更改后,可以在基本 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. 可以从基本 Blob 或从其他区域中的基本 Blob 上的快照还原磁盘。You can restore your disk either from the base blob or from a snapshot on the base blob in another region.

描述跨区域复制的增量快照的图表。快照会执行各种 API 调用,直到最终形成每个快照的页 blob。

增量快照仅按已用大小计费。Incremental snapshots are billed for the used size only.

限制Restrictions

  • 增量快照当前无法在订阅之间转移。Incremental snapshots currently cannot be moved between subscriptions.
  • 当前,在任何给定时间,只能为某个特定系列的最多 5 个快照生成 SAS URI。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.
  • 每五分钟最多可为每个磁盘创建 7 个增量快照。Up to seven incremental snapshots per disk can be created every five minutes.
  • 总共可以为单个磁盘创建 200 个增量快照。A total of 200 incremental snapshots can be created for a single disk.
  • 如果父磁盘的大小调整超过 4 TB 限额,则无法获取分别在磁盘大小调整之前和之后拍摄的快照之间的差异。You cannot get the changes between snapshots taken before and after the change in the size of the parent disk across 4-TB boundary. 需要再次下载调整大小后创建的快照的完整副本。You have to again download the full copy of the snapshot created after the resize. 在那之后,可以获取大小调整超过 4 TB 后创建的快照之间的差异。Subsequently, you can get the changes between the snapshots created after the resize across 4-TB boundary.

可以使用 Azure PowerShell 创建增量快照。You can use Azure PowerShell to create an incremental snapshot. 将需要最新版本的 Azure PowerShell,以下命令将安装它或将现有安装更新到最新版本: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

安装之后,使用 Connect-AzAccount -Environment AzureChinaCloud 登录到 PowerShell 会话。Once that is installed, login to your PowerShell session with Connect-AzAccount -Environment AzureChinaCloud.

若要使用 Azure PowerShell 创建增量快照,请使用含有 -Incremental 参数的 New-AzSnapShotConfig 设置配置,然后将其作为变量通过 -Snapshot 参数传递给 New-AzSnapshotTo 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.

$diskName = "yourDiskNameHere>"
$resourceGroupName = "yourResourceGroupNameHere"
$snapshotName = "yourDesiredSnapshotNameHere"

# Get the disk that you need to backup by creating an incremental snapshot
$yourDisk = Get-AzDisk -DiskName $diskName -ResourceGroupName $resourceGroupName

# 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 $resourceGroupName -SnapshotName $snapshotName -Snapshot $snapshotConfig 

可以使用快照的 SourceResourceIdSourceUniqueId 属性标识同一磁盘中的增量快照。You can identify incremental snapshots from the same disk with the SourceResourceId and the SourceUniqueId properties of snapshots. SourceResourceId 是父磁盘的 Azure 资源管理器资源 ID。SourceResourceId is the Azure Resource Manager resource ID of the parent disk. SourceUniqueId 是从磁盘的 UniqueId 属性继承的值。SourceUniqueId is the value inherited from the UniqueId property of the disk. 如果要删除某个磁盘,然后创建具有相同名称的新磁盘,则 UniqueId 属性的值将更改。If you were to delete a disk and then create a new disk with the same name, the value of the UniqueId property changes.

可以使用 SourceResourceIdSourceUniqueId 来创建与特定磁盘关联的所有快照的列表。You can use SourceResourceId and SourceUniqueId to create a list of all snapshots associated with a particular disk. <yourResourceGroupNameHere> 替换为你的值,然后可以使用以下示例列出现有增量快照:Replace <yourResourceGroupNameHere> with your value and then you can use the following example to list your existing incremental snapshots:

$snapshots = Get-AzSnapshot -ResourceGroupName $resourceGroupName

$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

后续步骤Next steps

要查看演示使用 .NET 的增量快照的差异功能的示例代码,请参阅通过增量快照差异功能将 Azure 托管磁盘备份复制到另一区域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.