Created
March 6, 2014 11:29
-
-
Save mrkkhattak/9387704 to your computer and use it in GitHub Desktop.
This script takes a snap shot of volume in AWS.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 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