12

You have entered Introductory Backups for Amazon EC2 EBS-backed Windows Images 010...

I have been browsing my brains out to find a simple backup strategy for our single windows 2008 server running SharePoint Services. This is an EBS-backed image of one server with one data volume. I don’t need anything exotic. I only need a “daily” backup (losing a day’s worth of data is not catastrophic).

We have created and saved an EBS backed AMI image (Windows 2008) we are comfortable using. We started off making backups by simply creating a new EBS AMI image. This is really simple, but the running server is put offline during the first 10 – 15 minutes of creating the image – not ideal.

The standard way of creating backups would seem to be creating snapshots of volumes attached to a running instance. Again it’s pretty simple and the server remains usable during the snapshot generation. The apparent Catch-22 is that you can’t simply launch a new instance directly from a snapshot.

I know how to bundle a running instance to S3 storage and then register the AMI from the S3 bucket. This does allow me to capture a backup of a running instance and, if the running instance is lost, register the AMI from the S3 bucket and launch the new AMI to recover the instance, but this seems really convoluted and it seems ridiculous to have to juggle back and forth between the AWS Console and the S3 Organizer plug-in for Firefox to get this accomplished. (Please don't mention the command line approach, this is an 010 level course).

From playing around with EBS-backed images, the following approach appears to work for me (all done within the AWS Console):

1.For your backups, simply snapshot the system volume (/dev/sda1) as needed. 2.If you lose your running instance, do the following: a.Create a new volume from your last snapshot backup b.Launch another instance of your starting AMI (must be EBS-backed) c.Stop this instance. d.Detach the existing system volume from the new stopped instance and discard. e.Attach the newly created volume as system volume (/dev/sda1) to the stopped instance. f.Re-start the new instance. I have tested this out a couple of times and it seems to work for me.

Question: Is there anything wrong with this approach?

3 Answers 3

8

Your approach sounds very good - but I can think of a possible way to improve it.

To reduce the impact of data loss since the last backup, and EBS volume failure (unlikely, but still possible) you could store your data on a separate EBS volume than your system files, and back up the data volume more frequently than the system volume.

With your current strategy, you'll lose any data that was created between the time of the last backup and the time your instance failed. With the new approach, the data volume will be getting written to right up until the instance failure, so you can just reattach it to your new instance once it's up and running.

1
  • Excellent point.
    – John Miner
    May 14, 2010 at 16:16
4

I generate a snapshot for every volume in my account using a bash script

#!/bin/bash

ec2-describe-volumes | awk '{ print $2 }' | sort -u >  /tmp/ebs_volumes

for i in $(cat /tmp/ebs_volumes); do
   echo $i;
   ec2-create-snapshot $i;
done
2
0

Here is script which will create AMI backup for all ec2 instances within your VPC

#!/bin/bash
#Script to Automate AMI backup

echo "----------------------------------\n   `date`   \n----------------------------------"

aws ec2 describe-instances --filters Name=vpc-id,Values=vpc-xxx |   awk '{ print $8 }' | sort -n   | grep  "i-" > /tmp/instanceid.txt

echo "Starting the Daily AMI creation: "

 #To create AMI from instance-id 

for i in $(cat /tmp/instanceid.txt); do
        echo "Creating AMI for Instance id $i ......."


echo "instance-`date +%d%b%y`-$i" > /tmp/aminame.txt

aws ec2 create-image --instance-id $i --name "`cat /tmp/aminame.txt`" --description "This is created by ami-backup.sh" --no-reboot | grep -ir ami | awk '{print $4}' > /tmp/amiID.txt

echo  "AMI Name is: `cat /tmp/aminame.txt`\n"

done

echo done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .