A Complete Guide to EC2 Instance Backup: AWS Snapshots vs. AMIs

Amazon Web Services (AWS) provides two native options that can be used to back up AWS EC2 instances – AWS EBS Snapshots and Amazon Machine Images (AMIs). This blog post explains the differences between these two approaches to backup and explains when each method is optimal.

NAKIVO for AWS EC2 Backup

NAKIVO for AWS EC2 Backup

Backup of Amazon EC2 instances to EC2, AWS S3 and onsite. Anti-ransomware options. Fast recovery of instances and application objects.

Understanding EC2 Backup Options

Let’s go over the two native AWS tools used to backup EC2 instances to better understand their differences.

AWS EBS Snapshots

AWS EBS snapshots are point-in-time copies of EBS volumes and may be viewed as EBS volume backups. EBS snapshots are stored in Amazon S3, but they are not directly accessible in Amazon S3 buckets and can only be used to create new EBS volumes. The first snapshot is a full data copy and each subsequent snapshot is stored incrementally to write only data changes since the previous snapshot. The incremental approach reduces storage space consumption and decreases costs.

EBS snapshots can be used to restore only EBS volumes for EC2 instances. You need to follow manual procedures to restore a full instance, including the instance configuration, boot settings, network configuration, etc.

Read how to configure AWS EC2 snapshots for AWS EC2 instance backup.

Amazon Machine Images (AMIs)

Amazon Machine Images (AMIs) are pre-configured images that contain not only data from EC2 EBS volumes but also other data required to fully restore or create new EC2 instances. AMIs are used as full backups of the entire instance and can be used to perform a full recovery of an AWS EC2 instance. AMIs include EBS volumes with the root volume, an operating system, instance configuration and metadata (that is, everything you need for full instance recovery).

AMIs are stored in Amazon S3 and can be reused across different instances, regions or even accounts. You can create custom Amazon Machine Images using your existing EC2 instance. AMIs are ideal for creating “gold images” to deploy multiple identical EC2 instances.

AWS Snapshot vs. AMI: Key Differences

AWS EC2 EBS snapshots and Amazon Machine Images differ in terms of use cases, purpose and functionality. These are the primary factors behind the differences between AWS snapshots and AMIs.

  • While snapshots capture data only on the EBS volume level, AMIs capture all the data of AWS EC2 instances. For example, if a database is located on an EBS volume, a snapshot can contain this volume with the database. An AMI, on the other hand, contains all attached volumes with the operating system, application data, files and instance configuration. Snapshots don’t capture EC2 instance configuration.
  • AMIs are always full instance backups (with the full backup type), which include everything needed to recreate the instance. EBS snapshots are incremental, meaning only the changes since the last snapshot are saved.
  • EBS snapshots are used to create or restore volumes for existing EC2 instances while AMIs are used to launch new EC2 instances for pre-configured environments.
  • EBS snapshots are used for data backup and recovery of EBS volumes and EC2 instances (with manual instance configuration). Amazon Machine Images are used to duplicate environments and pre-configured deployments.

Below, you can see the table comparing the main aspects of EBS snapshots and Amazon Machine Images.

Definition

Feature AWS EBS Snapshots Amazon Machine Images (AMIs)
Purpose Point-in-time backup of an EBS volume’s data A complete image of an EC2 instance (OS, data, config.)
Scope Captures only the EBS volume (data layer) Captures the entire instance, including OS, data and configurations

Functionality

Feature AWS EBS Snapshots Amazon Machine Images (AMIs)
Contents Only the data on a single EBS volume Includes OS, installed software, data and attached volumes
Incremental backup Supports incremental backups after the first snapshot Does not support incremental backups (full image every time)
Configuration Does not include instance-level configurations Includes instance-level configurations like instance type, network and permissions
Portability Can be copied to another region Can be copied to another region
Network transfer Requires data transfer only for changed blocks Transfers the full instance image

Usage

Feature AWS EBS Snapshots Amazon Machine Images (AMIs)
Primary use case Backup or restore EBS volumes Create pre-configured templates for launching EC2 instances
Granularity Volume-specific backups (for example, database volume) Entire instance-level backups (for example, app server)
Disaster recovery Restore individual volumes Launch pre-configured instances in a failover region
Testing Test data-only backups Duplicate environments with full configurations

Cost

AWS EBS Snapshots Amazon Machine Images (AMIs)
Cost basis Storage cost based on snapshot size (incremental) Storage cost for the AMI and associated snapshots
Cost efficiency More cost-efficient for frequent, incremental backups Higher cost as it includes instance configuration

Recovery Options

Feature AWS EBS Snapshots AMIs
Recovery target Creates a new EBS volume from the snapshot Launches a new EC2 instance based on the AMI
Granularity of recovery Can restore individual volumes Restores the full instance, including attached volumes

Automation

Feature AWS EBS Snapshots AMIs
Automation tools Can be automated using AWS Backup or lifecycle rules Can be automated using scripts, AWS CLI or tools like AWS Lambda
Frequency Suitable for frequent, incremental backups Typically used for periodic or pre-deployment backups

When to Use AWS Snapshots or AMIs?

The choice between AWS Snapshots and Amazon Machine Images (AMIs) depends on your specific use case and the level of data or instance backup you require. We’ve covered the differences between AWS EC2 snapshots and Amazon Machine Images in the previous section; now let’s look at their main use cases.

Use cases of EBS snapshots:

  • Snapshots are ideal for volume-level backups, with a focus on the data stored in EBS volumes and disaster recovery purposes by restoring EBS volumes.
  • Copying snapshots to another region for disaster recovery purposes.
  • Testing by duplicating EBS volumes using snapshots without impacting the original instance .
  • EBS snapshots are effective in terms of scalability – when you run parallel creation of a high number of AMIs, issues and failures can occur.

Use cases of Amazon Machine Images:

  • Creating backups of the entire EC2 instance, including operating system, application data and other files.
  • Launching identical EC2 instances in AWS to scale workloads by deploying multiple instances with the same configuration. This is the optimal approach before running massive updates or implementing configuration changes to the instances. This can be useful in load-balancing scenarios.
  • Creating templates for deploying EC2 instances using the pre-configured environments.
  • Migration of EC2 instances to another AWS region on the account by creating AMIs and deploying new instances from these images.

In the table below, you can find the common scenarios and recommendations for choosing the right native AWS feature to use for backup purposes.

Scenario Use AWS Snapshots Use AMIs
Backup of specific EBS volumes (data only) Yes No
Full EC2 instance backup (OS + data) No Yes
Frequent incremental backups Yes No
Scaling with identical instances No Yes
Disaster recovery for individual volumes Yes No
Disaster recovery for the entire instance No Yes
Cross-region replication of EBS volumes Yes No
Cross-region or cross-account instance migration No Yes
Pre-configured instance templates No Yes
Cost-efficient frequent backups Yes No

Choosing the right option depends on the level of backup granularity and recovery speed you need:

  • Use AWS snapshots for data-only, volume-specific backups and for cost-efficient frequent backups.
  • Use AMIs for full instance backups, scaling identical environments and disaster recovery, which requires entire instance restoration.

Sometimes, EBS snapshots and AMIs can be used together. Below are examples of how these two features can be combined:

  • Creating regular data backups + full instance backups:
    • Use snapshots for frequent backups of critical data volumes (for example, database storage).
    • Use AMIs periodically to back up the entire instance, including its configuration and applications.
  • AWS disaster recovery:
    • Combine AMIs for full instance recovery and snapshots for granular volume restoration.
    • Snapshots allow the recovery of specific volumes, while AMIs can recreate the entire instance.
  • Testing and development:
    • Use AMIs to create full replicas of production environments for testing.
    • Use snapshots to duplicate only the data layer for focused development tasks.

Best Practices for EC2 Instance Backup

By using EBS snapshots for data and AMIs for full instance configuration, you can implement a robust backup and disaster recovery strategy for your AWS EC2 instances. Below you can see the best practices for EC2 instance backup.

  • Choose the right backup method. Snapshots for data backup and AMIs for full instance backup.
  • Automate backups. Use AWS Backup or custom scripts to automate snapshot and AMI creation.
  • Monitor and manage costs. Regularly review and delete outdated snapshots or AMIs to minimize storage costs.
  • Implement retention policies. Define retention periods for snapshots and AMIs to avoid excessive storage costs. Use lifecycle policies to automatically delete outdated backups after a set period. Retain critical backups for longer durations (e.g., quarterly backups for compliance).
  • Ensure backup consistency. For applications like databases, ensure application consistency during backup. Pause writes or use application-specific APIs (e.g., MySQL’s FLUSH TABLES WITH READ LOCK). Use AWS Application Consistent Snapshots for database volumes.
  • Secure backups by encrypting snapshots and AMIs. Use AWS Key Management Service (KMS) to encrypt backups. Enable encryption for enhanced data security.
  • Test recovery workflows. Periodically test restoring from snapshots and launching instances from AMIs to ensure that recovery processes work correctly (as expected). Disaster recovery testing allows you to ensure that data can be restored in case of failure.
  • Deploy a dedicated backup solution for AWS backup. A professional data protection solution, like NAKIVO Backup & Replication, that supports AWS EC2 backup can make your backup and recovery processes more effective and seamless.

Simplified EC2 Backup with NAKIVO

NAKIVO Backup & Replication supports AWS EC2 backup to Amazon S3 and other cloud storage and local storage. The NAKIVO solution supports AWS EC2 backup automation, backup encryption, backup verification, disaster recovery testing, application-aware backup, backup immutability and numerous other features. The NAKIVO solution creates full and incremental backups of the entire EC2 instances, including EBS volumes and instance configuration with metadata to make recovery fast and convenient. You can simplify AWS EC2 backup and improve your disaster recovery strategy.

Before we start creating a backup job for AWS EC2, let’s review the prerequisites.

AWS EC2 backup configuration in the NAKIVO solution requires adding an AWS account to the inventory. You can do this in Settings > Inventory by clicking the + (plus) button and following the instructions.

The AWS account is added to the inventory

The second prerequisite is deploying a NAKIVO Transporter in AWS for data processing when running backup and recovery jobs. Go to Settings > Nodes, click the + button to add a new Transporter in AWS.

The Transporter is deployed in AWS

Configuring a new AWS backup job is straightforward in NAKIVO Backup & Replication and can be done in a few clicks.

  1. Go to Data Protection, click + and hit Backup for Amazon EC2.

    Creating a new job for EC2 instance backup

  2. Select the AWS EC2 instances that you want to back up. If you have not deployed the Transporter in AWS earlier, you will see the message that a Transporter is required. Once done, click Proceed to allow NAKIVO Backup & Replication to deploy the Transporter as an EC2 instance in the appropriate AWS region automatically. Then click Next.

    Selecting AWS EC2 instances to back up

  3. Select the destination location to store AWS EC2 backups. You can select any supported backup repository added to the NAKIVO inventory. In this example, we have a local backup repository and a backup repository in Amazon S3.

    Selecting a backup repository

  4. Configure scheduling and retention settings for an Amazon EC2 backup job. You can configure multiple rules to implement complex scheduling and retention schemes. Enable backup immutability to ensure ransomware protection.

    Configure scheduling and retention settings

  5. Configure backup job options. Enter a job name and specify the application-aware mode, change tracking method, encryption, full backup mode and other settings. Click Finish & Run to save the settings and run the job.

    Configuring job options for EC2 instance backup

Conclusion

EBS snapshots are optimal for backing up EBS volumes frequently and with storage-saving options because new snapshots are incremental. To restore the entire EC2 instance from an EBS snapshot, you need to create and configure an EC2 instance manually or use an existing EC2 instance to restore EBS volumes. Amazon Machine Images (AMIs) are used to create a full image of an EC2 instance (including EBS volumes, boot options, instance configuration, metadata, etc.) to perform full recovery of instances, mass deployment of instances with identical configuration and migration.

Consider using a dedicated Amazon EC2 backup solution that combines the functionalities of the native backup features of EBS snapshots and AMIs with a long list of advanced backup features and options. NAKIVO Backup & Replication supports full and incremental backups of the entire EC2 instances with high reliability and a convenient user interface. This combines the advantages of native methods with a wide set of customizable features that improve data protection efficiency.

Try NAKIVO Backup & Replication

Try NAKIVO Backup & Replication

Get a free trial to explore all the solution’s data protection capabilities. 15 days for free. Zero feature or capacity limitations. No credit card required.

People also read