Snapshots are point-in-time backups of cloud disks. You can use a snapshot of a cloud disk to restore disk data to the point in time when the snapshot was created. This topic describes how to create and delete snapshots and calculate the snapshot size. This topic also describes the relationship between the snapshot size and the disk size.
Create snapshots
You can manually or automatically create standard snapshots for cloud disks based on your business requirements. For more information, see Create a snapshot or Create an automatic snapshot policy.
Description
Snapshots use data blocks as the minimum granularity for data backup. Snapshots are classified into full snapshots and incremental snapshots. The first standard snapshot that you create for a cloud disk is a full snapshot, which includes all data stored on the cloud disk when the snapshot is created. Subsequent standard snapshots of the same cloud disk are incremental snapshots. These snapshots include only the data blocks added or changed on the cloud disk since the previous snapshot was created. This minimizes the storage space required to store snapshots and reduces storage costs. The full snapshot and incremental snapshots include information about all data blocks on the cloud disk. When you roll back the cloud disk by using a snapshot, you can restore cloud disk data to the point in time when the snapshot was created.
To ensure long-term and secure storage and flexible restoration of data, snapshots are automatically stored in Alibaba Cloud Object Storage Service (OSS). For information about the storage locations of snapshots, see the Storage locations section of the "Overview" topic.
Example
In this example, data is written to a cloud disk on an Elastic Compute Service (ECS) instance at 10:00:00 and 11:00:00. The following section describes how snapshots are created for the disk:
At 9:00:00, the disk contains data blocks A, B, and C, and the first snapshot (Snapshot 1) is created for the disk. Data blocks A, B, and C are backed up in Snapshot 1. Snapshot 1 is a full snapshot that stores all data on the disk.
Data continues to be written to the disk. Data block A is changed to A1, data block B is changed to B1, and data block D is added. The second snapshot (Snapshot 2) for the disk is created at 10:00:00. Snapshot 2 is an incremental snapshot that backs up only the changed data blocks A1, B1, and D. Snapshot 2 contains information about all data blocks (A1, B1, C, and D) of the disk. Data block C is derived from Snapshot 1.
Data continues to be written to the disk. Data block C is changed to C1 and data block E is added. The third snapshot (Snapshot 3) is created at 11:00:00. Snapshot 3 is an incremental snapshot that backs up only the changed data blocks C1 and E. Snapshot 3 contains information about all data blocks A1, B1, C1, D, and E of the disk. Data blocks A1, B1, and D are derived from Snapshot 2.
The preceding processes are repeated.
Delete snapshots
If you want to free up storage space or the maximum number of snapshots is reached, you can delete snapshots that are no longer needed. For information about how to delete a snapshot, see Delete a snapshot.
For information about the limits on manual and automatic snapshots for each cloud disk, see the Limits section of the "Overview" topic.
Description
Full and incremental snapshots include information about all data blocks on the cloud disk. Even if you delete any snapshot of the cloud disk, you can use an existing snapshot to roll back the cloud disk to the point in time when the existing snapshot was created. When you delete a full snapshot, the full snapshot attribute is automatically set for the next adjacent incremental snapshot.
Example
For example, Snapshot 1, Snapshot 2, and Snapshot 3 are created for a cloud disk attached to an ECS instance. The following section describes the data blocks contained in each snapshot:
Snapshot 1: a full snapshot that contains data blocks A, B, and C.
Snapshot 2: an incremental snapshot that contains data blocks A1 (changed from data block A), B1 (changed from data block B), C (unchanged), and D (new data block). Data block C is derived from Snapshot 1.
Snapshot 3: an incremental snapshot that contains data block A1 (unchanged), B1 (unchanged), C1 (changed from data block C), D (unchanged), and E (new data block). Data blocks A1, B1, and D are derived from Snapshot 2.
The following section describes how the snapshots are deleted:
When you delete Snapshot 1 (full snapshot), Snapshot 2 becomes a full snapshot and contains data blocks A1, B1, C, and D. Snapshot 3 remains as an incremental snapshot.
When you delete Snapshot 2 (full snapshot), Snapshot 3 becomes a full snapshot. Snapshot 3 contains data blocks A1, B1, C1, D, and E.
When you delete Snapshot 3 (full snapshot), all data blocks in the snapshot are deleted.
Calculate the snapshot size
Description
The total snapshot size of a cloud disk is calculated at the granularity of snapshot chains. A snapshot chain is a chain of all snapshots created for a cloud disk. The size of a snapshot chain is an equivalence of the amount of storage space occupied by the data blocks of all snapshots of the disk. The system calculates standard snapshot storage fees based on the size of the snapshot chain. For more information, see the View the snapshot size of a cloud disk based on the snapshot chain of the disk section of the "View the snapshot size" topic and Snapshots.
The calculation of the size of a snapshot chain has single-digit-minute latency. The displayed snapshot chain size is only for reference. You are charged based on the actual storage space that is occupied by the snapshot chain. You can view the actual fees in your bills.
The following section describes the concepts involved in snapshot size:
Full snapshot size: the amount of the storage space occupied by all data blocks in a single snapshot.
Incremental snapshot size: the amount of storage space occupied by the data blocks in a snapshot that have changed since the previous snapshot in the same snapshot chain.
Total snapshot size: the sum of the size of the first snapshot (full snapshot) and the size of all subsequent incremental snapshots.
Example of calculating the snapshot size
A cloud disk has three standard snapshots. The three standard snapshots form a standard snapshot chain of the disk.
Snapshot 1: a full snapshot that backs up full data blocks A, B, and C. The full snapshot size is 30 GB.
Snapshot 2: an incremental snapshot that backs up only data blocks A1, B1, and D that have changed since Snapshot 1. The incremental snapshot size is 30 GB.
Snapshot 3: an incremental snapshot that backs up only data blocks C1 and E that have changed since Snapshot 2. The incremental snapshot size is 20 GB.
Total capacity of standard snapshots = Full standard snapshot 1 + Incremental standard snapshot 2 + Incremental standard snapshot 3 = 80 GB
Relationship between the snapshot size and cloud disk size
The size of a single snapshot of a cloud disk cannot exceed the disk size. As the number of snapshots increases, the disk size may be smaller than the total size of all snapshots.
For example, you create a 40-GB cloud disk, write 20 GB of data to the disk, and then create a snapshot for the disk. The size of the snapshot is 20 GB. You continue to write 10 GB of data to the disk and then create another snapshot for the disk. The disk size is still 40 GB and the total size of created snapshots is 30 GB. This process is repeated.
You can view the size of all snapshots of a cloud disk and the disk size based on the snapshot chain of the disk. For more information, see the View the snapshot size of a cloud disk based on the snapshot chain of the disk section in the "View the snapshot size" topic. As shown in the following figure, ① shows the disk size and ② shows the size of all snapshots created for the cloud disk.
Difference between the snapshot size and the system value
The snapshot size is calculated by using fixed-sized data blocks as the minimum granularity for data backup in snapshots.
When you delete a file from a cloud disk, the used disk capacity that is displayed in the operating system decreases. When you delete a file from the file systems of the operating system, the file is labeled as Deleted, but the data of the file is not physically deleted. File deletion on cloud disks is a write operation, which does not reduce the actual amount of disk space occupied by data. If a snapshot is created before a file is deleted, the snapshot still contains the data blocks that correspond to the deleted file after the file is deleted. If files are physically deleted from the file systems of the operating system, snapshots do not contain the data blocks of the deleted files. For more information, view the documentation of the TRIM mechanism of file systems.
Even if you do not write data to a system disk, the snapshot size may still increase. When an operating system is running, system files are generated and written to the system disk and backed up in snapshots.
The size of a snapshot may be slightly larger than the size of data that is written to the source disk of the snapshot. This is because some metadata of file systems occupies disk space. The data blocks of the snapshot contain metadata and the data written by you. For example, if you create only 1 MB of text files on a cloud disk, the size of the data backed up by snapshots is slightly larger than the size of the text files due to the presence of file system metadata. The snapshot size is greater than 1 MB.