简体   繁体   中英

How to take a backup of EC2 instance in AWS and move to a low cost alternative?

We have an EC2 instance running in AWS EC2 instance. We have our ML algorithms and data that. We have also hosted a web-based interface also in that machine.

Now there are no new developments happening in that EC2 instance. We would like to terminate AWS subscription for a short period of time (for the purpose of cost-reduction and exploring new cloud services). Most importantly, we want to be in a position where we can purchase a new EC2 instance with a fresh AWS subscription, use the backup which we take now, and resume all operations (web-backend, SMS services for our app which is hosted in AWS, etc.).

What is the best way to do it? Is temporary termination of AWS subscription advisable?

There is no concept of an "AWS Subscription". AWS is charged on-demand, which means you only pay when you use resources.

If you temporarily do not want the Amazon EC2 instance, you could:

  • Stop the instance, which is like turning off the power. You will not be charged for the instance, but you will still pay for the disk storage attached to the instance. You can simply Start the instance again when you wish to use it. You will only be charged while the instance is running. OR
  • Create an image of the instance, then terminate the instance. This will create an Amazon Machine Image (AMI), which contains a copy of the disks. You can then launch a new Amazon EC2 instance from the AMI when you wish to use it again. This is a lower-cost option compared to simply stopping the instance, but it takes more effort to stop/start.

It is quite common for companies to stop Amazon EC2 instances at night or over the weekend to reduce costs while they are not needed.

EDIT: Just thought of a third option. Will test it and be back. Not worth it; it would involve creating an image from the EC2 instance and then convert that image to a VM image, storing the VM image in S3. There may be some advantages to this, but I do not see them.

I think you have two options, both of them very reasonably priced . If you can separate the data from the operating system, then your best option would be to use an S3 bucket as a file system within the EC2 instance. Your EC2 instance would use this bucket to store all your "ML algorithms and data" and, possibly, even your "web-based interface". Whenever you decide that you no longer need the processing capacity of the EC2, you would unmount the S3 bucket file system from the EC2 instance and terminate that instance. After configuring an appropriate lifecycle rule for the S3 bucket, it would transition to Glacier, or even Glacier Deep Archive [you must considerer the different options of long term storage]. In the future, whenever you want to work with your data again, you would move your data from Glacier back to S3, create a new EC2 instance, install your applications, mount your S3 bucket as a file system and you would have access to all your data. I think this is your least expensive and shortest recovery time objective option. To implement this option, look at my answer to this question ; everything you need to use an S3 bucket as a regular folder inside the EC2 instance is there.

The second option provides an integrated solution, meaning the operating system and the data stay together, and allows you to restore everything as it was the day you stopped processing your data. It's made up of the following cycle:

  1. Shutdown your EC2 and make a note of all the specs [you need them further down].
  2. Export your instance to a virtual image, vmdk for example, and store it in your S3 bucket. Something like this:

aws ec2 create-instance-export-task --instance-id i-0d54b0682aa3998a0 --target-environment vmware --export-to-s3-task DiskImageFormat=VMDK,ContainerFormat=ova,S3Bucket=sm-vm-backup,S3Prefix=vms

  1. Configure an appropriate lifecycle rule for the S3 bucket so that it transitions to Glacier, or even Glacier Deep Archive.
  2. Terminate the EC2 instance.
  3. In the future you will need to implement the inverse, so you will need to restore the archived S3 Object [make sure you you can live with the time needed by AWS to do this]
  4. Import the virtual image as an EC2 AMI, something like this [this is not complete - you will need some more options that you saved above]:

aws ec2 import-image --disk-containers Format=ova,UserBucket="{S3Bucket=sm-vm-backup,S3Key=vmsexport-i-0a1c382e740f8b0ee.ova}"

  1. Create an EC2 instance based on the image and you're back in business.

Obviously you should do some trial runs and even automate the entire process if it's something that will be done frequently. I have a feeling, based on what you said, that the first option is a better option, provided you can easily install whatever applications they use.

I'm assuming that you launched an EC2 instance from a base Amazon Machine Image and then added your own software and models to it. As opposed to launched an EC2 instance from an AWS Marketplace offering.

The simplest thing to do is to create an Amazon Machine Image (AMI) from your running EC2 instance. That will capture the current state of the instance and persist it in your AWS account. Then you can terminate the instance. Later, when you want to recreate it, launch a new instance, selecting the saved AMI instead of a standard AMI.

An alternative is to avoid the need to capture machine state at all, by using standard DevOps practices to revision-control everything you need to recreate the state of a running machine.

Note that there are costs associated with an AMI, though they are minimal ($0.05 per GB-month of data stored, for example).

I had contacted AWS customer care regarding this issue. Given below is the response I received. Please add your comments on which option might be good for me.

Note: I acknowledge the AWS customer care team for their help.

I understand that you require some information on cost saving for your Instance since you will not be utilizing the service for a while.

To assist you with this I would recommend checking out the Instance Stop/Start link here: ==> https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Stop_Start.html .

When you stop an Instance, you do not lose any data & you are not charged for the resources any further. However please keep in mind that you will still be charged for any EBS Storage Volumes attached to the stopped Instance(s).

I also recommend checking out the below links on how you can reduce your costs. ==> https://aws.amazon.com/premiumsupport/knowledge-center/reduce-aws-bill/ ==> https://aws.amazon.com/blogs/compute/10-things-you-can-do-today-to-reduce-aws-costs/

That being said, please note that as I am in the billing department, for the best assistance with the various plans you will require the assistance of our Sales Team.

The Sales Team will be able to assist with ways to save while maintaining your configurations.

You will be able to reach the Sales Team here: ==> https://aws.amazon.com/websites/contact-us/ .

Once you have completed the details in the link, a member of the team will be in touch with you at their soonest.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM