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.

Once in a while I would go to http://aws.amazon.com/console and manually right click my EBS volume and create a snapshot.

This is kind of tedious and I would forget sometimes. Is it possible to automate this actions and say, make a daily or weekly snapshot?

I'm using a Windows Server instance.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

Use AMI Tools:

share|improve this answer
    
Excellent. Will look into this. Thanks –  bruno077 Feb 18 '11 at 15:29
add comment

As an alternative to command line tools you may use PHP script developed by me. It is easier to setup as you do not need write even a line of code and you do not need to setup environment.

Not only this script create snapshots automatically, it can also delete old snapshots after given period of time.

How to setup

  1. Open SSH connection to your server.
  2. Navigate to folder

    $ cd /usr/local/
    
  3. Clon this gist into ec2 folder

    $ git clone https://gist.github.com/9738785.git ec2
    
  4. Go to that folder

    $ cd ec2
    
  5. Make backup.php executable

    $ chmod +x backup.php
    
  6. Open releases of the AWS PHP SDK github project and copy URL of aws.zip button. Now download it into your server.

    $ wget https://github.com/aws/aws-sdk-php/releases/download/2.6.0/aws.zip
    
  7. Unzip this file into aws directory.

    $ unzip aws.zip -d aws 
    
  8. Edit backup.php php file and set all settings in line 5-12. Pay attention on your region.

    $dryrun     = FALSE;
    $interval   = '24 hours';
    $keep_for   = '10 Days';
    $volumes    = array('vol-********');
    $api_key    = '*********************';
    $api_secret = '****************************************';
    $ec2_region = 'us-east-1';
    $snap_descr = "Daily backup";
    
  9. Test it. Run this script

    $ ./backup.php
    

    Check if snapshot is created.

  10. If everything is ok just add cronjob. I run it everyday on 23:00. because i use interval 24 hours. If you setup shorter interval, consider to trigger cronjob more often. You can even set it every 5 minutes. It will create new snapshot only with given interval anyway.

    * 23 * * * /usr/local/ec2/backup.php
    
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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