HOW TO: Revert a Snapshot of an Instance In Amazon Web Services (AWS)

I write about this topic because it's one that may not be immediately obvious to those new to AWS and with previous visualization experience.

In AWS there is a much looser tie between various components that make up a server. An EC2 instance is nothing more than a reservation for some allocation of processor power and memory. Persistent block storage (EBS) or ephemeral instance storage is associated with an instance reservation and assigned a device mapping that tells the hypervisor how the volume is related to the instance. A single device either an EBS volume or ephemeral instance storage can be attached as the root (boot) device. The number of other attachable devices depends on your instance type. See the reference link below to AWS documentation for further explanation of these device mappings and these concepts.

A snapshot is related to a volume and only to an instance through the attachment of a volume. Hence a snapshot is not per say a point in time for an instance, rather it is a point in time for a volume. If you want to take a snapshot of an instance, you would in fact need to assess each attached volume and take snapshots of each as needed. If you want to snapshot the instance what you probably want to do is take a snapshot of the root drive.

Snapshots capture each block in a volume that has changed since the last snapshot was taken. Each block in a snapshot of a volume is stored as an S3 object. The more changes and time between snapshots the longer your snapshots will take as more blocks will likely need to be copied and stored as S3 objects. There is no way to revert a volume to a previous state from these snapshots. Instead, a snapshot allows you to create a new volume using the snapshotted blocks giving you a copy of a volume at a specific point in time. You'll need to then replace the attached volume on your instance with this new volume created from the snapshot.

STEPS:

  1. Open your AWS EC2 console https://console.aws.amazon.com/ec2 and ensure you have the proper region selected.
  2. Open the Instances control panel and select the instance that you know your volume that has been snapshotted is attached to.
    1. Find the volume ID
      1. If you scroll down in the instance details panel you'll find a section called "Block devices".
      2. Select the volume that you want to revert.
      3. Note the EBS-ID of this volume.
    2. Shutdown the instance if it is still running.
  3. Open the Snapshots control panel, you should see a volume column, sort by the volume column.
    1. Find the snapshot(s) in this list with the volume ID you noted in the above step.
    2. Right Click and select "Create Volume from Snapshot" which will open a dialog to select volume options.
      1. Select the Volume Type (Standard or IOPS Provisioned)
        1. Note that you can only use an IOPS provisioned volume on an EBS Optimized Instance Type.
      2. Enter the Size
        1. Note that you can expand but not shrink a volume size.
      3. If you chose IOPS provisioned enter the IOPS value.
      4. Choose Availability Zone
        1. Note that you can create a volume from a snapshot in any AZ. This could be used to move datasets between AZs. Your volume will need to exist in the same AZ as the instance you want to attach it to so be sure you select the right AZ.
      5. Click "Yes, Create"
  4. Open the Volume control Panel.
    1. Select the volume that is still attached to your instance.
      1. Find the Device Code in your volumes current attachment.
        1. If you scroll down in the volume details panel you'll find a section called "Attachment".
        2. Note the device mapping in the displayed attachment information.
          1. Syntax of attachment information <Instance> (<Instance Name>):<Device Mapping> (<Status>)
          2. For Example in the attachment information "i-ee512299a (My Instance):/dev/sda1 (attached)" the device mapping is "/dev/sda1". This happens to be the device mapping for the root device.
      2. Right click and select "Detach Volume"
    2. Select the new volume you created
      1. Note that it should show a status of Available once the volume creation has completed.
      2. Right click the volume and select "Attach Volume" which will open a dialog.
        1. Select the instance that you want to attach to, in our example above "i-ee512299a".
        2. Enter the device mapping, in our case "/dev/sda1".
        3. Click "Yes, Attach"
  5. Startup your instance and you’re done!

Reference: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html

NOTICE: All thoughts/statements in this article are mine alone and do not represent those of Amazon or Amazon Web services. All referenced AWS services and service names are the property of AWS. Although I have made every effort to ensure that the information in this article was correct at writing, I do not assume and hereby disclaim any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from negligence, accident, or any other cause.