Possible Duplicate:
What’s the easiest way to back up EC2 instances automatically?
I have an EBS-backed Amazon EC2 instance. I would like to create a daily backup schedule, and keep, say, a week's worth of daily backups, plus a few older images (from 2,3,4 weeks ago). I don't mind creating the backups on the fly, with the snapshot mechanism, but I would like an easy wrapper to manage it for me.
What is the simplest way to set this up? How much would this cost me, for a micro instance?
I'd suggest giving my "ec2-automate-backup" tool a try and running this under cron. You'd run the command as follows
ec2-automate-backup -v your_volumeid -k 7 -p
. The options here tell the tool: which volumes to backup (-v your_volumeid) the number of days you wish to keep backups (-k 7) and to purge old volumes (-p). The tool is freely available and open source.If you need to backup more than one volume, you'd "tag" each volume using AWS Tags and then run as follows
ec2-automate-backup -s tag -t "Backup=your_tag" -k 7 -p
. The options here are: -s tag (-s tag tellsec2-automate-backup
to select volumes for backup by tag) and -t "Backup=your_tag" tellsec2-automate-backup
to backup volumes tagged "your_tag."ec2-automate-backup is part of AWS-Missing-Tools, available at http://awsmissingtools.com
I have all my application code, db, configuration and log files sitting on a seperate EBS volume that i mount on /dev/sdf. You can create an initial snapshot of this and then mount this to your os at runtime. My ami just contains the relevent stuff to autostart the environment.
The volume that this creates can be backed up fairly easily using crontab and ec2-create-snapshot or whatever. ec2-describe-snapshot gives the date of snapshot creation, so that can be used with awk or whatever to figure out which one's to delete. Although snapshot's only record the change between versions, so after the first one they don't actually take up too much space.
I have created a small wrapper script which does the following:
-dumps the DB (it is small, takes seconds)
-creates a tarball but only the diff between yesterday and today or a full backup if the day is Sunday
-invokes hg addremove && hg commit on /etc and the webroot (ignore file is pretty smart)
-uploads the previously created files to S3
This is not a full backup because it excludes the operating system. But since all my configuration files are saved, I don't care. This is a cost efficient way to make sure everything is available, even the history for certain things like the database.
Hope that helps.
Here is a short python script I created that takes care of the maintainence (deletes old backups, etc...)