Copying table snapshots

This document describes how to make a copy of a table snapshot using a SQL query, the bq command-line tool, or the jobs.insert API. It is intended for users who are familiar with BigQuery table snapshots.

Permissions and roles

This section describes the Identity and Access Management (IAM) permissions that you need to make a copy of a table snapshot, and the predefined IAM roles that grant those permissions.

Permissions

To copy a table snapshot, you need all of the following permissions:

Permission Resource
bigquery.tables.get The table snapshot that you want to copy.
bigquery.tables.getData The table snapshot that you want to copy.
bigquery.tables.createSnapshot The table snapshot that you want to copy.
bigquery.tables.create The dataset that contains the copy of the table snapshot.

Roles

The minimum predefined roles you need to copy a table snapshot are the following:

Role Resource
bigquery.dataEditor The table snapshot that you want to copy.
bigquery.dataEditor The dataset that contains the copy of the table snapshot.

Limitations

For information about table snapshot limitations, see table snapshot limitations.

Copy a table snapshot

The process for making a copy of a table snapshot is similar to the process for creating a snapshot of a table. The difference is that you specify the table snapshot that you want to copy as the source table.

For example, make a copy of the library_backup.books table snapshot in the library_snapshots_backup dataset as follows:

SQL

Run the following query:

CREATE SNAPSHOT TABLE
  myproject.library_snapshot_backup.books
  CLONE myproject.library_backup.books

bq

Enter the following command in the Cloud Shell:

Go to Cloud Shell

bq cp --no_clobber --expiration=86400 library_backup.books \
  library_snapshot_backup.books

The --no_clobber flag is required.

API

Call the jobs.insert method with the following parameters:

Parameter Value
projectId myProject
Request body
{
  "configuration": {
    "copy": {
      "sourceTables": [
        {
          "projectId": "myProject",
          "datasetId": "library_backup",
          "tableId": "books"
        }
      ],
      "destinationTable": {
        "projectId": "myProject",
        "datasetId": "library_snapshot_backup",
        "tableId": "books"
      },
      "writeDisposition": "WRITE_EMPTY"
    }
  }
}

Table security

To control access to tables in BigQuery, see Introduction to table access controls.

What's next