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

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?


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:

Automating Amazon EBS snapshots anyone have a good script or solution for this on linux

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

UPDATE

To create a snapshot manually,

  • Browse to https://console.aws.amazon.com/ec2/home?#s=Volumes
  • Right-click on the volume you want to backup (the instance the volume is attached to is in the column named 'Attachment Information')
  • Select Create Snapshot

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.):

  • Browse to https://console.aws.amazon.com/ec2/home?#s=Instances
  • Right-click on the instance you want to create the AMI from
  • Select Create Image (EBS AMI)