All Products
Search
Document Center

Elastic Compute Service:Roll back a disk by using a snapshot

Last Updated:Mar 27, 2024

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

Before you roll back a disk by using a snapshot, take note of the following items:

  • 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 for a disk.

    Warning

    The 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 point in 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.

  • 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.

    Note

    You 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.

  • 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.

  • You cannot use a snapshot of one disk to roll back another disk. If you want to migrate data in a snapshot of one disk to another disk, you can create a disk by using the snapshot. For more information, see Create a disk from a snapshot.

  • Limits on disk status:

    • If a disk is in the Unattached state, the disk is not attached to an ECS instance. You can roll back the disk.

    • If a disk is attached to an ECS instance, stop the ECS instance before you roll back the disk.

Roll back a disk by using a snapshot

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.

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Storage & Snapshots > Snapshots.

  3. In the top navigation bar, select the region and resource group to which the resource belongs. 地域

  4. Click the Disk Snapshots tab.

  5. Find the snapshot that you want to use. In the Actions column, click Roll Back Disk.

  6. In the message that appears, click OK.

Note

If you roll back the system disk of an ECS instance, the current SSH key pair or username and password of the instance remains bound to the instance. After the system disk is rolled back, you still can use the SSH key pair or username and password to log on to the ECS instance.

(Optional) Synchronize data after a disk is rolled back

If you roll back a disk by using Snapshot A that was created at the point in time T1 and you want to synchronize data that you added, removed, and modified after T1, you can perform the following operations:

image
  1. Create Snapshot B for the original disk at the point in time T2.

  2. Roll back the original disk by using Snapshot A.

  3. Create a disk by using Snapshot B.

    For more information, see Create a disk from a snapshot.

  4. Attach the new disk to the same ECS instance as the original disk.

    For more information, see Attach a data disk.

  5. Connect to an ECS instance.

    For information about the connection methods, see Connection method overview.

  6. View the new disk.

    • Linux instance:

      1. If the disk is attached to a Linux instance, log on to the instance and run the following command to perform the mount operation:

        mount <Disk partition name> <Mount point>
        • <Disk partition name>: You can log on to the instance to which the source disk of the snapshot is attached and run the df -h command to query the disk partition name.

        • <Partition mount point>: You can specify an existing directory as the mount point or run the mkdir -p <Mount point of the partition> command to create a directory as the mount point. The mount point must start with a forward slash (/) and contain letters or digits. Example: /mnt.

      2. Writes the new partition information to the /etc/fstab file. This way, the partition is automatically mounted on system startup.

        For more information, see Step 4: Configure the disk partition to automatically mount on instance startup.

    • If the disk is attached to a Windows instance, log on to the instance and connect the disk online in the Disk Management window. For more information, see Step 1 to Step 4 in Initialize a data disk up to 2 TiB in size on a Windows instance.

  7. Copy useful data from the new disk to the original disk.

  8. (Optional) Release the new disk to prevent unnecessary charges.

    For more information, see Release a disk.

What to do next

  • After you roll back a disk by using a snapshot, data that you added, removed, or modified from the point in time when the snapshot was created to the point in 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.