Amazon AWS: Backing up running instances with additional volumes

Standard

I have a running instance (virutal server) with an additional attached volume (virtual hard disk) on Amazon AWS and I need to make a snapshot (back it up) regularly. So I can restore it quickly if need be.

For this purpose the following steps are taken:

  1. Setup another machine either inside or outside of AWS with the EC tools (http://aws.amazon.com/developertools/351). I chose one of the preconfigured Amazon images with EC2 tools already installed and spun up a micro instance in the same region as my servers, that then controls all the backing up of all my instances. It does not matter in which region the backup server controller is spun up, but it will only make snapshots in the region the backed up volume or instance resides.
  2. It is vital to have a valid X509 certificate with the private key. Create it in the Security Essentials section of AWS.
  3. Next you will need to know the volume IDs you want to back up. They are found in the Amazon AWS Management Console under EC2 / Elastic Block Store / Volumes
  4. The command to use to create a snapshot is:
    ec2-create-snapshot -C cert-YOURCERT.pem -K pk-YOURPK.pem VOLUME-ID -d “An optional description (I also use the $(date +%C%g%m%d%H%M%S%N) to timestamp my snapshot”This will make the snapshot appear in the Amazon AWS Management Console under EC2 / Elastic Block Store / SnapshotsYou could automate this with cron.
  5. From within the Amazon AWS Management Console under EC2 / Elastic Block Store / Snapshots you can create an Image from your snapshot (which then appears in EC2 / Images /AMIs) or a create a volume (which then appears in EC2 / Elastic Block Store / Volumes)
  6. The resulting AMI can be spun up as a new instance or the volume can be attached to a running instance and appears as an additional disk.

Steps 1 to 4 describe Backup.

Steps 5 and 6 describe Restore.

Note: I have not tested this with running databases (MySQL or PostgreSQL). If in doubt shutdown databases first then create the snapshot. Then start the databases up again.