Database – Amazon EC2 + EBS:: Regular backup plan

amazon ec2amazon-ebsbackupdatabasefiles

I have read some articles about amazon ec2 instances and ebs. I found out that, the data on the instance are not persistent, which means, if the hardware fails, instance shut down, I will lost my data. Hence, what is your backup plan for this case?

Q1 How do you backup the necessary files and database (mysql)?

Q2 I created/mounted an EBS volume. What should I do with it? (How big should I assign the Volume, by default, I assigned 1 GB, is it enough? Or is it extensible?)

Q3. Whats the snapshots in EBS? (for backup?)

My OS: Amazon Linux
Using ec2 instance, installed httpd and mysql

Best Answer

EBS volumes are persisted when your instance fails:

"Amazon EBS volumes are off-instance storage that persists independently from the life of an instance." see EBS Information

"Local instance storage" is probably what you're thinking of - and that is lost when the ec2 instance is terminated. I use local instance storage to handle data that can be rebuilt from elsewhere. It can be very handy as a fast cache of data - but you must be able to rebuild it.

Q1: Either use Amazon's RDS service to backup your database regularly and automatically, or run mysqldump on a cron job, compress + encrypt your backup file, and perhaps push it to S3.

Q2: You can snapshot an EBS volume, then create a new volume from the snapshot and specify the storage space (effectively expanding it).

Q3: Snapshots allow you to roll back to a point in time - so before you do potentially breaking upgrades, you could snapshot to ensure you've got a rollback plan. You can snapshot as frequently as your data/service demands.