Skip to main content

Command Palette

Search for a command to run...

Amazon EBS Snapshots

Published
17 min read
Amazon EBS Snapshots

Amazon Elastic Block Store (EBS) provides a reliable way to store data in AWS. One key feature for ensuring data safety and recovery is Amazon EBS snapshots.

What are Snapshots? Think of snapshots like photos—they capture the state of your EBS volume at a specific point in time. When you take snapshots regularly, only the changes since the last snapshot are saved. It's like taking a picture of only the new things in a scene since the last photo.

Features of Amazon EBS Snapshots

  1. Taking Snapshots:

    • You can take a snapshot of a volume even while it's being used. However, the snapshot will only include data written up to that point. For a complete picture, it's best to pause writes, unmount the volume, take the snapshot, and then remount it.
  2. Encryption:

    • Both encrypted volumes and their snapshots are automatically encrypted, enhancing data security. You can share snapshots, but for encrypted ones, the recipient needs the encryption key to access them.
  3. Managing Multiple Snapshots:

    • You can create snapshots for all or some volumes attached to an instance. Using tags makes it easier to manage multiple snapshots collectively during restore, copy, or retention.
  4. Automating Snapshots:

    • You can automate the creation and retention of snapshots with snapshot lifecycle policies using Amazon Data Lifecycle Manager, simplifying management.

Understanding Incremental Backups

EBS snapshots work as incremental backups, capturing only the data changes since the last snapshot. This method saves time and reduces storage costs by avoiding duplicate data.

User Responsibility

It's important to note that AWS doesn't automatically back up data on EBS volumes. Users must regularly create snapshots or use tools like Amazon Data Lifecycle Manager or AWS Backup for automated snapshots to ensure data safety and disaster recovery.

Snapshot Management

  1. Storage in Amazon S3:

    • Snapshots are stored in Amazon S3, providing durability and accessibility. However, you can't directly access them through the S3 console or API; use the Amazon EC2 console or API instead.
  2. Restoring Snapshots:

    • Each snapshot includes all the information needed to restore data to a new EBS volume. When creating a volume from a snapshot, it becomes an exact replica of the original, with data loaded in the background for immediate use.
  3. Deleting Snapshots:

    • Deleting a snapshot removes only the unique data of that snapshot. Data referenced by other snapshots remains intact, ensuring efficient storage management.

Snapshot Events and Multi-Volume Snapshots

  1. CloudWatch Events Integration:

    • Track the status of your snapshots using CloudWatch Events for insights into their health.
  2. Multi-Volume Snapshots:

    • For complex workloads, multi-volume snapshots provide coordinated, crash-consistent backups without stopping instances, simplifying management for critical workloads.

Snapshot Pricing

  1. Incremental Storage Charges:

    • Charges are based on the amount of stored data. Deleting a snapshot may not immediately reduce costs since only the unique data to that snapshot is removed.
  2. Billing Considerations:

    • For detailed pricing information, refer to the AWS Billing User Guide.

Easily Copy Amazon EBS Snapshots

  1. Copy Snapshots Anywhere:

    • Once a snapshot is stored in Amazon S3, you can copy it to another AWS region or within the same region. This process is secure with strong encryption.
  2. Copying Multi-Volume Snapshots:

    • Tagging makes it easier to find and copy multiple snapshots individually.
  3. Sharing Snapshots:

    • Share your snapshot by allowing access or making it public, similar to sharing a file with a friend.

Use Cases

  1. Geographic Expansion:

    • Easily deploy your applications in a new AWS region.
  2. Migration:

    • Move your application to a new place for better availability and cost.
  3. Disaster Recovery:

    • Backup data in different places to quickly restore applications in case of issues.

Encryption and Security

  1. Encrypt Snapshots:

    • Keep snapshots secure by encrypting them.
  2. Change Encryption Key:

    • Change the encryption key used for added security.
  3. Data Retention:

    • Copy data to another AWS account for safekeeping, protecting against accidental deletions or account compromises.

In Summary

Amazon EBS snapshots are a smart way to keep your data safe, whether for expansion, migration, or disaster recovery. Start protecting your data today!

Follow these steps to generate a snapshot from an EBS volume:

  1. Go to the Amazon EC2 Console:

    • Open the Amazon EC2 console.
  2. Navigate to Snapshots:

    • In the side menu, click on "Snapshots," then select "Create snapshot."
  3. Choose Resource Type:

    • Select "Volume" as the resource type.
  4. Select Specific Volume:

    • Pick the specific volume you want to snapshot.
  5. Encryption Status:

    • Check the Encryption field. If the volume is encrypted, the snapshot will be automatically encrypted with the same key. If it's not encrypted, the snapshot won't be encrypted.
  6. Provide Description (Optional):

    • Add a brief description for the snapshot if desired.
  7. Add Tags (Optional):

    • In the Tags section, click "Add tag" and enter key-value pairs. You can add up to 50 tags for easier management.
  8. Create Snapshot:

    • Click on "Create snapshot" to complete the process.

How to Create a Volume from an EBS Snapshot

  1. Go to the Amazon EC2 Console:

    • Open the Amazon EC2 console.
  2. Navigate to Volumes:

    • In the menu, click on "Volumes."
  3. Create Volume:

    • Click on "Create volume."
  4. Select Volume Type:

    • Choose the type of volume you want to create (the default is General Purpose SSD gp3).
  5. Enter Volume Size:

    • Specify the size of the volume in gigabytes (GiB).
  6. Specify IOPS/Throughput (if needed):

    • For io1, io2, and gp3 types, you can enter the maximum number of input/output operations per second (IOPS) or throughput.
  7. Choose Availability Zone:

    • Select the Availability Zone where you want the volume. It must match the zone of the instances you plan to attach it to.
  8. Pick Snapshot:

    • Choose the snapshot you want to use for creating the volume.
  9. Set Encryption Status:

    • If the snapshot is encrypted, the volume will be automatically encrypted. If not, you can choose to encrypt it and select the encryption key.
  10. Add Tags (Optional):

    • Add custom tags for easier identification.
  11. Create Volume:

    • Click on "Create Volume."

Final Step

  • Check Volume Status:

    • Your volume is ready when the status shows "available."

    • Attach the volume to an instance to start using it.

By following these steps, you can easily create snapshots from EBS volumes and create new volumes from those snapshots. This helps in managing and backing up your data efficiently in AWS.

Automate EBS Volume Snapshots

Automating EBS volume snapshots helps ensure your data is regularly backed up without manual intervention. Here are some key points and steps to set up and manage snapshot lifecycle policies in AWS:

Considerations for Snapshot Lifecycle Policies:

  1. Region-Specific Targeting:

    • Snapshot lifecycle policies operate within the same AWS Region where the policy is defined.
  2. Snapshot Creation Timing:

    • The first snapshot is taken within an hour of the specified time, with subsequent snapshots following the scheduled times.
  3. Multiple Policies for a Volume or Instance:

    • You can have multiple policies for one volume or instance, each with its own schedule. Remember, tags are case-sensitive when targeting resources.
  4. Managing Existing Snapshots:

    • If you remove target tags, existing snapshots are no longer managed by the policy, so you'll need to delete them manually.
  5. Policy Impact on New Volumes:

    • New volumes attached to a target instance will be included in the backup during the next policy run.
  6. Custom Cron-Based Schedule:

    • Custom cron-based schedules creating a single snapshot won't auto-delete when the retention threshold is met.
  7. Age-Based Policy Consideration:

    • If the retention period is shorter than the creation frequency, the last snapshot is kept until the next one is created.

Snapshot Archiving Considerations:

  1. Snapshot Archiving Restrictions:

    • Archiving is only allowed for volume-targeting snapshot policies. One archiving rule per schedule is specified.
  2. Archiving Minimum Retention:

    • The minimum retention period in the archive tier is 90 days.
  3. Snapshot Archiving Impact:

    • Archiving converts snapshots to full snapshots, potentially increasing storage costs.
  4. Snapshot Sharing and Archiving:

    • Fast snapshot restore and snapshot sharing are disabled for archived snapshots.
  5. Snapshot Archiving Retry:

    • If archiving fails for 24 hours, the snapshot remains in the standard tier, scheduled for deletion as if it had been archived.
  6. Tagging of Archived Snapshots:

    • Archived snapshots are tagged for identification.

Additional Considerations:

  1. Excluding Root Volumes and Data Volumes:

    • Excluding root volumes impacts snapshot creation for the entire instance.
  2. Deleting Volumes or Terminating Instances:

    • This affects snapshots based on the retention schedule.
  3. Fast Snapshot Restore:

    • Enabled only for snapshots 16 TiB or less, with charges applied per minute.
  4. Multi-Attach Enabled Volumes:

    • Separate snapshots are initiated for each attached instance when targeting instances with Multi-Attach enabled volumes.
  5. Snapshot Sharing Across Accounts:

    • Encrypted snapshots require sharing the KMS key. Default encryption KMS key snapshots can't be shared.
  6. Snapshot Archiving and Recycle Bin:

    • Manually archived snapshots in the Recycle Bin must be managed manually.
  7. Policies in Error State:

    • Policies in an error state affect snapshot retention. Manual deletion may be required.
  8. Snapshot Lock Considerations:

    • Manually locked snapshots need manual deletion if still locked when their retention threshold is reached.

Creating a Snapshot Policy in Amazon EC2

Here are the simplified steps:

  1. Go to the Amazon EC2 Console:

  2. Navigate to Lifecycle Manager:

    • In the menu, select "Elastic Block Store," then "Lifecycle Manager," and click "Create lifecycle policy."
  3. Choose Policy Type:

    • Select "EBS snapshot policy" and click "Next."

  4. Specify Target Resources:

    • Choose the type of resource to back up (Volume or Instance). If using AWS Outpost, select the location of the target resources.
  5. Choose Resource Tags:

    • Identify volumes or instances for backup using resource tags.

  6. Provide Policy Description:

    • Enter a brief description for the policy.
  7. Select IAM Role:

    • Choose the IAM role with permissions for managing snapshots.
  8. Add Tags:

    • Add tags for identification and categorization.
  9. Enable or Disable Policy:

    • Choose to enable or disable the policy for immediate or manual start.

  10. Exclude Volumes (if needed):

    • Decide whether to exclude volumes from multi-volume snapshot sets if targeting instances.
  11. Configure Policy Schedules:

    • Set up the schedule, including name, frequency, start time, and retention type.

  12. Specify Snapshot Details:

    • Define the snapshot destination, tagging, and any pre/post scripts if needed.
  13. Configure Snapshot Archiving:

    • For volume-targeting policies, set up snapshot archiving.
  14. Enable Fast Snapshot Restore:

    • If desired, enable fast snapshot restore and choose the Availability Zones.
  15. Add Additional Schedules (if necessary):

    • Add more schedules if required.
  16. Review Policy Summary:

    • Go through the policy summary.

  17. Create the Policy:

    • Finally, choose "Create policy."

By following these steps, you can automate the snapshot creation process, ensuring your data is backed up regularly and efficiently managed.

Recycle Bin Retention Rules

The Recycle Bin in Amazon EBS acts like a safety net for your data. When you accidentally delete snapshots or AMIs (Amazon Machine Images), they aren't gone right away. Instead, they go to the Recycle Bin and stay there for a set period before being permanently deleted.

You can restore any deleted resource from the Recycle Bin as long as it's within that set time. Once you restore something, it leaves the Recycle Bin and becomes fully functional again. If you don't restore it in time, it's permanently deleted after the specified period.

Using the Recycle Bin adds an extra layer of protection, ensuring you don't lose important data due to accidental deletions, keeping your business running smoothly.

How It Works

Setting It Up:

  1. Define Rules:

    • In AWS Regions, you create rules to specify what kind of resources you want to protect.

    • These rules dictate which types of resources go into the Recycle Bin when deleted.

    • You also set how long to keep these resources in the Recycle Bin before they are permanently deleted.

Types of Rules:

  1. Tag-Level Rules:

    • If you want to protect specific resources based on their tags (labels), you use this type of rule. Anything with those tags goes into the Recycle Bin when deleted.
  2. Region-Level Rules:

    • If you want to protect all resources of a certain type in a specific region, use this rule. It covers everything of that type in that area without needing tags.

What Happens in the Recycle Bin:

  • Restoring Resources:

    • You can bring back any resource from the Recycle Bin at any time as long as it's within the retention period.
  • Permanent Deletion:

    • If you don't restore the resource in time, it's permanently deleted after the set period.

What It Protects:

  • Amazon EBS Snapshots: Like saving a copy of your data at a specific time.

  • Amazon EBS-backed AMIs: Like a saved version of a computer setup.

Important Notes

  1. Stored Snapshots:

    • The rules also apply to stored snapshots. If you delete one that matches a rule, it stays in the Recycle Bin for the rule's duration.
  2. Disabled AMIs:

    • Rules work even for disabled AMIs (ones not actively in use).

Setting Up Retention Rules

Step 1: Understand Required Parameters:

  • Tag-level Retention Rule:

    • Protect resources based on tags. You can assign up to 50 tags to each rule for customization.
  • Region-level Retention Rule:

    • Protect all resources of a specific type in a particular region without needing tags.

Step 2: Set the Retention Period:

  • Decide how long to keep resources in the Recycle Bin after deletion. This can be up to 1 year (365 days), providing flexibility based on your needs.

Step 3: Optional Parameters:

  • Name and Description:

    • Give your retention rule a descriptive name and a brief description to manage it easily.
  • Retention Rule Tags:

    • Use custom tags to organize and identify your retention rules effectively.
  • Locking Rules:

    • Optionally, lock retention rules on creation for added security. Specify an unlock delay period (7 to 30 days).

Step 4: Creation Methods:

  • You can create a Recycle Bin retention rule using either the Recycle Bin console or the AWS CLI, whichever you prefer.

Step 5: Walkthrough Using the Recycle Bin Console:

  1. Open the Recycle Bin console here.

  2. In the navigation pane, select "Retention rules" and click "Create retention rule."

  3. Fill in the rule details and settings as needed.

  4. Choose to lock or leave the retention rule unlocked based on your security preferences.

  5. Optionally, add custom tags for better organization.

  6. Click "Create retention rule" to complete the process.

By following these steps, you can efficiently create Recycle Bin retention rules, ensuring the safety and recoverability of your AWS resources.

Conclusion

Securing your AWS resources is made easier with Recycle Bin retention rules. You gain control over the fate of your deleted resources, ensuring they are safely stored before permanent deletion. Follow this guide, and you'll be on your way to a more organized and secure AWS environment.

Recover Snapshot from Recycle Bin

Step-by-Step Guide:

  1. Accessing the Recycle Bin Console:

  2. Navigating to the Recycle Bin:

    • In the navigation pane on the left, click on "Recycle Bin."
  3. Locating Snapshots:

    • The grid on this page shows all snapshots currently in the Recycle Bin. Find the snapshot you want to restore.

  4. Initiating the Restore Process:

    • Select the snapshot you wish to recover.

    • Click "Recover" to start the restoration process.

    • When prompted, confirm by clicking "Recover" again.

  5. Congratulations, you have successfully restored a snapshot from the Recycle Bin using the console!

Copy Snapshot from One Region to Another

Copy Snapshot Cross Region/Account

Amazon EBS lets you create snapshots of your volumes, capturing a moment in time for your data. These snapshots are securely stored in Amazon S3. Once a snapshot is complete, you can copy it to another AWS Region or within the same Region. During this process, Amazon S3 ensures data security with server-side encryption.

Key Points:

  1. Unique ID:

    • Every copied snapshot gets a unique ID, different from the original.
  2. Copying Multi-Volume Snapshots:

    • Identify them using applied tags and copy each snapshot individually.
  3. Adjust Snapshot Permissions:

    • To let another account copy your snapshot, adjust the permissions or make it public.
  4. Use Cases:

    • Launch applications in a new AWS Region, move them for better availability and reduced costs, and safeguard data across regions for disaster recovery.

Considerations to Keep in Mind:

  1. Concurrent Copy Requests:

    • A limit of 20 concurrent snapshot copy requests per destination Region.
  2. Tags:

    • Source snapshot tags aren't automatically copied. Add tags during or after the copy.
  3. Volume IDs:

    • Snapshots created during copy operations have arbitrary volume IDs (e.g., vol-ffff).
  4. Permissions:

    • Permissions specified for the copy apply only to the new snapshot.

Guide to Copying a Snapshot:

  1. Open the Amazon EC2 Console:

  2. Navigate to Snapshots:

    • Select "Snapshots" in the navigation pane.
  3. Pick and Copy Snapshot:

    • Choose the snapshot you want to copy, go to "Actions," and select "Copy snapshot."

  4. Enter Description:

    • Provide a brief description for the snapshot copy.
  5. Specify Region:

    • Choose the region where you want to create the snapshot copy.
  6. Determine Encryption:

    • If the source snapshot is encrypted or your account defaults to encryption, the copy is automatically encrypted.

    • For unencrypted source snapshots, you can choose to encrypt the copy and select the KMS key.

  7. Initiate Copy:

    • Click "Copy snapshot" to start the process.

      Now we will check in the specified region to see if the snapshot has been copied.

By following these steps, you can efficiently manage and secure your AWS snapshots, ensuring data safety and availability across regions.

AWS EBS Encryption

Encrypting an Amazon Elastic Block Store (EBS) volume has several key points to consider:

  1. Encryption of Data in Transit: When you enable encryption for an EBS volume, all data moving between the volume and the instance is encrypted, keeping it secure during transfer.

  2. Encryption at Rest: This ensures that the data stored on the EBS volume is encrypted, including data blocks and any snapshots created from the volume.

  3. KMS Key Usage: EBS volume encryption uses AWS Key Management Service (KMS) keys. You can use the default AWS managed key for EBS or specify a customer-managed key (CMK) in AWS KMS.

  4. Impact on Snapshots: If you create a snapshot of an encrypted EBS volume, the snapshot is also encrypted. Launching an instance from an encrypted snapshot results in encrypted EBS volumes.

  5. Performance Considerations: Encrypting and decrypting data introduces some overhead, though modern hardware and AWS infrastructure minimize this impact. Consider this for performance-sensitive workloads.

  6. Changing Encryption Status: Once an EBS volume is encrypted, you can't change its encryption status. Similarly, you can't modify the encryption status of an existing snapshot. To change encryption status, create a new encrypted volume or snapshot.

  7. Sharing Encrypted Snapshots: If you share an encrypted snapshot with another AWS account, they must have permissions to use the KMS key associated with the snapshot.

  8. Limitations on Snapshot Copying: When copying an unencrypted snapshot, you can choose to encrypt the copy. Copying an encrypted snapshot will always be encrypted, and you can't create an unencrypted copy.

Amazon EC2 Snapshot Deletion

To delete a snapshot using the console:

  1. Open the Amazon EC2 console.

  2. In the navigation pane, click on "Snapshots."

  3. Choose the snapshot you want to delete.

  4. Click on "Actions" and select "Delete snapshot."

  5. Confirm the deletion by selecting "Delete."

Fast Snapshot Restore (FSR)

Amazon EBS fast snapshot restore (FSR) lets you quickly create a fully initialized volume from a snapshot, with no delay when accessing data for the first time. Volumes created with FSR provide full performance instantly.

Using FSR:

  1. Enable FSR for Snapshots: Choose specific snapshots in specific Availability Zones. Each snapshot and Zone pair is one FSR. Volumes created from these snapshots in the enabled Zones use FSR.

  2. Explicitly Enable FSR: Turn it on for each snapshot individually. Creating a new snapshot from an FSR-enabled volume doesn't automatically enable FSR for the new snapshot.

  3. Volume Creation Credits: The number of volumes benefiting from FSR is determined by credits, depending on the snapshot's size. Use CloudWatch metrics to monitor credit usage.

Considerations:

  • FSR doesn't work with AWS Outposts, Local Zones, and Wavelength Zones.

  • It can be enabled for snapshots up to 16 TiB in size.

  • Volumes with performance up to 64,000 IOPS and 1,000 MiB/s receive full FSR benefits.

Managing FSR:

  • Enable or disable FSR for your snapshots. Billing applies to each minute FSR is enabled in a specific Availability Zone.

  • Deleting a snapshot turns off FSR for that snapshot in your account.

Monitoring:

  • Use CloudWatch metrics to check credit bucket size and available credits.

  • Snapshot States: Snapshots go through states like enabling, optimizing, enabled, disabling, and disabled during FSR processes.

  • Viewing Restored Volumes: Use describe-volumes to see volumes created with FSR. The FastRestored field indicates if FSR was used.

Quotas:

  • Up to 5 snapshots per region can have FSR enabled. The quota includes both owned and shared snapshots.

In Summary

FSR is a powerful tool for quickly creating high-performance volumes from snapshots, but it's essential to manage credits, monitor usage, and be mindful of quotas and billing.

More from this blog

DevOps journey

34 posts

In this DevOps journey, we’ll explore a range of DevOps tools and related projects.