Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

marked as duplicate by Mark Henderson Nov 12 '12 at 1:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
what you need backup(db,source code,system,..)? –  ooshro Feb 21 '11 at 8:11
    
I'd like an entire system state, including DB, config and data files. I could use a separate procedure to back these up, but I'm thinking that there should be a complete backup solution at the image level - it's just neater. –  ripper234 Feb 21 '11 at 9:00

4 Answers 4

up vote 2 down vote accepted
+50

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.

ec2-run-instances ami-id <other options> --block-device-mapping '/dev/sdf=snap-id::false'

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.

share|improve this answer
    
This sounds like a great solution. Any chance you can blog about it, or otherwise write a step-by-step guide to doing this? (I'm an AWS noob, I'm sure others would find it useful as well) –  ripper234 Mar 9 '11 at 15:15
    
Actually, if you have an ebs instance running, just take a snap shot of that. Then register that as an ami. You may just have to mount it to an already running instance and MAKEDEV the /dev/zero, /dev/null and /dev/console devices if it wont boot, but otherwise that should do it. Then just take snapshots of it as you go. –  Decado Mar 9 '11 at 15:51

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 tells ec2-automate-backup to select volumes for backup by tag) and -t "Backup=your_tag" tells ec2-automate-backup to backup volumes tagged "your_tag."

ec2-automate-backup is part of AWS-Missing-Tools, available at http://awsmissingtools.com

share|improve this answer

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.

share|improve this answer

Here is a short python script I created that takes care of the maintainence (deletes old backups, etc...)

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.