Managing backups

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

  1. Go to the Cloud Bigtable instances page in the Cloud Console.

    Open the instance list

  2. Click the instance that contains the table you want to back up.

  3. In the left navigation pane, click Tables.

  4. Click Create backup for the table you want to back up.

  5. 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.)

  6. Enter a unique ID for the backup.

  7. Set an expiration date.

  8. Click Create.

    The console displays the Backups page filtered to show the backup and its details.

  9. 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 of m, h, or d (minutes, hours, or days).

    Examples: 5m, 36h, or 29d

  1. 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
    
  2. 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
    
  3. 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
    
  4. 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.

  5. View the list of backups to see if your backup has been created.

    gcloud bigtable backups list --instance-INSTANCE_ID
    --cluster=CLUSTER_ID
    
  6. 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

  1. Go to the Cloud Bigtable instances page in the Cloud Console.

    Open the instance list

  2. Click the instance that contains the table you want to back up.

  3. In the left navigation pane, click Backups.

  4. Click Restore for the table you want to back up.

  5. Enter a unique ID for the table that will be created from the backup. You are not able to change this ID later.

  6. 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.
  1. 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
    
  2. 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
    
  3. 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
    
  4. 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.

  5. View the list of tables to see if your table has been created.

    gcloud bigtable instances tables list --instance=INSTANCE_ID
    
  6. If the backup is not listed, check the status of the operation.

Checking the status of an operation

Console

  1. Go to the Cloud Bigtable instances page in the Cloud Console.

    Open the instance list

  2. Click the instance that contains the backup.

  3. In the left navigation pane, click Backups.

  4. 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.

  1. Copy the operation ID.

  2. 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 is TRUE.

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.

  1. 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, and DONE. The value in the NAME column is the operation ID.

  2. Beginning with the first item on the list, copy the operation ID.

  3. 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
    
  4. 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 for DONE is TRUE.

    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 of m, h, or d (minutes, hours, or days).

    Examples: 5m, 36h, or 29d

  1. View a list of backups:

    gcloud bigtable backups list --instance=INSTANCE_ID
    

    The terminal displays a list of backups.

  2. Note the backup and cluster IDs for the backup you need to update.

  3. 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
    
  4. 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

  1. Go to the Cloud Bigtable instances page in the Cloud Console.

    Open the instance list

  2. Click the instance that contains the backup.

  3. In the left navigation pane, click Backups.

  4. For the backup you need to delete, expand the More menu next to the word Restore, then click Delete.

  5. Enter the backup ID in the Confirm deletion field, then click Delete.

gcloud

  1. 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.

  2. Note the backup ID and the ID of the cluster it is stored on.

  3. Run the following command, substituting the backup ID you noted for BACKUP_ID and the cluster ID for CLUSTER_ID.

    gcloud bigtable backups delete BACKUP_ID --instance=INSTANCE_ID --cluster=CLUSTER_ID

What's next