You have the ability to create snapshots for your cloud disk, thereby preserving data at a specific moment in time. Tencent Cloud employs an incremental approach to snapshot creation, meaning that only new data changes compared to the last snapshot are created. As such, in situations where data changes are minimal, snapshot creation can be completed in a relatively short time. Despite snapshots being created incrementally, deleting a snapshot will not affect your use of any snapshot data, and any undeleted snapshots can restore the cloud disk to the state of that snapshot.
You can create a snapshot under any state of the cloud disk, but the snapshot can only preserve data that has been written at the current time point. If an application or process is writing data, this portion of data may not be saved to the snapshot created at that time point. Depending on your actual business situation, you can choose to temporarily stop all writing and promptly create a snapshot, or first dismount the cloud disk from the cloud server, create a snapshot, and then remount it, in order to obtain a snapshot with complete data.
The number and total capacity of your snapshots within the current region have not reached the maximum. For detailed information, please refer to Snapshot Usage Limits.
Snapshots only retain data that has been written to the disk at that moment, and do not preserve data in memory that has not been written to the disk at that time (for example, files under the /run directory in the Linux system). It is strongly recommended that you shut down or ensure that memory data has been written to the disk and disk read/write operations are paused before creating a snapshot. Actions should be taken from the following two aspects.
Database level
For database-type businesses, it is recommended to first lock all tables in the database in a read-only state to prevent new data from being written during snapshot creation, which could result in the new data not being captured by the snapshot. This article uses the MySQL database as an example, performing the following operations:
1. Execute the FLUSH TABLES WITH READ LOCK command to close all open tables and lock all tables in all databases with a global read lock, as shown in the figure below:
2. Create a snapshot for the cloud disk.
3. Execute the UNLOCK TABLES command to remove the lock. As shown in the figure below:
System level
From a system perspective, data is typically first stored in the memory buffer during processing, and then written to the cloud disk at the appropriate time to enhance system performance. Therefore, when creating a snapshot, data in the buffer that has not yet been written to the cloud disk cannot be written into the snapshot or recovered from the snapshot, which can affect data consistency.
You can execute the sync command to force immediate writing of data from the file system memory buffer to the cloud disk, and avoid writing new data before creating a snapshot. If no error message is returned after executing the command, it means that the data in the cache has been written to the cloud disk. As shown in the figure below: