Created
November 12, 2012 17:31
-
-
Save cam-gists/4060701 to your computer and use it in GitHub Desktop.
Revisions
-
cam-gists created this gist
Nov 12, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ #!/usr/bin/php <?php // Pear Lib require_once "XML/Unserializer.php"; $options = array( 'complexType' => 'object', 'encoding' => 'utf-8', 'parseAttributes' => TRUE, 'returnResult' => TRUE ); $xr = new XML_Unserializer($options); $volumes = array( "xxxxxxxx" => "OS-Image-Production", "xxxxxxxx" => "Data-Production", "xxxxxxxx" => "OS-Image-Dev", "xxxxxxxx" => "Data-Dev" ); foreach($volumes as $vol_name => $descrip) { shell_exec("/usr/bin/aws --xml create-snapshot vol-".$vol_name." --description ".date("Y-m-d")."_".$descrip); // print "/usr/bin/aws --xml create-snapshot vol-".$vol_name." --description ".date("Y-m-d")."_".$descrip."\n"; } $aws_snapshots = shell_exec("/usr/bin/aws --xml describe-snapshots"); $aws_snapshots = $xr->unserialize($aws_snapshots); if($aws_snapshots) { foreach($aws_snapshots->snapshotSet->item as $snap) { if($snap->snapshotId != "snap-b5d2dbd8" AND strtotime($snap->startTime) < strtotime("-14 day")) { // print "/usr/bin/aws --xml delete-snapshot ".$snap->snapshotId."\n"; shell_exec("/usr/bin/aws --xml delete-snapshot ".$snap->snapshotId); } } } // TIm K cmd line script // AWS command line //http://timkay.com/aws/ ?>