This page describes Cloud Bigtable backup operations and explains how to back up and restore a table. Before you read this page, you should be familiar with the Overview of backups.
You can work with Cloud Bigtable backups by using the following:
- The Cloud Console.
- The
gcloud
command-line tool. - The Java, HBase, Go, and C++ Cloud Bigtable client libraries for Cloud Bigtable.
You can also access the API directly, but we strongly recommend that you do so only if you need to use a language that is not supported by the Cloud Bigtable client libraries.
Before you begin
Make sure that you or the user account that you are using have the required permissions for the action you need to perform.
If you plan to use the gcloud
tool, install the Cloud SDK for Cloud Bigtable.
Creating a table backup
Console
Go to the Cloud Bigtable instances page in the Cloud Console.
Click the instance that contains the table you want to back up.
In the left navigation pane, click Tables.
Click Create backup for the table you want to back up.
If you are using replication, use the dropdown menu to choose the Cluster ID for the cluster that should store the backup. (If you clicked Create backup next to a cluster ID rather than an instance ID on the Tables page, the cluster is pre-selected.)
Enter a unique ID for the backup.
Set an expiration date.
Click Create.
The console displays the Backups page filtered to show the backup and its details.
Click Activity to view the status of the backup.
The status column displays Backup complete when the backup has been completed.
gcloud
For all commands, substitute actual values for the following:
INSTANCE_ID
: The permanent identifier for the instance.CLUSTER_ID
: The permanent identifier for the cluster.TABLE_ID
: The ID of the table to be backed up.BACKUP_ID
: The ID you assign to the backup.EXPIRATION_DATE
: A date 30 days or less in the future, formatted as a "Zulu" UTC timestamp, accurate to nanoseconds.Example:
2019-10-02T15:01:23.045123456Z
RETENTION_PERIOD
: A period of up to 30 days, expressed as a number with a unit ofm
,h
, ord
(minutes, hours, or days).Examples:
5m
,36h
, or29d
If you don't know the instance ID, use the
bigtable instances list
command to view a list of your project's instances:gcloud bigtable instances list
View the list of backups for the instance that contains the table you want to back up, so that you can choose a backup ID that is not already in use on the intended cluster.
gcloud bigtable backups list --instance=INSTANCE_ID --cluster=CLUSTER_ID
View the list of tables to confirm the ID of the table you want to back up.
gcloud bigtable instances tables list --instance=INSTANCE_ID
Create a backup from the table, providing either an expiration date or a retention period of up to 30 days.
gcloud bigtable backups create BACKUP_ID --instance=INSTANCE_ID --cluster=CLUSTER_ID --table=TABLE_ID --async --expiration-date=EXPIRATION_DATE | --retention-period=RETENTION_PERIOD
The
--async
flag is optional. Use it if you want the terminal to return the operation ID before the operation is complete. This is helpful if you want to check the status of the operation.View the list of backups to see if your backup has been created.
gcloud bigtable backups list --instance=INSTANCE_ID --cluster=CLUSTER_ID
If the backup is not listed, check the status of the operation.
A status of
Ready
indicates the backup is complete.
Restoring a table backup
Console
Go to the Cloud Bigtable instances page in the Cloud Console.
Click the instance that contains the backup you want to restore.
In the left navigation pane, click Backups.
Click Restore for the backup that you want to restore.
Enter a unique ID for the table that will be created from the backup. You are not able to change this ID later.
Click Restore.
The console displays the Tables page filtered to show the new table.
The console displays the restore status for each cluster. When the status column for all clusters shows Ready the table has been restored and replicated to all clusters in the instance.
gcloud
For all commands, substitute actual values for the following:
INSTANCE_ID
: The permanent identifier for the instance.CLUSTER_ID
: The permanent identifier for the cluster.TABLE_ID
: The ID of the table to be backed up.BACKUP_ID
: The ID you assign to the backup.NEW_TABLE_ID
: The ID for the newly restored table.
If you don't know the instance ID, use the
bigtable instances list
command to view a list of your project's instances:gcloud bigtable instances list
View the list of backups for the instance that contains the backup, to verify the backup exists.
gcloud bigtable backups list --instance=INSTANCE_ID --cluster=CLUSTER_ID
View the list of tables in the instance, so you can choose an ID for the new table that is not already in use.
gcloud bigtable instances tables list --instance=INSTANCE_ID
Restore the backup to a new table.
gcloud bigtable instances tables restore --source-instance=INSTANCE_ID --source-cluster=CLUSTER_ID --source=BACKUP_ID --destination-instance=INSTANCE_ID --destination=NEW_TABLE_ID --async
The
--async
flag is optional. Use it if you want the terminal to return the operation ID before the operation is complete. This is helpful if you want to check the status of the operation.View the list of tables to see if your table has been created.
gcloud bigtable instances tables list --instance=INSTANCE_ID
If the backup is not listed, check the status of the operation.
Checking the status of an operation
Console
Go to the Cloud Bigtable instances page in the Cloud Console.
Click the instance that contains the backup.
In the left navigation pane, click Backups.
On the Backups page, click Activity. The status column displays the current status for each operation.
Operation statuses when restoring a table include the following:
- Waiting to copy
- Restoring backup
- Initializing
- Ready-optimizing
- Ready
Operations statuses when create a backup include the following:
- Creating backup
- Backup complete
gcloud
To check the status of a backup or restore operation, you need the unique ID of the operation. The following is an example of an operation ID:
`instances/instance-name/tables/table-name/locations/us-east1-b/operations/917168358249360635`
After you run a command to create a backup or restore to a new table using
the option --async
, the terminal displays the operation ID.
Copy the operation ID.
Run the following command, substituting the value you copied for
OPERATION_ID
.gcloud bigtable operations describe OPERATION_ID
Example:
gcloud bigtable operations describe instances/instance-name/tables/table-name/locations/us-east1-b/operations/917168358249360635
You can execute this command every few moments until the value for
DONE
isTRUE
.
If you don't know the operation ID, either because you didn't just execute the command or you are in a different terminal window, you can view a list of operations for the instance and determine which operation you want to check.
View a list of recent operation activity for the instance that contains the table you are backing up or restoring, substituting the ID of the instance for
INSTANCE_ID
:gcloud bigtable operations list --instance=INSTANCE_ID
The terminal displays a list of operations in columns labeled
NAME
,START_TIME
,END_TIME
, andDONE
. The value in theNAME
column is the operation ID.Beginning with the first item on the list, copy the operation ID.
Use
gcloud bigtable operations describe
to view metadata for the operation.gcloud bigtable operations describe OPERATION_ID
Example:
gcloud bigtable operations describe instances/instance-name/tables/table-name/locations/us-east1-b/operations/917168358249360635
If the metadata for an operation shows a value for
backupInfo
, you have found the correct operation, and you can repeat this command every so often until the value forDONE
isTRUE
.If the metadata does not show a value for
backupInfo
, check the next operation in the list you created in Step 1.
Modifying a backup
Console
The Cloud Console does not allow you to modify a backup.
gcloud
The gcloud
tool allows you to modify a backup's expiration date or period.
Substitute actual values for the following:
INSTANCE_ID
: The permanent identifier for the instance.CLUSTER_ID
: The permanent identifier for the cluster.BACKUP_ID
: The unique ID for a backup.EXPIRATION_DATE
: A date 30 days or less in the future, formatted as a "Zulu" UTC timestamp, accurate to nanoseconds.Example:
2019-10-02T15:01:23.045123456Z
RETENTION_PERIOD
: A period of up to 30 days, expressed as a number with a unit ofm
,h
, ord
(minutes, hours, or days).Examples:
5m
,36h
, or29d
View a list of backups:
gcloud bigtable backups list --instance=INSTANCE_ID
The terminal displays a list of backups.
Note the backup and cluster IDs for the backup you need to update.
Run the following command. You can set either a new expiration date or a new retention period.
gcloud bigtable backups update BACKUP_ID --instance=INSTANCE_ID --cluster=CLUSTER_ID --expiration-date=EXPIRATION_DATE | --retention-period=RETENTION_PERIOD
Verify that you have successfully updated the expiration:
gcloud bigtable backups describe BACKUP_ID --instance=INSTANCE_ID --cluster=CLUSTER_ID
Deleting a backup
You can delete a backup before its scheduled expiration.
Console
Go to the Cloud Bigtable instances page in the Cloud Console.
Click the instance that contains the backup.
In the left navigation pane, click Backups.
For the backup you need to delete, expand the More menu next to the word Restore, then click Delete.
Enter the backup ID in the Confirm deletion field, then click Delete.
gcloud
View a list of backups, substituting the ID of the instance for
INSTANCE_ID
:gcloud bigtable backups list --instance=INSTANCE
The terminal displays a list of backups.
Note the backup ID and the ID of the cluster it is stored on.
Run the following command, substituting the backup ID you noted for
BACKUP_ID
and the cluster ID forCLUSTER_ID
.gcloud bigtable backups delete BACKUP_ID --instance=INSTANCE_ID --cluster=CLUSTER_ID
What's next
- Read the overview of backups.
- Learn how to import and export Cloud Bigtable data.