If data loss occurs on a disk due to reasons such as accidental operations and ransom viruses, you can use a snapshot of the disk to roll back the disk. This way, the disk reverts to the state it was in when the snapshot was created. This topic describes how to roll back a disk by using a snapshot.
Limits
You cannot use a snapshot of one disk to roll back another disk.
NoteIf you want to roll back a snapshot to another disk, you can create a new disk from the snapshot. For more information, see Create a disk from a snapshot.
After you replace the operating system of an Elastic Compute Service (ECS) instance, you cannot use snapshots of the original system disk to roll back the new system disk.
NoteYou can use the snapshots to create pay-as-you-go disks and then attach the disks to ECS instances for data restoration. After data is restored, we recommend that you release the disks as soon as possible. For more information, see Create a disk from a snapshot, Attach a data disk, and Release a disk.
Prerequisites
Ensure the following conditions are met before rolling back a disk using a snapshot:
Make sure that a snapshot of the disk exists and can be used to roll back the disk and that no snapshot is being created for the disk. For more information, see Create a snapshot.
WarningThe rollback operation is irreversible. After you roll back a disk, data that you added, removed, or modified from the point in time when the snapshot is created to the time when the disk is rolled back is lost. To prevent data loss that is caused by modifications, we recommend that you create a snapshot for the disk to back up data before you roll back the disk.
The disk must not be released.
If the disk is attached to an ECS instance, stop the ECS instance before you roll back the disk.
If you roll back a disk that is used to create a dynamic extended volume or RAID, you must first stop the services or applications that use the disk to ensure that no read or write operations are being performed on the disk when you roll back the disk.
Procedure
You can roll back a disk on the Snapshots or Instance page. This section describes how to roll back a disk on the Snapshots page.
Log on to the ECS console.
In the left-side navigation pane, choose .
In the top navigation bar, select the region and resource group to which the resource belongs.
On the Disk Snapshots tab, find the snapshot that you want to use. In the Actions column, click Roll Back Disk.
In the message that appears, click OK.
(Optional) Synchronize data after a disk is rolled back.
What to do next
After you roll back a disk by using a snapshot, data that you added, removed, or modified from the time when the snapshot was created to the time when the disk is rolled back is lost. The lost data involves the host configuration file and configurations such as the hostname, SSH settings, passwords, network settings, system software repository settings, and clock source. The host configuration file and configurations are restored to the states they were in when the snapshot was created. You must reconfigure the lost data based on your business requirements.
If you resized a data disk after you created a snapshot for the disk and use the snapshot to roll back the disk, the disk reverts to its original size when the snapshot was created. The additional disk space is lost. To restore the disk to the new size, you must log on to the ECS instance to which the disk is attached and resize the disk again.
Linux instance: Extend the partitions and file systems of disks on a Linux instance
Windows instance: Extend the partitions and file systems of disks on Windows instances
Rolling back the system disk of an ECS instance does not affect the current SSH key pair, username or password. You can continue to use them to log on to the ECS instance after the rollback.
FAQ
How do I restore a specific folder or file on the D drive of a Windows instance by using a snapshot?
To restore a specific folder or file, you cannot directly roll back by using a snapshot. Instead, perform the following steps:
Create a temporary pay-as-you-go disk from the snapshot. For more information, see Create a disk from a snapshot.
Attach the disk to an ECS instance. For more information, see Attach a data disk.
Bring the disk Online.
Connect to the ECS instance to which the cloud disk is attached, click the icon, and then select Disk Management.
Find the cloud disk that you want to manage, right-click a blank area, and select Online.
Copy the specific folder or file to the original disk.
Detach and release the temporary disk. For more information, see Detach a data disk and Release a disk.