Skip to content

Instantly share code, notes, and snippets.

Created March 6, 2014 11:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
This script takes a snap shot of volume in AWS.
// Include the SDK using the Composer autoloader
require '/AWS_LIB_PATH/aws-autoloader.php';
use Aws\Common\Aws;
/// Create a service locator using a configuration file
$aws = Aws::factory(array(
'region' => 'eu-west-1', // define zone here
'key' => 'API KEY', // define your api key here
'secret' => 'API SECRET', // define your api secret here
$ec2Client = $aws->get('ec2');
$result = $ec2Client->createSnapshot(array(
//'DryRun' => true || false,
// VolumeId is required
'VolumeId' => 'VOLUME ID', // define volume id
'Name' => 'Auto Backup',
'Description' => 'Backup Generated at '. date('F j, Y, H:i:s'),
//Save this script and in cron I added this entry to run every night
//30 2 * * * php /home/meraj/aws-volume-backup.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment