Clone a database cluster

You can clone a database cluster to create a new database cluster that contains the same data as the original cluster. Cloning is a good way to make database clusters for testing purposes.

You can specify any point in time to base the clone on. You aren't limited to cloning the present state of a database cluster. The database service clones a new database cluster at the exact point in time you specify.

You can clone a database cluster with the GDC console or with the gdcloud CLI tool:

Console

  1. From the main menu of the GDC console, choose Database Service.
  2. Select the database cluster to clone.
  3. Click add_box CLONE.
  4. In the Create a clone dialog, specify the point in time to clone from and specify an ID for the new database cluster.
  5. Click CLONE. This takes you to the Database cluster overview page for the new cluster where you can monitor its status.

gdcloud CLI

Use the following command to clone a database cluster:

gdcloud database clusters clone SOURCE \
   DESTINATION --point-in-time POINT_IN_TIME

Replace the following:

  • SOURCE with the name of the database cluster to create a clone from.
  • DESTINATION with the name of the new database cluster to create.
  • POINT_IN_TIME with the timestamp of the point in time to use as the basis of the clone. Use the RFC 3339 timestamp format (yyyy-MM-dd'T'HH:mm:ss'Z').

API

To clone a database cluster, create a Restore resource:

apiVersion: DBENGINE_NAME.dbadmin.gdc.goog/v1
kind: Restore
metadata:
  name: NEW_DBCLUSTER_NAME_restore
spec:
  sourceDBCluster: DBCLUSTER_NAME
  pointInTime: POINT_IN_TIME
  clonedDBClusterConfig:
    dbclusterName: NEW_DBCLUSTER_NAME

Replace the following:

  • DBENGINE_NAME: the name of the database cluster to clone from.
  • NEW_DBCLUSTER_NAME: the name of the new database cluster to create.
  • POINT_IN_TIME: the timestamp of the point in time to use as the basis of the clone. Use the RFC 3339 timestamp format (yyyy-MM-dd'T'HH:mm:ss'Z').