create_snapshot ( $volume_id, $opt )

Create a snapshot of the volume identified by volume ID. A volume does not have to be detached at the time the snapshot is taken.

Snapshot creation requires that the system is in a consistent state. For instance, this means that if taking a snapshot of a database, the tables must be read-only locked to ensure that the snapshot will not contain a corrupted version of the database. Therefore, be careful when using this API to ensure that the system remains in the consistent state until the create snapshot status has returned.

Access

public

Parameters

Parameter

Type

Required

Description

$volume_id

string

Required

The ID of the volume from which to create the snapshot.

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • Description - string - Optional - The description for the new snapshot.
  • curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Create a snapshot from an EBS volume.

// Instantiate the class
$ec2 = new AmazonEC2();

// Create the snapshot
$response = $ec2->create_snapshot('vol-fc482995', array(
	'Description' => 'my-snapshot'
));

// Success?
var_dump($response->isOK());
Result:
bool(true)

Changelog

Version

Description

1.3.4

The CreateSnapshot operation introduced backwards-incompatible changes in the 2011-02-28 API release. The Description parameter is no longer required.

Related Methods

Source

Method defined in services/ec2.class.php | Toggle source view (7 lines) | View on GitHub

public function create_snapshot($volume_id, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['VolumeId'] = $volume_id;
    
    return $this->authenticate('CreateSnapshot', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback