How snapshots work

更新时间:
复制 MD 格式

Snapshots capture point-in-time disk data for backup and recovery, using incremental storage to reduce costs.

How snapshot creation works

Create a snapshot manually or configure an automatic snapshot policy.

How it works

Snapshots use blocks as the minimum granularity for data backup. The first standard snapshot of a disk is a full snapshot that backs up all data blocks. Subsequent standard snapshots are incremental — they back up only new or modified blocks since the previous snapshot. Incremental snapshots reference unchanged data from earlier snapshots in the snapshot chain, so any snapshot can restore the full disk state.

Snapshots are stored in Object Storage Service (OSS) by default. The OSS bucket used for snapshots is not visible to users, and you cannot use your own OSS buckets to store snapshot data.

Example

Assume that an ECS instance has a disk where data is modified at 10:00 and 11:00:

  1. At 9:00, the disk contains data blocks A and B. Snapshot 1 (full) backs up both blocks.

  2. Block B is modified to B1. At 10:00, Snapshot 2 (incremental) backs up only block B1. Block A is referenced from Snapshot 1.

  3. A new block C is added. At 11:00, Snapshot 3 (incremental) backs up only block C. Blocks A and B1 are referenced from Snapshots 1 and 2.

  4. This process continues for subsequent snapshots.

image

How archiving snapshots works

How it works

Archive standard snapshots that you rarely access but must retain long-term to reduce storage costs. The first archived snapshot of a disk is a full snapshot. Subsequent archived snapshots are incremental, backing up only changed blocks since the previous archived snapshot. See Archive snapshots.

Examples

Example 1: Archiving the only snapshot of a disk

Assume that a disk has one standard snapshot. Archiving it produces an archived snapshot of the same size. The standard snapshot size becomes zero.

image

Example 2: Archiving an incremental snapshot of a disk

Assume that a disk has three standard snapshots. You archive Snapshot 2 and Snapshot 3.

  1. Archiving standard Snapshot 2 converts it into a full archived snapshot containing blocks A and B1. Because standard Snapshot 3 referenced block B1 from Snapshot 2, block B1 is retained and reassociated with Snapshot 3.

  2. Archiving standard Snapshot 3 creates an incremental archived snapshot containing only block C. Blocks A and B1 are referenced from archived Snapshot 2.

  3. This process continues for subsequent snapshots.

After archiving, the disk has two snapshot chains: one standard chain (one snapshot) and one archived chain (two snapshots).

image

How snapshot deletion works

Delete snapshots you no longer need or when the snapshot quota is exceeded to free storage space. See Delete snapshot.

Note

For snapshot quotas per disk (manual, automatic, and archived), see Limits.

How it works

Incremental snapshots reference unchanged data from earlier snapshots in the chain. Deleting a snapshot does not affect your ability to restore the disk from any remaining snapshot.

Examples

Assume that a disk has three snapshots with the following data blocks:

  • Snapshot 1 (full): Contains data blocks A and B.

  • Snapshot 2 (incremental): Contains only block B1. Block A is referenced from Snapshot 1.

  • Snapshot 3 (incremental): Contains only block C. Block A is referenced from Snapshot 1, and block B1 from Snapshot 2.

Example 1: Deleting a full snapshot of a disk

Deleting full Snapshot 1 promotes Snapshot 2 to a full snapshot. Block A, referenced by Snapshot 2 from Snapshot 1, is retained and merged into Snapshot 2. Block B, unique to Snapshot 1, is deleted. Snapshot 3's reference for block A shifts to Snapshot 2; its reference for block B1 remains unchanged.

image

Example 2: Deleting an incremental snapshot of a disk

Deleting incremental Snapshot 2 removes its reference to block A (from Snapshot 1) and merges block B1 into Snapshot 3.

image

How snapshot size is calculated

How it works

The total snapshot size of a disk is the sum of storage occupied by all data blocks in its snapshot chain. After archiving, a disk has two chains — standard and archived — billed separately. See View the snapshot size of a disk and Snapshot billing.

Note

Snapshot size calculations may have a latency of several minutes. For actual charges, refer to your bill.

Key concepts:

  • Full size: The total storage occupied by all data blocks of a single snapshot.

  • Incremental size: The storage occupied by data blocks that differ between the current snapshot and the previous one in the same chain.

  • Total snapshot size: The full size of the first snapshot plus the incremental sizes of all subsequent snapshots in the chain.

Example of snapshot size calculation

  1. Assume that a disk has a capacity of 100 GiB with 30 GiB of data. Data is modified at 10:00 and 11:00:

    • Standard Snapshot 1: At 9:00, the disk contains 30 GiB. Snapshot 1 (full) backs up all data. Full size: 30 GiB.

    • Standard Snapshot 2: 10 GiB of data is overwritten. At 10:00, Snapshot 2 (incremental) backs up only the 10 GiB of changed data. The remaining 20 GiB is referenced from Snapshot 1.

    • Standard Snapshot 3: 10 GiB of new data is written, bringing total disk data to 40 GiB. At 11:00, Snapshot 3 (incremental) backs up only the 10 GiB of changed data. Of the 30 GiB unchanged, 20 GiB is referenced from Snapshot 1 and 10 GiB from Snapshot 2.

    Before archiving, total standard snapshot size = 30 + 10 + 10 = 50 GiB.

  2. Archive Snapshot 2 and Snapshot 3 to form the archived snapshot chain:

    • Archived Snapshot 2 (full): Backs up all data. Full size: 30 GiB.

    • Archived Snapshot 3 (incremental): Backs up only the 10 GiB of changed data. The 30 GiB unchanged is referenced from Archived Snapshot 2.

    After archiving, the disk has two snapshot chains:

    • Total archived snapshot size = Full Archived Snapshot 2 + Incremental Archived Snapshot 3 = 40 GiB

    • Total standard snapshot size = Full Standard Snapshot 1 = 30 GiB

    Total snapshot size after archiving increases by 20 GiB. Archiving only some snapshots may not reduce costs. For a cost comparison, see Optimize snapshot costs.

image

Relationship between snapshot size and disk capacity

A single snapshot does not exceed the disk's capacity, but the total size of all snapshots can exceed it as more snapshots are created.

For example, create a 40 GiB disk and write 30 GiB of data (snapshot = 30 GiB). Then overwrite 30 GiB and create a second snapshot. The disk capacity is still 40 GiB, but the total snapshot size is now 60 GiB.

View the snapshot size of a disk to check disk capacity and snapshot size. In the following figure, ① indicates disk capacity, and ② indicates total snapshot size.

image

Differences between snapshot size and system capacity

  • Snapshots use fixed-size data blocks as the minimum backup granularity. Snapshot size is calculated based on these blocks.

  • Deleting a file on a disk increases the available capacity shown by the operating system but does not physically erase the data. Most file systems only mark the file as deleted. A snapshot created at this point still contains the deleted file's data blocks. The data is removed only when the file system physically deletes the file, for example, using the TRIM command.

  • A system disk's snapshot size may increase even without active writes, because the operating system generates system files at runtime that are backed up in snapshots.

  • A snapshot may be slightly larger than the data written to disk because file system metadata is also included. For example, a 1 MB text file occupies slightly more than 1 MB in a snapshot due to metadata.