An Overview & Hands-On for EBS Snapshots.
Focus,
- Tailored for DevOps.
Breakdown:
- Intro,
- Key Features and How EBS Snapshots Work,
- Common Use Cases,
- Considerations,
- Key Benefits of EBS Snapshots,
- Reasos to detach EBS volume before creating Snapshots (NOT necessary BUT still recommended)
- Architecture of EBS Snapashot
- Best Practices & Summary table of best Practices,
- Cross-Region Snapshots Copy,
- Cross-Account Snapshot Sharing,
- Restore Snapshot to Volume in Target Region/Account,
- How to Handles Encryption for Snapshots,
- How to enable a retention rule before deleting snapshots,
- How to recover deleted volume snapshots from bin (UI & CLI),
- Tips to mitigate Accidental Deletion of Snapshot,
- Quick Overview of AWS Snapshots Tpyes,
- Project: Hands-On,
- twtech Final thoughts.
- EBS snapshots are incremental, point-in-time backups of Amazon Elastic Block Store (EBS) volumes, used for data protection, disaster recovery, and data migration within the AWS cloud. The snapshots are stored securely in Amazon S3 for high durability and availability.
- An EBS Snapshot is a point-in-time backup of an Amazon Elastic Block Store (EBS) volume. Snapshots are stored in Amazon S3 (although not directly accessible from S3), and they are used to back up data or create new EBS volumes.
- Snapshots are incremental—only the blocks that have changed since the last snapshot are saved, making them storage-efficient.
- The first snapshot is a full copy of all data blocks written to the volume.
- Subsequent snapshots only save the blocks that have changed since the previous snapshot, making them cost-effective and efficient for regular backups.
- Although stored in Amazon S3, users cannot access the underlying S3 buckets directly via the S3 console or API; management is done through the EC2 console or APIs.
- A snapshot contains all the information needed to restore a volume to its state at the moment the snapshot was taken.
- When a new volume is created from a snapshot, data is "lazily loaded" in the background, meaning the volume is available almost immediately, but performance may be impacted for uninitialized blocks until all data is transferred.
- Snapshots automatically inherit the encryption status of their source volume. Encrypted snapshots use AWS Key Management Service (KMS) for key management, ensuring data security at rest.
- The creation, retention, and deletion of snapshots can be automated using AWS Data Lifecycle Manager (DLM) or AWS Backup, which helps enforce backup policies and manage costs.
- Snapshots can be copied across Availability Zones and AWS Regions, providing a robust solution for cross-regional disaster recovery.
- They facilitate easy migration of data across different regions, accounts, or even from on-premises environments to AWS.
- Snapshots allow developers to create copies of production environments for testing without affecting the live system.
- Backup and Restore
- Dev/Test Environment Cloning
- Volume Migration Across AZs or Regions
- Compliance and Audit Readiness
- Data Recovery in CI/CD Pipelines
- Not necessary to detach volume to do snapshot, but recommended.
Application Consistency:
- By default, snapshots are crash-consistent, meaning they capture the disk state at a point in time, which may not include data cached in memory by applications.
- For database-intensive applications, AWS recommends pausing writes, unmounting the volume, or using application-consistent snapshots via AWS Systems Manager (SSM) agent integration to ensure data integrity.
- While incremental backups are cost-effective, accumulating numerous snapshots over time can increase costs.
- Implementing retention policies and using the EBS Snapshot Archive tier for long-term, seldom-accessed data can help optimize expenses.
Architecture of EBS Snapashots.
Key Benefits of EBS Snapshots
Data
Backup and Disaster Recovery
- Protects data against accidental deletion, corruption, or failure.
- Can be used to restore EBS volumes quickly in the same or different Availability Zones or regions.
Incremental
Backup
- After the first full snapshot, only changed
blocks are saved.
- This reduces storage cost and backup time.
Fast
Volume Creation
- twtech can launch a new EBS volume from a
snapshot in minutes, enabling fast scaling and deployment.
Cross-Region
and Cross-Account Copy
- Snapshots can be copied to other AWS regions
or shared across AWS accounts.
- Helps with geo-redundancy, compliance, and
cross-account workflows.
Automation
with Lifecycle Policies
- Use Amazon Data Lifecycle Manager (DLM) to
automate snapshot creation, retention, and deletion.
- Simplifies management and ensures compliance
with backup policies.
Cost-Efficient
- Because they're incremental, snapshots are
more storage-efficient than full disk clones.
Supports
Encryption
- Snapshots of encrypted volumes are
encrypted.
- twtech can also copy unencrypted snapshots to create encrypted versions, helping with data security and compliance.
Recommended
Because:
Although technically allowed, detaching the volume (or freezing I/O) is recommended for data consistency,
especially for:
File
Systems and Databases
- If twtech snapshot a volume while a database or
file system is writing data, it may end up with inconsistent or corrupted data (e.g.,
incomplete transactions, unflushed file system buffers).
- Think of it like pulling a hard drive out of a computer while it's still writing.
- The blocks might be consistent, but
logical files or databases might not be accessible.
Not Necessary Because:
Amazon EBS supports online snapshots—twtech can take a snapshot of a volume while it is attached and in use.
This is possible because:
- The snapshot captures a point-in-time copy of the data blocks.
- AWS ensures crash-consistent snapshots at the block level.
- This means it captures the data as it exists at that moment—even if the volume is actively being written to.
Best Practices:
- Flush
I/O buffers (e.g., use
fsfreezeon Linux orsync). - Stop
services or pause
the application briefly before snapshotting.
- (Optional) detach the volume to ensure no writes occur at all during snapshot.
Summary table of best Practices
|
Action |
Consistency Level |
Recommended When |
|
Snapshot attached, active volume |
Crash-consistent only |
Low-write workloads, non-critical data |
|
Snapshot after flushing buffers |
Application-consistent |
Most workloads |
|
Snapshot after detaching volume |
Fully consistent |
Critical data, databases, compliance-sensitive backups |
No comments:
Post a Comment