DEV Community

Cover image for A Deep Dive into AWS Snapshots, EBS Backup, and Automation Strategies - Week Twelve
Shubham Murti
Shubham Murti

Posted on • Edited on

A Deep Dive into AWS Snapshots, EBS Backup, and Automation Strategies - Week Twelve

Hello Community!

In week twelve of my cloud engineering journey, I focused on mastering AWS Snapshots, specifically EBS Snapshots, their importance, and the strategies surrounding their use. Here's an in-depth explanation of what I learned and how you can apply these concepts in your cloud infrastructure.

What is an AWS Snapshot?

An AWS snapshot is essentially a point-in-time backup of your EBS volumes. This means that at any given moment, you can create a snapshot to capture the state of your data. This is incredibly useful if you accidentally delete or corrupt data; you can restore your EBS volume to the exact state it was in when the snapshot was taken.

Key Features of AWS Snapshots:

  • Point-in-Time Backup: Snapshots capture the exact state of your EBS volume at a specific moment. This ensures that your data can be restored to that exact point in time.
  • Stored in S3: AWS stores these snapshots in Amazon S3, ensuring durability and availability.

Incremental Backups: A Cost-Effective Solution

AWS snapshots are incremental, which means that only the data that has changed since the last snapshot is saved. This feature makes snapshotting a very cost-effective solution.

Example of Incremental Backup:

Suppose you create a 100GB EBS volume and take a snapshot after adding 50GB of data. Initially, the snapshot will store the full 50GB. Two days later, you add another 10GB of data, making the total 60GB. When you take another snapshot, AWS will only save the 10GB of new data.

This incremental approach ensures that you are only charged for the storage you use, not for the entire volume each time.

Backup Strategies: Full vs. Incremental

  1. Full Backup:

    • A full backup involves creating a snapshot that includes all the data on your EBS volume. While this ensures comprehensive backup coverage, it is more storage-intensive.
  2. Incremental Backup:

    • As described earlier, incremental backups only save changes made since the last snapshot. This method is more storage-efficient and cost-effective.

How Incremental Backups Work:

AWS manages these backups in a series of containers. For example, if Container 1 stores 50GB and Container 2 stores 20GB, and you delete Container 1, AWS will automatically transfer the necessary data to Container 2, ensuring that no data is lost. The key point is that data dependencies are managed sequentially, meaning that if data in Container 1 is deleted, Container 2 will inherit it, but not Container 3.


Creating Your First EBS Snapshot

Let's walk through the process of creating and managing your first EBS snapshot.

Step 1: Create an EC2 Instance

When you create an EC2 instance, AWS automatically creates two volumes: one 8GB root volume and another 10GB volume for data.

Step 2: Connect to Your EC2 Instance

Use a web browser or the AWS console to connect to your EC2 instance. Then, use the command line to create a file:

sudo -i  # Log in as root
file -s /dev/xvdb  # Check the file system
mkfs.ext4 /dev/xvdb  # Format the volume
mkdir /data  # Create a directory
mount /dev/xvdb /data  # Mount the volume
cd /data/
yes "your_text_here" >> abc.txt  # Create a file with some data
ls -lh  # List files to verify
df -h  # Check disk usage
Enter fullscreen mode Exit fullscreen mode

Step 3: Create a Snapshot

  1. Navigate to the Volume Section:

    • Go to the EC2 Dashboard.
    • Select the "Volumes" section.
  2. Select Your Volume:

    • Choose the volume you want to create a snapshot of.
  3. Create Snapshot:

    • Click on "Create Snapshot."
    • Provide a description for your snapshot to help identify it later.

Step 4: Verify Snapshot

  1. Go to the Snapshot Dashboard:

    • Access the "Snapshots" section in the EC2 Dashboard.
  2. Select Your Snapshot:

    • Find and select the snapshot you just created.
  3. Ensure Correct Creation:

    • Verify that the snapshot is listed and its status shows as "completed."

Automating EBS Volume Backups with Lifecycle Manager

Manually managing snapshots can be tedious, especially as your infrastructure grows. AWS provides a solution with the EBS Lifecycle Manager, which allows you to automate backup creation.

Steps to Automate EBS Backups:

  1. Create a Volume:

    • Start by creating and tagging your EBS volume.
  2. Lifecycle Manager Configuration:

    • Navigate to the Lifecycle Manager.
    • Specify the settings, including volume selection, target resources (using tags), and IAM roles.
    • Configure the backup schedule, including frequency, start time, and retention period.
  3. Review and Apply Policy:

    • Once configured, review the policy and apply it.

Using the Recycle Bin for Snapshots and AMIs

The AWS Recycle Bin provides a safety net for deleted snapshots and AMIs. When you delete a snapshot, it moves to the Recycle Bin, where it can be recovered within a specified retention period.

Steps to Use the Recycle Bin:

  1. Access Recycle Bin:

    • Go to the EBS Dashboard and search for the Recycle Bin.
  2. Create Retention Rules:

    • Click on "Create Retention Rule."
    • Fill in details such as Rule Name, Resource Type, and Retention Period.
  3. Testing:

    • Create and delete a snapshot.
    • Check the Recycle Bin to verify that the snapshot is there.
    • Recover the snapshot if needed.

Copying Snapshots Across Regions

AWS allows you to copy snapshots across regions, which is essential for disaster recovery and data migration.

How to Copy a Snapshot:

  1. Navigate to the Snapshot Dashboard:

    • Access the Snapshots section in the EC2 Dashboard.
  2. Select the Snapshot:

    • Click on the snapshot you wish to copy.
  3. Action Button:

    • Choose the "Copy Snapshot" option.
  4. Select Target Region:

    • Fill in the details and choose the destination region.
  5. Verify:

    • Go to the selected region to ensure that the snapshot is available.

Closure

AWS EBS snapshots provide a powerful, flexible, and cost-effective way to back up and restore your data. Understanding how to use snapshots effectively is crucial for maintaining data integrity and ensuring business continuity.

By leveraging incremental backups, automating snapshot creation, and using tools like the Recycle Bin and cross-region copying, you can create a robust backup strategy that minimizes data loss and optimizes costs.

Stay tuned for more updates next week!

Shubham Murti — Aspiring Cloud Security Engineer | Weekly Cloud Learning !!

Let’s connect: Linkdin, Twitter, Github

Top comments (0)