This page describes how to use Cloud Spanner Backup and Restore with the client libraries.
For information on installing and setting up the client libraries, see Cloud Spanner Client Libraries.
Create a backup
The following code sample creates a backup at a specific version_time and then waits for it to complete. Once complete, it verifies that the backup is ready and retrieves some information about it, such as its name, size, and create time.
C#
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
C++
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Go
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Java
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Node.js
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
PHP
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Python
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Ruby
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
List backup operations
The following code sample lists all of the create backup operations (operations with CreateBackupMetadata) filtered by a given database and prints operations that are still ongoing.
For information on filtering syntax, see the filter
parameter in List BackupOperations.
C#
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
C++
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Go
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Java
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Node.js
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
PHP
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Python
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Ruby
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Restore database from backup
The following code sample restores a database from a given backup and waits for the restore operation (an operation with RestoreDatabaseMetadata) to complete. The restored database is created in the same instance as the backup. Once complete, the sample retrieves and prints some restore information from the database.
C#
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
C++
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Go
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Java
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Node.js
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
PHP
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Python
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Ruby
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
List database operations
The following code sample lists the optimize database operations (operations with OptimizeRestoredDatabaseMetadata) filtered by a given database.
For information on filtering syntax, see the filter
parameter in List DatabaseOperations.
C#
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
C++
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Go
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Java
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Node.js
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
PHP
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Python
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Ruby
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Cancel a backup operation
The following code sample creates a backup, cancels the backup operation, and then polls or waits until the backup operation is done
. If the operation was successfully cancelled, it will have a cancelTime
and an error message. If the backup operation completed before it was cancelled, the backup will exist, in which case we delete the backup for cleanup.
C#
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
C++
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Go
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Java
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Node.js
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
PHP
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Python
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Ruby
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
List backups in an instance
The following code sample lists the backups in a given instance.
You can filter the list of returned backups (e.g., filtering by name, version time, or by backup expire time) by providing a filter expression. For information on filtering syntax, see the filter
parameter in List Backups.
C#
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
C++
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Go
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Java
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Node.js
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
PHP
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Python
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Ruby
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Update a backup
The following code sample retrieves the expiry time of a backup and extends it.
C#
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
C++
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Go
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Java
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Node.js
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
PHP
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Python
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Ruby
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Delete a backup
The following code sample deletes a backup and verifies that it was deleted. Deleting a backup that is still in progress will both remove the backup resource and cancel the long-running backup operation.
C#
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
C++
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Go
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Java
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Node.js
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
PHP
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Python
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.
Ruby
To learn how to install and use the client library for Cloud Spanner, see the Cloud Spanner Client Libraries.