This page describes Spanner backup schedule operations and explains how to set up a backup schedule for your database.
Before you begin
-
To get the permissions that you need to create and manage backup schedules, ask your administrator to grant you the following IAM roles on the instance:
-
Create, view, update, and delete backup schedules:
Cloud Spanner Backup Admin (
roles/spanner.backupAdmin
) -
Create and view backup schedules:
Cloud Spanner Backup Writer (
roles/spanner.backupWriter
)
-
Create, view, update, and delete backup schedules:
Cloud Spanner Backup Admin (
Create a backup schedule
In the Google Cloud console, go to the Spanner Instances page.
Click the instance containing the database.
Click the database.
In the navigation menu, click the Backup/Restore.
Click Create backup schedule.
Fill out the form, then click Create.
Before using any of the command data below, make the following replacements:
-
SCHEDULE_ID : the backup schedule ID. PROJECT_ID : the project ID.-
INSTANCE_ID : the ID of the instance where you want to create the backup schedule. -
DATABASE_ID : the ID of the database where you want to create the backup schedule. -
RETENTION_DURATION : the retention duration of the backups created by the schedule. For example, if you want the retention duration to be one day, you can use86400s
. -
CRONTAB_EXPRESSION : the crontab expression for the backup schedule frequency. For example, if you want the backup schedule frequency to be every 12 hours, you can use0 12 * * *
. -
BACKUP_TYPE : whether it's a full backup schedule or an incremental backup schedule. Possible values arefull-backup
orincremental-backup
. -
ENCRYPTION_TYPE : the encryption type of backups created by the backup schedule. Valid values areUSE_DATABASE_ENCRYPTION
,GOOGLE_DEFAULT_ENCRYPTION
, orCUSTOMER_MANAGED_ENCRYPTION
. If you useCUSTOMER_MANAGED_ENCRYPTION
, you must specify akmsKeyName
. If your backup type isincremental-backup
, the encryption type must beGOOGLE_DEFAULT_ENCRYPTION
.
Execute the following command:
Linux, macOS, or Cloud Shell
gcloud spanner backup-schedules createSCHEDULE_ID \ --project=PROJECT_ID \ --instance=INSTANCE_ID \ --database=DATABASE_ID \ --retention-duration=RETENTION_DURATION \ --cron="CRONTAB_EXPRESSION " \ --backup-type=BACKUP_TYPE \ --encryption-type=ENCRYPTION_TYPE
Windows (PowerShell)
gcloud spanner backup-schedules createSCHEDULE_ID ` --project=PROJECT_ID ` --instance=INSTANCE_ID ` --database=DATABASE_ID ` --retention-duration=RETENTION_DURATION ` --cron="CRONTAB_EXPRESSION " ` --backup-type=BACKUP_TYPE ` --encryption-type=ENCRYPTION_TYPE
Windows (cmd.exe)
gcloud spanner backup-schedules createSCHEDULE_ID ^ --project=PROJECT_ID ^ --instance=INSTANCE_ID ^ --database=DATABASE_ID ^ --retention-duration=RETENTION_DURATION ^ --cron="CRONTAB_EXPRESSION " ^ --backup-type=BACKUP_TYPE ^ --encryption-type=ENCRYPTION_TYPE
Before using any of the request data, make the following replacements:
PROJECT_ID : the project ID.-
INSTANCE_ID : the ID of the instance where you want to create the backup schedule. -
DATABASE_ID : the ID of the database where you want to create the backup schedule. SCHEDULE_ID : the backup schedule ID.-
BACKUP_TYPE : whether it's a full backup schedule or an incremental backup schedule. Possible values arefullBackupSpec
orincrementalBackupSpec
. -
ENCRYPTION_TYPE : the encryption type of backups created by the backup schedule. Possible values areUSE_DATABASE_ENCRYPTION
,GOOGLE_DEFAULT_ENCRYPTION
, orCUSTOMER_MANAGED_ENCRYPTION
. If you useCUSTOMER_MANAGED_ENCRYPTION
, you must specify akmsKeyName
. If your backup type isincremental-backup
, the encryption type must beGOOGLE_DEFAULT_ENCRYPTION
. -
RETENTION_DURATION : the retention duration of the backups created by the schedule.
HTTP method and URL:
POST https://spanner.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules?backup_schedule_id=SCHEDULE_ID
Request JSON body:
{ "retentionDuration": "RETENTION_DURATION ", "spec": { "cronSpec": { "text": "0 2 * * *" } }, "encryptionConfig": { "encryptionType": "ENCRYPTION_TYPE " }, "BACKUP_TYPE ": {} }
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell)
Save the request body in a file named request.json
,
and execute the following command:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://spanner.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules?backup_schedule_id=SCHEDULE_ID "
PowerShell (Windows)
Save the request body in a file named request.json
,
and execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://spanner.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules?backup_schedule_id=SCHEDULE_ID " | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules/SCHEDULE_ID ", "retentionDuration": "86400s", "encryptionConfig": { "encryptionType": "USE_DATABASE_ENCRYPTION" }, "spec": { "cronSpec": { "text": "0 2 * * *", "timeZone": "UTC", "creationWindow": "14400s" } }, "BACKUP_TYPE ": {}, "updateTime": "2024-05-22T11:13:51.835590Z" }
To create a full backup schedule, see the following sample code:
To create an incremental backup schedule, see the following sample code:To create a full backup schedule, see the following sample code:
To create an incremental backup schedule, see the following sample code:To create a full backup schedule, see the following sample code:
To create an incremental backup schedule, see the following sample code:To create a full backup schedule, see the following sample code:
To create an incremental backup schedule, see the following sample code:To create a full backup schedule, see the following sample code:
To create an incremental backup schedule, see the following sample code:To create a full backup schedule, see the following sample code:
To create a full backup schedule, see the following sample code:
To create an incremental backup schedule, see the following sample code:Get a backup schedule
In the Google Cloud console, go to the Spanner Instances page.
Click the instance containing the database.
Click the database.
In the navigation menu, click the Backup/Restore.
Click the Schedules tab to view all the backup schedules and their information.
Before using any of the command data below, make the following replacements:
PROJECT_ID : the project ID.INSTANCE_ID : the instance ID.DATABASE_ID : the database ID.SCHEDULE_ID : the backup schedule ID.
Execute the following command:
Linux, macOS, or Cloud Shell
gcloud spanner backup-schedules describeSCHEDULE_ID \ --project=PROJECT_ID \ --instance=INSTANCE_ID \ --database=DATABASE_ID
Windows (PowerShell)
gcloud spanner backup-schedules describeSCHEDULE_ID ` --project=PROJECT_ID ` --instance=INSTANCE_ID ` --database=DATABASE_ID
Windows (cmd.exe)
gcloud spanner backup-schedules describeSCHEDULE_ID ^ --project=PROJECT_ID ^ --instance=INSTANCE_ID ^ --database=DATABASE_ID
You should receive a response similar to the following:
{ encryptionConfig: encryptionType: USE_DATABASE_ENCRYPTION incrementalBackupSpec: {} name: projects/my-project/instances/my-instance/databases/my-database/backupSchedules/my-schedule retentionDuration: 2592000s spec: cronSpec: creationWindow: 14400s text: 0 */4 * * * timeZone: UTC updateTime: '2024-09-13T10:24:18.754839Z' }
Before using any of the request data, make the following replacements:
PROJECT_ID : the project ID.INSTANCE_ID : the instance ID.DATABASE_ID : the database ID.SCHEDULE_ID : the backup schedule ID.
HTTP method and URL:
GET https://spanner.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules/SCHEDULE_ID
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell)
Execute the following command:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://spanner.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules/SCHEDULE_ID "
PowerShell (Windows)
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://spanner.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules/SCHEDULE_ID " | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules/SCHEDULE_ID ", "retentionDuration": "100000s", "encryptionConfig": { "encryptionType": "USE_DATABASE_ENCRYPTION" }, "spec": { "cronSpec": { "text": "0 2 * * *", "timeZone": "UTC", "creationWindow": "14400s" } }, "fullBackupSpec": {}, "updateTime": "2024-05-22T11:13:51.835590Z" }
List backup schedules
In the Google Cloud console, go to the Spanner Instances page.
Click the instance containing the database.
Click the database.
In the navigation menu, click the Backup/Restore.
Click the Schedules tab to view all the backup schedules and their information.
Before using any of the command data below, make the following replacements:
PROJECT_ID : the project ID.INSTANCE_ID : the instance ID.DATABASE_ID : the database ID.
Execute the following command:
Linux, macOS, or Cloud Shell
gcloud spanner backup-schedules list \ --project=PROJECT_ID \ --instance=INSTANCE_ID \ --database=DATABASE_ID
Windows (PowerShell)
gcloud spanner backup-schedules list ` --project=PROJECT_ID ` --instance=INSTANCE_ID ` --database=DATABASE_ID
Windows (cmd.exe)
gcloud spanner backup-schedules list ^ --project=PROJECT_ID ^ --instance=INSTANCE_ID ^ --database=DATABASE_ID
You should receive a response similar to the following:
Name Backup type Cron Retention duration Encryption type my-full-schedule FULL 30 12 * * * 2592000s USE_DATABASE_ENCRYPTION my-incr-schedule INCREMENTAL 0 */4 * * * 2592000s USE_DATABASE_ENCRYPTION
Before using any of the request data, make the following replacements:
PROJECT_ID : the project ID.INSTANCE_ID : the instance ID.DATABASE_ID : the database ID.
HTTP method and URL:
GET https://spanner.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell)
Execute the following command:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://spanner.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules"
PowerShell (Windows)
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://spanner.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "backupSchedules": [ { "name": "projects/PROJECT_ID/instances/INSTANCE_ID/databases/DATABASE_ID/backupSchedules/SCHEDULE_ID", "retentionDuration": "172800s", "encryptionConfig": { "encryptionType": "USE_DATABASE_ENCRYPTION" }, "spec": { "cronSpec": { "text": "0 */12 * * *", "timeZone": "UTC", "creationWindow": "14400s" } }, "fullBackupSpec": {}, "updateTime": "2024-09-09T07:21:43.946180Z" }, { "name": "projects/PROJECT_ID/instances/INSTANCE_ID/databases/DATABASE_ID/backupSchedules/SCHEDULE_ID", "retentionDuration": "2592000s", "encryptionConfig": { "encryptionType": "CUSTOMER_MANAGED_ENCRYPTION", "kmsKeyName": "projects/PROJECT_ID/locations/us-central1/keyRings/cmek-demo/cryptoKeys/test-key" }, "spec": { "cronSpec": { "text": "30 12 * * *", "timeZone": "UTC", "creationWindow": "14400s" } }, "fullBackupSpec": {}, "updateTime": "2024-09-17T18:27:53.868741Z" } ] }
Update a backup schedule
In the Google Cloud console, go to the Spanner Instances page.
Click the instance containing the database.
Click the database.
In the navigation menu, click the Backup/Restore.
Click the Schedules tab.
Select More actions for your backup schedule and click Update.
You can update the frequency and retention time of the backup schedule. If it's a full backup schedule, you can also update the encryption type.
Click Save.
Before using any of the command data below, make the following replacements:
SCHEDULE_ID : the backup schedule ID.PROJECT_ID : the project ID.-
INSTANCE_ID : the ID of the instance where you want to modify the backup schedule. -
DATABASE_ID : the ID of the database where you want to modify the backup schedule. -
RETENTION_DURATION : the retention duration of the backups created by the schedule. -
CRONTAB_EXPRESSION : the crontab expression for the backup schedule frequency. For example, if you want the backup schedule frequency to be every 12 hours, you can use0 12 * * *
. -
ENCRYPTION_TYPE : the encryption type of backups created by the backup schedule. Valid values areUSE_DATABASE_ENCRYPTION
,GOOGLE_DEFAULT_ENCRYPTION
, orCUSTOMER_MANAGED_ENCRYPTION
. If you useCUSTOMER_MANAGED_ENCRYPTION
, you must specify akmsKeyName
. If your backup type isincremental-backup
, the encryption type must beGOOGLE_DEFAULT_ENCRYPTION
.
Execute the following command:
Linux, macOS, or Cloud Shell
gcloud spanner backup-schedules updateSCHEDULE_ID \ --project=PROJECT_ID \ --instance=INSTANCE_ID \ --database=DATABASE_ID \ --retention-duration=RETENTION_DURATION \ --cron="CRONTAB_EXPRESSION " \ --encryption-type=ENCRYPTION_TYPE
Windows (PowerShell)
gcloud spanner backup-schedules updateSCHEDULE_ID ` --project=PROJECT_ID ` --instance=INSTANCE_ID ` --database=DATABASE_ID ` --retention-duration=RETENTION_DURATION ` --cron="CRONTAB_EXPRESSION " ` --encryption-type=ENCRYPTION_TYPE
Windows (cmd.exe)
gcloud spanner backup-schedules updateSCHEDULE_ID ^ --project=PROJECT_ID ^ --instance=INSTANCE_ID ^ --database=DATABASE_ID ^ --retention-duration=RETENTION_DURATION ^ --cron="CRONTAB_EXPRESSION " ^ --encryption-type=ENCRYPTION_TYPE
Before using any of the request data, make the following replacements:
PROJECT_ID : the project ID.-
INSTANCE_ID : the ID of the instance where you want to modify the backup schedule. -
DATABASE_ID : the ID of the database where you want to modify the backup schedule. SCHEDULE_ID : the backup schedule ID.-
RETENTION_DURATION : the retention duration of the backups created by the schedule. For example, if you want the retention duration to be one day, specify86400s
. -
ENCRYPTION_TYPE : the encryption type of backups created by the backup schedule. Possible values areUSE_DATABASE_ENCRYPTION
,GOOGLE_DEFAULT_ENCRYPTION
, orCUSTOMER_MANAGED_ENCRYPTION
. If you useCUSTOMER_MANAGED_ENCRYPTION
, you must specify akmsKeyName
. If your backup type isincremental-backup
, the encryption type must beGOOGLE_DEFAULT_ENCRYPTION
.
HTTP method and URL:
PATCH https://spanner.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules/SCHEDULE_ID ?updateMask=retention_duration,encryption_config,spec.cron_spec.text
Request JSON body:
{ "retentionDuration": "RETENTION_DURATION ", "spec": { "cronSpec": { "text": "0 2 * * *" } "encryptionConfig": { "encryptionType": "ENCRYPTION_TYPE " }, }, }
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell)
Save the request body in a file named request.json
,
and execute the following command:
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://spanner.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules/SCHEDULE_ID ?updateMask=retention_duration,encryption_config,spec.cron_spec.text"
PowerShell (Windows)
Save the request body in a file named request.json
,
and execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://spanner.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules/SCHEDULE_ID ?updateMask=retention_duration,encryption_config,spec.cron_spec.text" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules/SCHEDULE_ID ", "retentionDuration": "86400s", "encryptionConfig": { "encryptionType": "USE_DATABASE_ENCRYPTION" }, "spec": { "cronSpec": { "text": "0 2 * * *", "timeZone": "UTC", "creationWindow": "14400s" } }, "fullBackupSpec": {}, "updateTime": "2024-05-22T11:13:51.835590Z" }
Delete a backup schedule
In the Google Cloud console, go to the Spanner Instances page.
Click the instance containing the database.
Click the database.
In the navigation menu, click the Backup/Restore.
Select More actions for your backup schedule and click Delete.
Type the backup schedule name.
Click Confirm.
Before using any of the command data below, make the following replacements:
SCHEDULE_ID : the backup schedule ID.PROJECT_ID : the project ID.-
INSTANCE_ID : the ID of the instance where you want to delete the backup schedule. -
DATABASE_ID : the ID of the database where you want to delete the backup schedule.
Execute the following command:
Linux, macOS, or Cloud Shell
gcloud spanner backup-schedules deleteSCHEDULE_ID \ --project=PROJECT_ID \ --instance=INSTANCE_ID \ --database=DATABASE_ID
Windows (PowerShell)
gcloud spanner backup-schedules deleteSCHEDULE_ID ` --project=PROJECT_ID ` --instance=INSTANCE_ID ` --database=DATABASE_ID
Windows (cmd.exe)
gcloud spanner backup-schedules deleteSCHEDULE_ID ^ --project=PROJECT_ID ^ --instance=INSTANCE_ID ^ --database=DATABASE_ID
Before using any of the request data, make the following replacements:
PROJECT_ID : the project ID.-
INSTANCE_ID : the ID of the instance where you want to delete the backup schedule. -
DATABASE_ID : the ID of the database where you want to delete the backup schedule. -
SCHEDULE_ID : the backup schedule ID.
HTTP method and URL:
DELETE https://spanner.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules/SCHEDULE_ID
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell)
Execute the following command:
curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://spanner.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules/SCHEDULE_ID "
PowerShell (Windows)
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://spanner.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules/SCHEDULE_ID " | Select-Object -Expand Content
You should receive a successful status code (2xx) and an empty response.
Set IAM access control policy
You can set an IAM access policy to specify who has access to the backup schedule.
Before using any of the command data below, make the following replacements:
SCHEDULE_ID : the backup schedule ID.PROJECT_ID : the project ID.INSTANCE_ID : the instance ID.DATABASE_ID : the database ID.
Execute the following command:
Linux, macOS, or Cloud Shell
gcloud spanner backup-schedules set-iam-policySCHEDULE_ID \ --project=PROJECT_ID \ --instance=INSTANCE_ID \ --database=DATABASE_ID \ policy.json
Windows (PowerShell)
gcloud spanner backup-schedules set-iam-policySCHEDULE_ID ` --project=PROJECT_ID ` --instance=INSTANCE_ID ` --database=DATABASE_ID ` policy.json
Windows (cmd.exe)
gcloud spanner backup-schedules set-iam-policySCHEDULE_ID ^ --project=PROJECT_ID ^ --instance=INSTANCE_ID ^ --database=DATABASE_ID ^ policy.json
You should receive a response similar to the following:
Updated IAM policy for backupSchedule [SCHEDULE_ID ]. bindings: - members: - user:test@google.com role: roles/editor etag: BwYi82k-fho= version: 1
policy.json
file that you can use along with this
gcloud CLI command:
{ "version": 1, "etag": "BwYi8ypICC0=", "bindings": [ { "role": "roles/editor", "members": [ "user:test@gmail.com" ] } ] }
Before using any of the request data, make the following replacements:
PROJECT_ID : the project ID.INSTANCE_ID : the instance ID.DATABASE_ID : the database ID.SCHEDULE_ID : the backup schedule ID.
HTTP method and URL:
POST https://spanner.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules/SCHEDULE_ID :setIamPolicy?alt=json
Request JSON body:
{ "policy": { "version": 1, "etag": "BwYi8ypICC0=", "bindings": [ { "role": "roles/editor", "members": [ "user:test@gmail.com" ] } ] } }
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell)
Save the request body in a file named request.json
,
and execute the following command:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://spanner.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules/SCHEDULE_ID :setIamPolicy?alt=json"
PowerShell (Windows)
Save the request body in a file named request.json
,
and execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://spanner.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules/SCHEDULE_ID :setIamPolicy?alt=json" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ { "version": 1, "etag": "etag", "bindings": [ { "role": "roles/non-primitive", "members": [ "user:test@gmail.com" ] } ] } }
Get IAM access control policy
Before using any of the command data below, make the following replacements:
SCHEDULE_ID : the backup schedule ID.PROJECT_ID : the project ID.INSTANCE_ID : the instance ID.DATABASE_ID : the database ID.
Execute the following command:
Linux, macOS, or Cloud Shell
gcloud spanner backup-schedules get-iam-policySCHEDULE_ID \ --project=PROJECT_ID \ --instance=INSTANCE_ID \ --database=DATABASE_ID
Windows (PowerShell)
gcloud spanner backup-schedules get-iam-policySCHEDULE_ID ` --project=PROJECT_ID ` --instance=INSTANCE_ID ` --database=DATABASE_ID
Windows (cmd.exe)
gcloud spanner backup-schedules get-iam-policySCHEDULE_ID ^ --project=PROJECT_ID ^ --instance=INSTANCE_ID ^ --database=DATABASE_ID
You should receive a response similar to the following:
bindings: - members: - user:test@gmail.com role: roles/editor etag: BwYi82k-fho= version: 1
Before using any of the request data, make the following replacements:
INSTANCE_ID : the instance ID.DATABASE_ID : the database ID.SCHEDULE_ID : the backup schedule ID.PROJECT_ID : the project ID.
HTTP method and URL:
POST https://spanner.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules/SCHEDULE_ID :getIamPolicy?alt=json
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell)
Execute the following command:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d "" \
"https://spanner.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules/SCHEDULE_ID :getIamPolicy?alt=json"
PowerShell (Windows)
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-Uri "https://spanner.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_ID /databases/DATABASE_ID /backupSchedules/SCHEDULE_ID :getIamPolicy?alt=json" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ { "version": 1, "etag": "BwYbyZ9pc4o=", "bindings": [ { "role": "roles/editor", "members": [ "user:test@gmail.com" ] } ] } }