How to make a daily back up of my ec2 instance?

Amazon S3Amazon Ec2Amazon Web-ServicesAmazon Ebs

Amazon S3 Problem Overview


I have a community AMI based Linux EC2 instance in AWS. Now I want to take a daily back up of my instance, and upload that image in to S3.

Is that the correct way of doing the back up of my EC2 instance? Can anybody help me to point out the correct method for taking back up of my EC2 instance?

Amazon S3 Solutions


Solution 1 - Amazon S3

Hopefully your instance is EBS backed.

If so, you can backup your instance by taking an EBS Snapshot. That can be done through aws.amazon.com (manually), using AWS Command Line Tools (which can be automated and scheduled in cron or Windows Task Scheduler as appropriate) or through the AWS API.

You want to ensure that no changes are made to the state of the database backup files during the snapshot process. When I used this strategy for MySQL running on Ubuntu, I used a script to ensure a consistent snapshot. That script uses a feature of the XFS file system to freeze the filesystem during the snapshot. In that deployment, the snapshot only took 2-3 seconds and was performed at a very off-peak time. Any website visitors would experience a 2-3 second lag. For Windows, if the device can not be rebooted for the snapshot (you have no maintenance window at night), I would instead create a separate EBS device (e.g. a "S:" device for snapshots), use SQL Server backup tools to create a .bak file on that other device, then create an EBS snapshot of that separate EBS device.

For details on scripting the backup, see this related question:

https://stackoverflow.com/questions/1320994/automating-amazon-ebs-snapshots-anyone-have-a-good-script-or-solution-for-this-o

If you have separate storage mounted e.g. for your database, be sure you back that up too!

UPDATE

To create a snapshot manually,

To create an AMI image from the instance and lauch other instances just like it (in instances with more resources or to balance load, etc.):

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionhackerView Question on Stackoverflow
Solution 1 - Amazon S3Eric J.View Answer on Stackoverflow