Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Elastic Beanstalk Backup & Recovery

I am new to AWS EB and I am trying to figure out how to backup and restore an entire EB environment. I created an AMI based on the EC2 instance generated by EB, and took a snapshot of RDS, also created by EB.

The problem I have is, how do I restore it, assuming that this is the correct approach of backup. Also, I am doing it manually, shouldn't there be an automated way of doing this within EB? By the way, when I created the AMI, it destroyed the source and the EB just created a new EC2 instance without all my changes.

How do I save & restore configuration changes to my application that impact both filesystem and database?

like image 782
Rene111 Avatar asked Jun 04 '14 22:06

Rene111


People also ask

What does rebuild environment do in Elastic Beanstalk?

Rebuilding an environment terminates all of its resources and replaces them with new resources with the same configuration. You can also rebuild terminated environments within six weeks (42 days) of their termination.

Is Elastic Beanstalk free in AWS?

There is no additional charge for AWS Elastic Beanstalk. You pay for AWS resources (e.g. EC2 instances or S3 buckets) you create to store and run your application. You only pay for what you use, as you use it; there are no minimum fees and no upfront commitments.

What is Elastic Beanstalk vs EC2?

Elastic Beanstalk is one layer of abstraction away from the EC2 layer. Elastic Beanstalk will setup an "environment" for you that can contain a number of EC2 instances, an optional database, as well as a few other AWS components such as a Elastic Load Balancer, Auto-Scaling Group, Security Group.


2 Answers

Unfortunately, Amazon AWS Elastic Beanstalk (EB) does not support restoring databases that contain live data, if those databases were created with EB. If you reload (AKA AWS "deploy") the EB saved configuration, you get a blank database!

I called them and they told me to create the RDS DB separately and update the application code to connect to the DB once you know it's name. If you restore the RDS DB it will have a new name too! So you have to update your code again to connect to it.

Also, if you code and environment is fine, but you want to restore your database, again it will have a new name and you will need to change your code.

How to change your code easily and automatically deploy it is a whole other question for which I don't have an answer yet.

So basically the RDS DB provisioning within Elastic Beanstalk has very limited uses, maybe coding and debugging and testing, but not live production use. :(

This is as of Jan 2015.

like image 93
Grant Rostig Avatar answered Nov 04 '22 02:11

Grant Rostig


First go into your EB environment and save the current config. You should go to a running EC2 instance created by EB and make an Image. Then use that new AMI ID by going to the EB configuration and setting it. It will rebuild the environment tearing down all running instances and creating new ones.

For your RDS instance you should make a backup and restore with a new instance name as the docs say you will lose it if the environment is destroyed. You should probably just manually set the environment variables like RDS does and setup the proper security groups between RDS and EC2.

One option I think could work is just renaming the RDS instance name as the environment seems to break and then destroy the environment and create a new one with an attached RDS instance and then destroy that one and rename the old one to the new one's name which may work.

As always make proper backups before proceeding with any of these ideas.

like image 29
dmyers Avatar answered Nov 04 '22 04:11

dmyers