Using Snapshots

Authors
  • avatar
    Name
    Michael Bui
    Twitter

Overview

Snapshots let you back up data on Amazon EBS volumes. They save the state of the volume at a point-in-time and subsequent backups are incremental.

Snapshots are useful for copying over EBS volumes from one availability zone to another. You can create a snapshot of an EBS volume then create a new volume based on the snapshot.

You can also use snapshots to create your own custom images with preconfigured settings then launch a new EC2 instance with those settings.

In this lab, we'll look at creating a snapshot for an EBS volume and creating a new volume in another availability zone. We'll also look at creating our own custom AMI with an apache http server installed.

Moving EBS Volumes with Snapshots

In the the Create and Attach EBS Volumes lab we created an EBS volume in the west-2a availability zone. We're going to create a snapshot of that EBS volume and move it to west-2b

  1. Go to EC2 -> Elastic Block Store -> Snapshots -> Create Snapshot
  2. Create a snapshot of a volume
  3. Choose the volume to create a snapshot of
  4. From the Snapshot select Create volume from snapshot
  5. Select the us-west-2b availability zone
  6. Attach the volume to the Lab-3 EC2 instance we made in a previous lab
  7. SSH into Lab-3
  8. Mount the volume
  • All the data we had from the previous EBS volume from availability zone west-2a has been moved to west-2b on to this EC2 instance

Creating an AMI From a Snapshot

  1. Create an EC2 instance with the following startup script
#!/bin/bash
yum update -y
yum install -y httpd
systemctl start httpd
systemctl enable httpd
  1. Go to the http://(ip address here) and you'll see the default apache webpage
  2. Create a Snapshot of the instance
  3. From the snapshot - select Create image from snapshot
  4. Provide a name/description and leave defaults
  5. Alternatively, you can skip creating a snapshot and create an image straight from the EC2 dashboard by right clicking the instance and selecting create image
  6. Go to EC2 -> Images -> AMIs select the AMI and click Launch instance from AMI
  7. Alternatively, go to launch an instance and select your AMI under My AMIs
  8. Go to the http://(ip address here) of the newly created EC2 instance & without any configurations you should see the apache http server default page