23

I want to backup a Linux-based EC2 instance while it is running with no downtime, and then later on launch a new instance. (The instance is running a web server and Postgres database.)

I found there are two ways to do this, but I am confused on what's the difference in the outcome between them.

Option #1: Create an AMI straight from a running instance:

  1. Create a new AMI straight from the running original instance.
  2. Launch a new instance from the AMI

Option #2: Manually create an AMI from a snapshot:

  1. Take a snapshot from the volume attached to the running original instance
  2. Create AMI from the snapshot, manually entering details like architecture and kernel ID
  3. Launch a new instance from the manually created image

Now what's confusing is that when creating an AMI straight from an instance, EC2 would reboot the instance by default. There's a checkbox "No reboot" with the following tooltip:

When enabled, Amazon EC2 does not shut down the instance before creating the image. When this option is used, file system integrity on the created image cannot be guaranteed.

Is there really a difference in the outcome of these two ways options? To me it feels like I am manually doing the same things that the automated wizard would do anyway. It generates snapshots, selects the kernel IDs and architectures.

Why one has a warning text and the other does not? Snapshotting a running instance is considered relatively safe, and if the AMI creation does a snapshot in the background, is it any more dangerous than doing it all by hand?

Vilsepi
  • 333
  • 1
  • 2
  • 7

1 Answers1

14

They do exactly the same if you select the no reboot option when creating the AMI directly from EC2. This basically creates a snapshot that can potentially be in a inconsistent state. For example, you are risking more having an inconsistent state if you are doing a lot of disk writes when creating the snapshot.

If you want to create a snapshot in a "consistent" state you would have to shutdown your instance first and then take a snapshot and then restart your instance. This is why the AMI creation option from EC2 is pretty useful because you don't have to stop and restart. Amazon takes care of it and also the IP address doesn't change on your instance. (If you stop/restart your instance your IP address actually changes)

I'm not really sure why Amazon doesn't have a warning if you take a snapshot directly from the volume but from the volume point of view it really doesn't matter whether the volume is being used by a running or non running instance (it only cares whether it's attach or detatch to no effect on creating snapshots)

Rico
  • 2,185
  • 18
  • 19
  • I agree that you should create AMIs since you don't want to shut down the instance. You can look into solutions who do this out of the box to save time. I personally use https://totalcloud.io to automate my actions on AWS. – Veer Abheek Singh Manhas Jun 12 '19 at 11:36