Skip to content

Instantly share code, notes, and snippets.

@bminer
Created March 8, 2012 15:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bminer/2001606 to your computer and use it in GitHub Desktop.
Save bminer/2001606 to your computer and use it in GitHub Desktop.
Simple PHP script to backup EC2 EBS volumes. Nice to include as a daily Cron job.
#! /usr/bin/env php
<?php
//Don't forget to setup credentials for the AWS API.
require_once('/usr/lib/aws-php-sdk-1.3.1/sdk.class.php');
$ec2 = new AmazonEC2();
$volumes = array(
'vol-xxxxxxxx' => '-- Your snapshot description here --',
'vol-xxxxxxxx' => '-- Your snapshot description here --',
'vol-xxxxxxxx' => '-- Your snapshot description here --'
);
foreach($volumes as $volumeID => $snapshotDesc)
{
$response = $ec2->create_snapshot($volumeID, $snapshotDesc);
$OK = $response->isOK();
if(!$OK)
var_dump($response);
}
?>
@bminer
Copy link
Author

bminer commented Mar 8, 2012

Hmmm... yeah.... can't get any more simple than this, I'm afraid. :-/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment