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.
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.
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 callBackup::reload()to refresh the cached value.
Example:
use Google\Cloud\Spanner\Backup;
if ($backup->state() === Backup::STATE_READY) {
echo 'Backup is ready!';
}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Cloud Spanner Client - Class Backup (1.104.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.104.0 (latest)](/php/docs/reference/cloud-spanner/latest/Backup)\n- [1.103.0](/php/docs/reference/cloud-spanner/1.103.0/Backup)\n- [1.102.0](/php/docs/reference/cloud-spanner/1.102.0/Backup)\n- [1.101.0](/php/docs/reference/cloud-spanner/1.101.0/Backup)\n- [1.100.0](/php/docs/reference/cloud-spanner/1.100.0/Backup)\n- [1.98.0](/php/docs/reference/cloud-spanner/1.98.0/Backup)\n- [1.97.0](/php/docs/reference/cloud-spanner/1.97.0/Backup)\n- [1.96.0](/php/docs/reference/cloud-spanner/1.96.0/Backup)\n- [1.95.0](/php/docs/reference/cloud-spanner/1.95.0/Backup)\n- [1.94.0](/php/docs/reference/cloud-spanner/1.94.0/Backup)\n- [1.93.1](/php/docs/reference/cloud-spanner/1.93.1/Backup)\n- [1.92.1](/php/docs/reference/cloud-spanner/1.92.1/Backup)\n- [1.91.0](/php/docs/reference/cloud-spanner/1.91.0/Backup)\n- [1.90.0](/php/docs/reference/cloud-spanner/1.90.0/Backup)\n- [1.89.0](/php/docs/reference/cloud-spanner/1.89.0/Backup)\n- [1.88.0](/php/docs/reference/cloud-spanner/1.88.0/Backup)\n- [1.87.0](/php/docs/reference/cloud-spanner/1.87.0/Backup)\n- [1.86.0](/php/docs/reference/cloud-spanner/1.86.0/Backup)\n- [1.85.0](/php/docs/reference/cloud-spanner/1.85.0/Backup)\n- [1.84.0](/php/docs/reference/cloud-spanner/1.84.0/Backup)\n- [1.83.0](/php/docs/reference/cloud-spanner/1.83.0/Backup)\n- [1.82.0](/php/docs/reference/cloud-spanner/1.82.0/Backup)\n- [1.81.0](/php/docs/reference/cloud-spanner/1.81.0/Backup)\n- [1.80.0](/php/docs/reference/cloud-spanner/1.80.0/Backup)\n- [1.79.0](/php/docs/reference/cloud-spanner/1.79.0/Backup)\n- [1.78.0](/php/docs/reference/cloud-spanner/1.78.0/Backup)\n- [1.77.0](/php/docs/reference/cloud-spanner/1.77.0/Backup)\n- [1.76.1](/php/docs/reference/cloud-spanner/1.76.1/Backup)\n- [1.68.0](/php/docs/reference/cloud-spanner/1.68.0/Backup)\n- [1.67.0](/php/docs/reference/cloud-spanner/1.67.0/Backup)\n- [1.66.0](/php/docs/reference/cloud-spanner/1.66.0/Backup)\n- [1.65.0](/php/docs/reference/cloud-spanner/1.65.0/Backup)\n- [1.64.0](/php/docs/reference/cloud-spanner/1.64.0/Backup)\n- [1.63.2](/php/docs/reference/cloud-spanner/1.63.2/Backup)\n- [1.62.1](/php/docs/reference/cloud-spanner/1.62.1/Backup)\n- [1.61.0](/php/docs/reference/cloud-spanner/1.61.0/Backup)\n- [1.60.0](/php/docs/reference/cloud-spanner/1.60.0/Backup)\n- [1.59.0](/php/docs/reference/cloud-spanner/1.59.0/Backup)\n- [1.58.4](/php/docs/reference/cloud-spanner/1.58.4/Backup)\n- [1.57.0](/php/docs/reference/cloud-spanner/1.57.0/Backup)\n- [1.56.0](/php/docs/reference/cloud-spanner/1.56.0/Backup)\n- [1.55.0](/php/docs/reference/cloud-spanner/1.55.0/Backup)\n- [1.54.2](/php/docs/reference/cloud-spanner/1.54.2/Backup) \nReference documentation and code samples for the Cloud Spanner Client class Backup.\n\nRepresents a Cloud Spanner Backup.\n\nExample: \n\n use Google\\Cloud\\Spanner\\SpannerClient;\n\n $spanner = new SpannerClient();\n\n $backup = $spanner-\u003einstance('my-instance')-\u003ebackup('my-backup');\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Spanner\n\nMethods\n-------\n\n### __construct\n\nCreate an object representing a Backup.\n\n### create\n\nCreate a Cloud Spanner backup for a database.\n\nExample: \n\n $operation = $backup-\u003ecreate('my-database', new \\DateTime('+7 hours'));\n\n### createCopy\n\nCreate a copy of an existing backup in Cloud Spanner.\n\nExample: \n\n $sourceInstance = $spanner-\u003einstance('source-instance-id');\n $destInstance = $spanner-\u003einstance('destination-instance-id');\n $sourceBackup = $sourceInstance-\u003ebackup('source-backup-id');\n $destBackup = $destInstance-\u003ebackup('new-backup-id');\n\n $operation = $sourceBackup-\u003ecreateCopy($destBackup, new \\DateTime('+7 hours'));\n\n### delete\n\nMarks this backup for deletion.\n\nExample: \n\n $backup-\u003edelete();\n\n### exists\n\nTests whether this backup exists.\n\nThis method sends a service call.\n\nExample: \n\n if ($backup-\u003eexists()) {\n echo 'Backup exists!';\n }\n\n### info\n\nGet info of a Cloud Spanner backup from cache or request.\n\nExample: \n\n $info = $backup-\u003einfo();\n\n### name\n\nReturn the backup name.\n\nExample: \n\n $name = $backup-\u003ename();\n\n### reload\n\nReload the backup info from the Cloud Spanner API.\n\nExample: \n\n $info = $backup-\u003ereload();\n\n### state\n\nReturn the backup state.\n\nWhen backups are created, they may take some time before\nthey are ready for use. This method allows for checking whether a\nbackup is ready. Note that this value is cached within the class instance,\nso if you are polling it, first call [Backup::reload()](/php/docs/reference/cloud-spanner/latest/Backup#_Google_Cloud_Spanner_Backup__reload__)\nto refresh the cached value.\n\nExample: \n\n use Google\\Cloud\\Spanner\\Backup;\n\n if ($backup-\u003estate() === Backup::STATE_READY) {\n echo 'Backup is ready!';\n }\n\n### updateExpireTime\n\nUpdate the expire time of this backup.\n\nExample: \n\n $info = $backup-\u003eupdateExpireTime(new \\DateTime(\"+ 7 hours\"));\n\n### resumeOperation\n\n{\nResume a long running operation\n\n### longRunningOperations\n\n{\nList long running operations.\n\nConstants\n---------\n\n### STATE_READY\n\n Value: \\Google\\Cloud\\Spanner\\Admin\\Database\\V1\\Backup\\State::READY\n\n### STATE_CREATING\n\n Value: \\Google\\Cloud\\Spanner\\Admin\\Database\\V1\\Backup\\State::CREATING"]]