- 2.0.1-RC1 (latest)
 - 2.0.0-RC1
 - 1.106.0
 - 1.105.1
 - 1.104.1
 - 1.103.0
 - 1.102.0
 - 1.101.0
 - 1.100.0
 - 1.98.0
 - 1.97.0
 - 1.96.0
 - 1.95.0
 - 1.94.0
 - 1.93.1
 - 1.92.1
 - 1.91.0
 - 1.90.0
 - 1.89.0
 - 1.88.0
 - 1.87.0
 - 1.86.0
 - 1.85.0
 - 1.84.0
 - 1.83.0
 - 1.82.0
 - 1.81.0
 - 1.80.0
 - 1.79.0
 - 1.78.0
 - 1.77.0
 - 1.76.1
 - 1.68.0
 - 1.67.0
 - 1.66.0
 - 1.65.0
 - 1.64.0
 - 1.63.2
 - 1.62.1
 - 1.61.0
 - 1.60.0
 - 1.59.0
 - 1.58.4
 - 1.57.0
 - 1.56.0
 - 1.55.0
 - 1.54.2
 
Reference documentation and code samples for the Cloud Spanner Client class Backup.
Represents a Cloud Spanner Backup.
Example:
use Google\Cloud\Spanner\SpannerClient;
$spanner = new SpannerClient();
$backup = $spanner->instance('my-instance')->backup('my-backup');
Namespace
Google \ Cloud \ SpannerMethods
__construct
Create an object representing a Backup.
| Parameters | |
|---|---|
| Name | Description | 
connection | 
        
          Connection\ConnectionInterface
          The connection to the Cloud Spanner Admin API. This object is created by SpannerClient, and should not be instantiated outside of this client.  | 
      
instance | 
        
          Instance
          The instance in which the backup exists.  | 
      
lroConnection | 
        
          Google\Cloud\Core\LongRunning\LongRunningConnectionInterface
          An implementation mapping to methods which handle LRO resolution in the service.  | 
      
lroCallables | 
        
          array
           | 
      
projectId | 
        
          string
          The project ID.  | 
      
name | 
        
          string
          The backup name or ID.  | 
      
info | 
        
          array
          [optional] An array representing the backup resource.  | 
      
create
Create a Cloud Spanner backup for a database.
Example:
$operation = $backup->create('my-database', new \DateTime('+7 hours'));
| Parameters | |
|---|---|
| Name | Description | 
database | 
        
          string
          The name or id of the database that this backup is for.  | 
      
expireTime | 
        
          DateTimeInterface
          The expiration time of the backup, with microseconds granularity that must be at least 6 hours and at most 366 days. Once the expireTime has passed, the backup is eligible to be automatically deleted by Cloud Spanner.  | 
      
options | 
        
          array
          Configuration Options.  | 
      
↳ versionTime | 
        
          DateTimeInterface
          The version time for the externally consistent copy of the database. If not present, it will be the same as the create time of the backup.  | 
      
| Returns | |
|---|---|
| Type | Description | 
Google\Cloud\Core\LongRunning\LongRunningOperation<Backup> | 
        |
createCopy
Create a copy of an existing backup in Cloud Spanner.
Example:
$sourceInstance = $spanner->instance('source-instance-id');
$destInstance = $spanner->instance('destination-instance-id');
$sourceBackup = $sourceInstance->backup('source-backup-id');
$destBackup = $destInstance->backup('new-backup-id');
$operation = $sourceBackup->createCopy($destBackup, new \DateTime('+7 hours'));
| Parameters | |
|---|---|
| Name | Description | 
newBackup | 
        
          Backup
          The backup object that needs to be created as a copy.  | 
      
expireTime | 
        
          DateTimeInterface
          The expiration time of the backup, with microseconds granularity that must be at least 6 hours and at most 366 days. Once the expireTime has passed, the backup is eligible to be automatically deleted by Cloud Spanner.  | 
      
options | 
        
          array
          Configuration Options.  | 
      
↳ versionTime | 
        
          DateTimeInterface
          The version time for the externally consistent copy of the database. If not present, it will be the same as the create time of the backup.  | 
      
| Returns | |
|---|---|
| Type | Description | 
Google\Cloud\Core\LongRunning\LongRunningOperation<Backup> | 
        |
delete
Marks this backup for deletion.
Example:
$backup->delete();
| Parameter | |
|---|---|
| Name | Description | 
options | 
        
          array
          [optional] Configuration options.  | 
      
| Returns | |
|---|---|
| Type | Description | 
void | 
        |
exists
Tests whether this backup exists.
This method sends a service call.
Example:
if ($backup->exists()) {
    echo 'Backup exists!';
}
| Parameter | |
|---|---|
| Name | Description | 
options | 
        
          array
          [optional] Configuration options.  | 
      
| Returns | |
|---|---|
| Type | Description | 
bool | 
        |
info
Get info of a Cloud Spanner backup from cache or request.
Example:
$info = $backup->info();
| Parameter | |
|---|---|
| Name | Description | 
options | 
        
          array
          [optional] Configuration options.  | 
      
| Returns | |
|---|---|
| Type | Description | 
array | 
        |
name
Return the backup name.
Example:
$name = $backup->name();
| Returns | |
|---|---|
| Type | Description | 
string | 
        |
reload
Reload the backup info from the Cloud Spanner API.
Example:
$info = $backup->reload();
| Parameter | |
|---|---|
| Name | Description | 
options | 
        
          array
          [optional] Configuration options.  | 
      
| Returns | |
|---|---|
| Type | Description | 
array | 
        |
state
Return the backup state.
When backups are created, they may take some time before they are ready for use. This method allows for checking whether a backup is ready. Note that this value is cached within the class instance, so if you are polling it, first call Backup::reload() to refresh the cached value.
Example:
use Google\Cloud\Spanner\Backup;
if ($backup->state() === Backup::STATE_READY) {
    echo 'Backup is ready!';
}
| Parameter | |
|---|---|
| Name | Description | 
options | 
        
          array
          [optional] Configuration options.  | 
      
| Returns | |
|---|---|
| Type | Description | 
int|null | 
        |
updateExpireTime
Update the expire time of this backup.
Example:
$info = $backup->updateExpireTime(new \DateTime("+ 7 hours"));
| Parameters | |
|---|---|
| Name | Description | 
newTimestamp | 
        
          DateTimeInterface
          New expire time.  | 
      
options | 
        
          array
          [optional] Configuration options.  | 
      
| Returns | |
|---|---|
| Type | Description | 
Backup | 
        |
resumeOperation
{ Resume a long running operation
| Returns | |
|---|---|
| Type | Description | 
void | 
        |
longRunningOperations
{ List long running operations.
| Returns | |
|---|---|
| Type | Description | 
void | 
        |
Constants
STATE_READY
Value: \Google\Cloud\Spanner\Admin\Database\V1\Backup\State::READYSTATE_CREATING
Value: \Google\Cloud\Spanner\Admin\Database\V1\Backup\State::CREATING