/**
  * Instantiate a GlacierClient object.
  *
  * @param string $accessKey
  * @param string $secretKey
  * @param array $config
  * @throws \InvalidArgumentException
  */
 public function __construct($accessKey, $secretKey, array $config = array())
 {
     if (empty($config['vault'])) {
         throw new InvalidArgumentException('Please provide a Glacier vault');
     }
     parent::__construct($accessKey, $secretKey, $config);
     $this->_client = GlacierClient::factory($this->_config);
 }
function client()
{
    static $client;
    if (is_null($client)) {
        $client = GlacierClient::factory(array('profile' => 'default', 'region' => 'us-west-2'));
    }
    return $client;
}
Beispiel #3
0
 /**
  * @covers Aws\Glacier\GlacierClient::factory
  */
 public function testFactoryInitializesClient()
 {
     $client = GlacierClient::factory(array('key' => 'foo', 'secret' => 'bar', 'region' => 'us-west-2'));
     $this->assertInstanceOf('Aws\\Common\\Signature\\SignatureV4', $this->readAttribute($client, 'signature'));
     $this->assertInstanceOf('Aws\\Common\\Credentials\\Credentials', $client->getCredentials());
     $this->assertEquals('https://glacier.us-west-2.amazonaws.com', $client->getBaseUrl());
     $this->assertEquals('-', $client->getCommand('ListVaults')->get('accountId'));
 }
<!DOCTYPE html>

<html>

<body>

<?php 
//Load the PHP SDK
require "aws.phar";
use Aws\Glacier\GlacierClient;
use Aws\Common\Enum\Region;
//This is where we connect to the Glacier Server
$aws = GlacierClient::factory(array('key' => 'your key', 'secret' => 'your secret key', 'region' => Region::US_EAST_1));
//Request an update on all of your jobs
$result = $aws->listJobs(array('vaultName' => 'new-vault'));
$array = $result->get('JobList');
//Creates an array with metadata regarding your jobs
print_r($array);
?>

</body>

</html>
Beispiel #5
0
 public function __construct($key, $secret, $region = Region::US_EAST_1)
 {
     $this->glacier = GlacierClient::factory(array('key' => $key, 'secret' => $secret, 'region' => $region, 'ssl.certificate_authority' => false));
 }
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
require 'vendor/autoload.php';
use Aws\Glacier\GlacierClient;
use Symfony\Component\Yaml\Yaml;
$countFiles = 0;
$file = 'config/config.yml';
$date = new DateTime(null, new DateTimeZone('America/Toronto'));
if ($file && file_exists($file)) {
    $config = Yaml::parse(file_get_contents($file));
}
$toUploadFolder = $config['files']['toUploadFolder'];
$extensionToUpload = $config['files']['extensionToUpload'];
$mysqlDump = sprintf('mysqldump -h %s -u %s -p%s %s | gzip > %s/%s.gz', $config['mysql']['host'], $config['mysql']['user'], $config['mysql']['pass'], $config['mysql']['db'], $toUploadFolder, $date->format('Y-m-d_H.i'));
//  system($mysqlDump);
$client = GlacierClient::factory(array('key' => $config['amazon']['amazonKey'], 'secret' => $config['amazon']['amazonSecret'], 'region' => $config['amazon']['amazonRegion']));
/*
    try {
       $result = $client->initiateJob(array(
           'accountId' => '-',
           'vaultName' => $config['amazon']['amazonVault'],
           'Type' => 'inventory-retrieval'
       ));

//  var_dump($result);

   } catch (Exception $e) {
       echo 'ERROR: ' .$e->getMessage();
   }
*/
// Getting info from my Vault:
<?php

require_once "/var/awsbackups/amazonaws/aws-autoloader.php";
use Aws\Glacier\GlacierClient;
$client = GlacierClient::factory(array('key' => 'yourAmazonKey', 'secret' => 'yourAmazonsecret', 'region' => 'us-east-1'));
$vaultName = 'yourVaultName';
$dir = "/var/awsbackups/";
$tdate = date('m_d_Y');
// Open a directory, and read its contents
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            if (sizeof(explode($tdate, $file)) > 1) {
                echo $file . " Going to upload";
                $result = $client->uploadArchive(array('vaultName' => $vaultName, 'body' => fopen($file, 'r')));
                $archiveId = $result->get('archiveId');
                echo "\nFile Uploaded and ArchiveID:" . $archiveId . "\n\n";
            }
        }
        closedir($dh);
    }
}