2018-12-09 12:50:40 -08:00
< ? php
2019-01-02 22:53:19 -08:00
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2018-12-09 12:50:40 -08:00
// SPDX-License-Identifier: Apache-2.0
2024-02-05 10:49:20 -07:00
2024-02-06 09:28:06 -07:00
// snippet-start:[php.example_code.rds.createDBSnapshot.complete]
// snippet-start:[php.example_code.rds.createDBSnapshot.import]
2024-02-05 10:49:20 -07:00
2024-02-06 09:28:06 -07:00
require __DIR__ . '/vendor/autoload.php' ;
2024-02-05 10:49:20 -07:00
2018-12-09 12:50:40 -08:00
use Aws\Exception\AwsException ;
2024-02-05 10:49:20 -07:00
2024-02-06 09:28:06 -07:00
// snippet-end:[php.example_code.rds.createDBSnapshot.import]
// snippet-start:[php.example_code.rds.createDBSnapshot.main]
2024-02-05 10:49:20 -07:00
2018-12-09 12:50:40 -08:00
$rdsClient = new Aws\Rds\RdsClient ([
2018-12-09 13:53:34 -08:00
'region' => 'us-east-2'
2018-12-09 12:50:40 -08:00
]);
2024-02-05 10:49:20 -07:00
2018-12-09 12:50:40 -08:00
$dbIdentifier = '<<{{db-identifier}}>>' ;
$snapshotName = '<<{{backup_2018_12_25}}>>' ;
2024-02-05 10:49:20 -07:00
2018-12-09 12:50:40 -08:00
try {
$result = $rdsClient -> createDBSnapshot ([
'DBInstanceIdentifier' => $dbIdentifier ,
'DBSnapshotIdentifier' => $snapshotName ,
]);
var_dump ( $result );
2018-12-09 13:53:34 -08:00
} catch ( AwsException $e ) {
2018-12-09 12:50:40 -08:00
echo $e -> getMessage ();
echo " \n " ;
2019-01-02 22:53:19 -08:00
}
2024-02-05 10:49:20 -07:00
2024-02-06 09:28:06 -07:00
// snippet-end:[php.example_code.rds.createDBSnapshot.main]
// snippet-end:[php.example_code.rds.createDBSnapshot.complete]