This is the fourth part of the series about Storage Gateway service from AWS. In this part, we will discuss snapshots. We will discuss how to:

  • Take a one time snapshot
  • Schedule snapshots
  • Restore a snapshot to an EBS volume
  • Restore a snapshot to a storage volume

Snapshots were discussed in the first part of the series, but we will revise the basic notions in this article as well.

VMware Training – Resources (Intense)

A snapshot allows backing up to a point in time view of the data that has been written to the storage volume. The snapshot can be used later to restore the data either on-premises or in Amazon EC2. The snapshots can be taken on a scheduled basis or on a one-time basis (that is manually).

A snapshot is incremental which means that the gateway uploads only the data that has changed since the last snapshot. Any snapshot can be deleted and only the snapshot data that is not needed by other snapshot is deleted.

If gateway-cached architecture is used where the data is stored in Amazon S3, a snapshot can help retaining older versions of the data.

If gateway-stored architecture is used where the data is stored on-premises, a snapshot can help backing up the data to Amazon S3.

So let’s start this and see how it is done. As you might remember from part three of the series, we had one drive on our Windows 7 system where the storage volume was connected.

Also, we used the gateway-cached architecture.

I added a file with the size of 100MB:

As mentioned, you can have the snapshots created on a scheduled basis or ad-hoc. By default, there are no scheduled snapshots jobs for gateway-cached volumes. To see if there are any jobs that should schedule the snapshots creation, select the storage gateway and then select the “Snapshot Schedules” tab. As you can see, we don’t have any:

Click on “Add/Modify Snapshot Schedule”. You can select for which volume to schedule the snapshot. You can then specify when the first snapshot will be taken and at which intervals the next ones will be taken:

The other way to take a snapshot is the one-time way. Actually, you can take multiple one-time snapshots. It is just done manually. To take this snapshot, select the storage gateway, select the “Volumes” tab and then click on “Create Snapshot”:

Few minutes later, from the navigation menu, select “Snapshots” and you should see the snapshot. The Snapshot ID will be used later:

Going back to EC2 Management Console and selecting “Snapshots”, you should see the snapshot that you created from the storage volume. You can compare the two Snapshot IDs:

Now you need to create a volume from the snapshot. Right click on the snapshot and select “Create Volume”:

Fill in the details and click on “Create”:

Select “Volumes” from the EC2 Management Console and you should see the new volume. As you can see, there is another volume that is in-use by the EC2 instance to which the new volume will be attached:

This is the EC2 instance to which we will attach the volume:

Right click on the new volume and then select “Attach Volume”:

Select the right EC2 instance and record the device to which the new volume will be attached:

Now, it’s time to perform some work on the EC2 instance. Connect to the EC2 instance:

lab@UBUNTU:~/AWS$ ssh -i AMAZON_LINUX.pem ec2-user@
The authenticity of host ' (' can't be established.
ECDSA key fingerprint is 2b:b0:c2:f1:68:5f:59:45:4c:f9:e0:36:a8:e0:d2:b4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (ECDSA) to the list of known hosts.

       __|  __|_  )
       _|  (     /   Amazon Linux AMI
24 package(s) needed for security, out of 53 available
Run "sudo yum update" to apply all updates.
[ec2-user@ip-172-31-12-184 ~]$

Confirm that the new volume was attached. In our case it will /dev/xvdf1:

[ec2-user@ip-172-31-12-184 ~]$ lsblk
xvda    202:0    0    8G  0 disk
└─xvda1 202:1    0    8G  0 part /
xvdf    202:80   0  150G  0 disk
└─xvdf1 202:81   0  150G  0 part
[ec2-user@ip-172-31-12-184 ~]$

After you made yourself root, create the folder where the volume from the snapshot will be mounted:

[root@ip-172-31-12-184 ec2-user]# mkdir /mnt/vol_from_snapshot
[root@ip-172-31-12-184 ec2-user]#

Before you can mount the device, you need to know the file system format:

[root@ip-172-31-12-184 ec2-user]# fdisk -l /dev/xvdf

Disk /dev/xvdf: 161.1 GB, 161061273600 bytes, 314572800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xa88dd049

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdf1            2048   314568703   157283328    7  HPFS/NTFS/exFAT
[root@ip-172-31-12-184 ec2-user]#

Now mount the device as NTFS (because the storage volume was mounted on a Windows 7):

[root@ip-172-31-12-184 ec2-user]# mount -t ntfs /dev/xvdf1 /mnt/vol_from_snapshot/
[root@ip-172-31-12-184 ec2-user]#

Move to the mountain point and confirm that you have the file test-1.100M that we saw in the beginning of the article:

[root@ip-172-31-12-184 ec2-user]# cd /mnt/vol_from_snapshot/
[root@ip-172-31-12-184 vol_from_snapshot]# ls -l
total 97660
dr-x------ 1 root root         0 Jul  8 15:25 $RECYCLE.BIN
dr-x------ 1 root root         0 Jul 14 12:39 System Volume Information
-r-------- 2 root root 100000000 Jul 14 13:17 test-1.100M
[root@ip-172-31-12-184 vol_from_snapshot]#

Remember that we configured the automatic snapshots previously. Meanwhile, I copied another file to the storage volume:

After the configured interval has passed, a snapshot of the storage volume was taken:

And you can also see this in the EC2 Management Console. Notice the different description between the two snapshots that were taken in a different way:

However, if another automatic snapshot is created, it will have the same description as the other automatic snapshots.

If we perform the steps that we did previously by creating another volume and then attaching it to the EC2 instance, we will see the two files there:

[root@ip-172-31-12-184 vol_from_snap_hour]# ls -l
total 195320
dr-x------ 1 root root         0 Jul  8 15:25 $RECYCLE.BIN
dr-x------ 1 root root         0 Jul 14 12:39 System Volume Information
-r-------- 2 root root 100000000 Jul 14 13:17 test-1.100M
-r-------- 2 root root 100000000 Jul 14 13:17 test-2.100M
[root@ip-172-31-12-184 vol_from_snap_hour]#

As mentioned in the beginning of the article, you can restore a snapshot to either an EBS volume or to another storage volume.

To restore the snapshot to another storage volume, select the storage gateway, select the “Volumes” tab and click on “Create New Volume”:

In the next window, you need to specify the storage volume capacity that has to be at least the size of the snapshot. Then on the “Based on Snapshot ID” you need to fill in the Snapshot ID that you want to use as source for this new storage volume:

After some time, the new volume is created and you can see what was the source snapshot:

And that would be almost everything that you need to know about snapshots.

By reaching this point of the article you should know what the snapshots are, how to create them regularly or manually and how to restore them into another storage volume or to an EBS volume that can be attached to an EC2 instance.

In the next part of the series we will discuss how to monitor the Amazon Storage Gateway service, so stay tuned.