--> -->

How to Use Amazon S3 and EC2 for Backup and Restore

Subscribe banner

Amazon Web Services (AWS) are growing in popularity because companies are generating ever increasing amounts of data every day. Cloud services provide many useful options to store data for data backup and recovery. What is EC2 and S3 in AWS? Amazon EC2 and S3 are among the most popular cloud services offered by Amazon given their high reliability and availability for cloud storage. This blog post explains how Amazon EC2 vs S3 can be used for data backup and restore, yet it doesn’t offer a full comparison of these two services.

Why Should You Use AWS for Data Backup?

The 3-2-1 backup rule recommends that you maintain at least three copies of your data, one of which is to be stored offsite. Cloud storage including Amazon S3 and Amazon EBS can be used as offsite storage for backup data. What is EC2 and S3 in AWS? What is Amazon EC2 instance?

Amazon EC2 (Elastic Cloud Computing) instances are virtual machines running in the AWS cloud on AWS servers in AWS data centers. A container to store data is called an EBS (Elastic Block Storage) volume, blocks are used as basic units to store data in EBS volumes. EBS volumes are analogs of virtual disks and are classified as block storage.

Amazon S3 (Simple Storage Service) is the object storage service in AWS. A container used to store data is a bucket. Data is stored in buckets as objects (which are the basic units data storage in buckets), not as blocks. Object-based storage allows the use of versioning, which is useful when recovering data.

Amazon EC2 vs S3 – which one to choose for backup? Let’s explore the two options.

Using EC2 for Backup and Restore

EC2 instances can be used to restore VMs (virtual machines) running on-premises when a disaster strikes. Backups or replicas must be prepared for this type of disaster recovery plan. Migration to the cloud should be performed in this case.

Although you can back up data to EC2 instances, replication to EC2 is preferable. Resuming the operation of your applications and servers using replicas requires less time than using backups. For example, you can replicate databases from on-premises servers or VMs to EC2 instances and perform failover in case of a disaster. If you are interested in Amazon EC2 vs S3 database performance, you should know that performance of databases using EBS volumes of EC2 instances is higher.

EBS volumes that are used by EC2 instances provide high-speed block storage. You can choose between hard disk drives (HDD) and solid-state drives (SSD) used to store EBS volumes. Below are some of the advantages and disadvantages of using EBS volumes for backup and restore.

Advantages: High performance of storage. Data can be copied with high speed from one EBS volume to another. If you need to transfer data from your local (on-premises) servers, internet connection speed is a bottleneck, using S3 may be more rational in this case.

Disadvantages: The high price for storage. With the exception of using EBS volumes for backing up other EBS volumes, EBS can be too expensive as the go-to backup destination.

How to Back up EC2 Instances?

Amazon EC2 instances and EBS volumes are not backed up automatically in the Amazon cloud for disaster recovery purposes. Data is only replicated across servers in Amazon data centers for data center redundancy to provide availability in a case of disk or server failure (hardware failure).

EBS snapshot-based protection is an easy way to create a recovery point for EBS volumes. Snapshots can be used to restore data to new EBS volumes. EBS encryption is supported. Read more about the difference between snapshots and backups in this blog post. If logical volume managers such as LVM or mdadm are used, consider performing backup on the volume manager layer instead of using EBS snapshots to preserve data consistency and coherency of subcomponent volumes. When you restore EBS volumes by using snapshots, these EBS volumes must be mounted to a prepared EC2 instance.

Creating an Amazon Machine Image (AMI) is another method to back up Amazon EC2 instances. AMI is the image that contains an operating system, all configuration settings, and data needed for operation of an EC2 instance. When having an AMI, you can create a new EC2 instance based on this AMI. This approach is used to recover EC2 instances and to clone them. You should stop a running EC2 instance to create a new AMI. The advantage of this method over using EBS volume snapshots is that the entire EC2 instance is restored and not just EBS volumes (which should be mounted to a created EC2 instance manually after restoring). Configuring AMI images as backups requires more efforts but provides a good result when it comes to recovery and scalability.

Backup of EC2 to S3

Copying data stored on EBS volumes to Amazon S3 buckets is an alternative method of data backup for EC2 instances. As Amazon S3 is an object-based storage and Amazon EBS is a block storage, FUSE (filesystem in userspace) is required to read/write files in/to S3 buckets. FUSE can be installed on operating systems running on EC2 instances, virtual machines, and physical computers to access S3 buckets for data backup and restore. Don’t forget about data consistency. Copying files that are in use by applications (such as databases) may cause data corruption.

Is EBS faster than S3? Yes, EBS is faster.

Does EC2 use S3? Yes, EBS snapshots are stored in Amazon S3. However, you cannot access EBS snapshots in the regular interface of Amazon S3.

Using S3 for Backup and Restore

Amazon S3 versioning for stored objects helps you recover files and folders that are stored as objects in S3 buckets. By default, versioning is disabled in Amazon S3 but you can easily enable this useful feature. When versioning is enabled, previous object versions are preserved after writing changes to them. Changes are saved in a new version of the object. Using Amazon S3 for backup and restore has its own advantages and disadvantages.

Advantages: A variety of storage classes for Amazon S3 buckets. Select a faster storage class for more money or slower storage class for less money. Amazon provides a flexible pricing policy for using Amazon S3 storage. S3 is affordable for many users. Read more about Amazon S3 to learn how S3 works.

Disadvantages: Special tools are needed if you don’t want to copy files manually by using the web interface of AWS.

Backup use cases

There are a lot of use cases for using Amazon S3 as a backup destination for:

  • Backups of data stored on EBS volumes. As mentioned above, Amazon S3 can be used to back up EBS volumes used by EC2 instances.
  • Backups of data stored in other S3 buckets.
  • Backups of data stored on physical computers and virtual machines running on-premises.

Tools for S3 backup and restore

Different tools can be used for S3 backup and restore. Configure object versioning for recovery of different versions of objects stored in S3 buckets and review the available tools below.

Command line tools. Back up data from one S3 bucket to another using AWS SDK or specialized tools. Popular command line tools for Linux and Windows such as s3cmd, s4cmd and AWS CLI can be used. Install one of those tools to transfer data to S3 buckets and from S3 buckets. It is possible to copy data between buckets for backup and recovery purposes with these command line tools. Using scripts for backup to S3 is a common approach but requires a lot of effort. This approach is applicable for data backup from S3 buckets, EC2 instances, physical and virtual machines.

Advantages: CLI tools and scripts are available for free.

Disadvantages: You should stop running applications and using features such as volume snapshots inside operating systems to preserve data consistency during a backup process. Backup configuration using scripts is complicated.

AWS Storage Gateway. If virtual machines are running in your on-premises data center, you can use AWS Storage Gateway to transfer data to Amazon S3 buckets.

AWS Storage Gateway is a hybrid storage service that is deployed as a VM and provides caching options for faster access to files. There are three types of AWS Storage Gateway – a file gateway, volume gateway and tape gateway. After deploying the storage gateway, standard sharing protocols, such as SMB, NFS and iSCSI, can be used to access Amazon S3 storage. AWS Storage Gateway is provided as a virtual appliance for VMware vSphere and Hyper-V platforms and can be downloaded for free if you have a subscription plan to use Amazon S3.

Alternative Solutions for Data Backup to AWS

A more efficient and reliable way of protecting your data in AWS is deploying a third-party data protection solution that offers integration with AWS. NAKIVO Backup & Replication is a universal data protection solution that supports AWS backup and recovery. NAKIVO Backup & Replication supports:

EC2 backup. Backup and recovery of entire EC2 instances. You don’t need to create and configure new EC2 instances and mount recovered EBS volumes manually.

EC2 replication. Replicate important EC2 instances in AWS and use EC2 replicas according to your data recovery scenarios and disaster recovery plans providing a high RTO.

Backup to Amazon S3. Backup your VMware and Hyper-V VMs, physical Windows and Linux machines and EC2 instances to Amazon S3 buckets by using a single interface of NAKIVO Backup & Replication. Now backup directly to Amazon S3 buckets is supported without deploying the AWS Storage Gateway. A special Amazon S3 backup repository is created in an S3 bucket.

Backup to EC2. You can deploy the Transporter and create a backup repository on an EC2 instance, configure network connection between your data center and network used by your EC2 instances and back up data to the EC2 instance.

NAKIVO Backup & Replication provides a set of useful features that make configuring backups to AWS faster, more convenient, and reliable. These features include:

Site Recovery allows you to automate and orchestrate disaster recovery workflows for virtual machines and EC2 instances depending on defined conditions and actions. Complex disaster recovery scenarios can be implemented with the Site Recovery feature.

Job scheduling. Backup jobs can be scheduled to run automatically. Flexible retention settings allow you to preserve multiple recovery points for different recovery cases.

Application-aware backup is important for data consistency. NAKIVO Backup & Replication uses features such as VSS (Volume Shadow Copy) on a backed up machine to preserve data consistency when applications (for example, a database server, Active Directory server, etc.) perform write operations to files.


Amazon EC2 vs S3 storage is a popular topic when talking about data backup and recovery. This blog post has covered using Amazon S3 and EC2 for backup and restore and provided an overview of the advantages of each approach. There are some native tools that can be used to back up and recover Amazon EBS volumes, EC2 instances and Amazon S3 objects. Pay attention to backup automation, data consistency and application-aware backups when using native tools. Configuring all these parameters may be complicated when using exclusively AWS tools and features. Download a free trial of NAKIVO Backup & Replication that provides many useful features for cloud backup and try the backup solution in your infrastructure.

AWS EC2 Backup

How to Use Amazon S3 and EC2 for Backup and Restore
Rate this post

Let’s Stay in Touch

Subscribe today to our monthly newsletter
so you never miss out on our offers, news and discounts.