Amazon Elastic Block Store (Amazon EBS) offers highly available and persistent block-level storage with AWS EC2. This type of storage system is very useful when it comes to storing files, applications, and databases in order to achieve persistent data storage. EBS volumes can only be attached to EC2 instances that are located in the same Availability Zone (AZ).
While it is important to perform backups on a regular basis, certain cases, such as before any major changes are made within your company, call for backups when data is consistent at a stable point in time so it can be recovered in the future. AWS EBS provides you with the ability to create point-in-time consistent backup snapshots of volumes, we like to call them ‘crash-consistent’. They are helpful when you want to restore data to a stable point in time when the crash-consistent snapshot was taken.
This article will look at an EBS volume whose data is consistent at a particular point in time. You can back up data with crash-consistent snapshots, however it is important to note that AWS recommends stopping instances in order to achieve consistent data. Otherwise, you can use solutions, such as N2WS Backup & Recovery, that provide application-consistent snapshots, ensuring data is consistent. Once a snapshot is taken, you can use it to recover files or volumes that were accidentally deleted by creating a new volume from that snapshot.
AWS EBS snapshots provide incremental backups, therefore, if they are taken during different intervals of time, only the blocks that were modified would be backed up by AWS. This makes backups quicker and more cost effective.
Below, we will outline how to recover files that were accidentally deleted from their EBS volume, using snapshots:
- We have launched a Windows 2012 based EC2 instance with an EBS volume as the root device.
- Data can be stored in a root or an additional volume that is attached to the instance.
(Note: Two files—a text and an MP4—are stored in the EBS volume below.)
- You can now create a snapshot of this volume containing the data.
(Note: For this example, we’ve assumed that the AWS CLI tool has already been installed on the local host.)
aws ec2 create-snapshot –volume-id vol-654c7421 –description “This is my root volume backup snapshot.”
Now, assuming that the two files stored on the volume were accidently deleted, how can they be recovered?
You can recover data using the snapshot you created in step #2.
The following steps detail this process:
- The snapshot that was generated through the volume can be seen in the following screen.
aws ec2 describe-snapshots –snapshot-id snap-59c568d4
- Create a volume of the snapshot (containing the data that is to be recovered) in the same AZ as the instance.
- Next, fill the appropriate details (apart from the AZ) into the wizard below, such as the type and size of the volume, as well as IOPS (if you want to create a PIOPS volume).
aws ec2 create-volume –region us-east-1 –availability-zone us-east-1a –snapshot-id snap-59c568d4 –volume-type io1 –iops 500
- Check out the newly created volume in the following wizard.
aws ec2 describe-volumes
- Next, attach this volume to the desired instance.
aws ec2 attach-volume –volume-id vol-d63d0592 –instance-id i-ab669244 –device /dev/sdf
We are attaching this volume as an additional volume to an already running instance in the US-East-1a region. You can configure additional devices as “D” drives on your Windows instance.
- “D” drives show the original data in the following wizard:
There you have it. In this article, we have demonstrated how to recover lost data using EBS snapshots. It is recommended to perform backups at regular intervals.
N2WS Backup & Recovery (CPM) is an enterprise-class backup, recovery and disaster recovery solution for EC2. It uses existing EBS volume and RDS database snapshot abilities to automatically take snapshots at regular intervals. Additionally, you can set up policies and schedule backups for various targets. CPM helps manage snapshots with policies. For example, if you have multiple snapshots, the older ones may be irrelevant. With CPM, you can configure a policy to delete the snapshots after a certain period. This also helps in cost savings and effective backup management.