2022-03-01 04:29:52 +00:00
|
|
|
NAME
|
|
|
|
|
gcloud sql instances clone - clones a Cloud SQL instance
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
|
gcloud sql instances clone SOURCE DESTINATION [--async]
|
2026-02-11 11:28:25 +00:00
|
|
|
[--destination-network=DESTINATION_NETWORK]
|
|
|
|
|
[--destination-project=DESTINATION_PROJECT]
|
2024-06-06 09:19:36 +00:00
|
|
|
[--preferred-secondary-zone=PREFERRED_SECONDARY_ZONE]
|
|
|
|
|
[--preferred-zone=PREFERRED_ZONE]
|
2025-09-17 11:04:06 +00:00
|
|
|
[--source-instance-deletion-time=SOURCE_INSTANCE_DELETION_TIME]
|
2023-01-19 00:56:33 +00:00
|
|
|
[--bin-log-file-name=BIN_LOG_FILE_NAME
|
|
|
|
|
--bin-log-position=BIN_LOG_POSITION | [--point-in-time=POINT_IN_TIME
|
2024-06-06 09:19:36 +00:00
|
|
|
: --restore-database-name=RESTORE_DATABASE_NAME]]
|
2023-01-19 00:56:33 +00:00
|
|
|
[GCLOUD_WIDE_FLAG ...]
|
2022-03-01 04:29:52 +00:00
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
gcloud sql instances clone creates a clone of a Cloud SQL instance. The
|
|
|
|
|
clone is an independent copy of the source instance with the same data and
|
|
|
|
|
settings. Source and destination instances must be in the same project. An
|
|
|
|
|
instance can be cloned from its current state, or from an earlier point in
|
|
|
|
|
time.
|
|
|
|
|
|
|
|
|
|
For MySQL: The binary log coordinates or timestamp (point in time), if
|
|
|
|
|
specified, act as the point in time the source instance is cloned from. If
|
|
|
|
|
not specified, the current state of the instance is cloned.
|
|
|
|
|
|
|
|
|
|
For PostgreSQL: The point in time, if specified, defines a past state of
|
|
|
|
|
the instance to clone. If not specified, the current state of the instance
|
|
|
|
|
is cloned.
|
|
|
|
|
|
2023-01-19 00:56:33 +00:00
|
|
|
For SQL Server: The point in time, if specified, defines a past state of
|
|
|
|
|
the instance to clone. If not specified, the current state of the instance
|
|
|
|
|
is cloned.
|
|
|
|
|
|
2026-02-11 11:28:25 +00:00
|
|
|
Note: The flags --destination-project and --destination-network are
|
|
|
|
|
currently for allowlisted customers only.
|
|
|
|
|
|
2022-03-01 04:29:52 +00:00
|
|
|
EXAMPLES
|
|
|
|
|
To clone an instance from its current state (most recent binary log
|
|
|
|
|
coordinates):
|
|
|
|
|
|
2025-06-14 05:31:37 +00:00
|
|
|
$ gcloud sql instances clone my-source-instance my-cloned-instance
|
2022-03-01 04:29:52 +00:00
|
|
|
|
|
|
|
|
To clone a MySQL instance from an earlier point in time (past binary log
|
|
|
|
|
coordinates):
|
|
|
|
|
|
2025-06-14 05:31:37 +00:00
|
|
|
$ gcloud sql instances clone my-source-instance my-cloned-instance \
|
2022-03-01 04:29:52 +00:00
|
|
|
--bin-log-file-name mysql-bin.000020 --bin-log-position 170
|
|
|
|
|
|
|
|
|
|
To clone a MySQL source instance at a specific point in time:
|
|
|
|
|
|
2025-06-14 05:31:37 +00:00
|
|
|
$ gcloud sql instances clone my-source-instance my-cloned-instance \
|
2022-03-01 04:29:52 +00:00
|
|
|
--point-in-time '2012-11-15T16:19:00.094Z'
|
|
|
|
|
|
|
|
|
|
To clone a PostgreSQL source instance at a specific point in time:
|
|
|
|
|
|
2025-06-14 05:31:37 +00:00
|
|
|
$ gcloud sql instances clone my-source-instance my-cloned-instance \
|
2022-03-01 04:29:52 +00:00
|
|
|
--point-in-time '2012-11-15T16:19:00.094Z'
|
|
|
|
|
|
2023-01-19 00:56:33 +00:00
|
|
|
To clone a SQL Server source instance at a specific point in time:
|
|
|
|
|
|
2025-06-14 05:31:37 +00:00
|
|
|
$ gcloud sql instances clone my-source-instance my-cloned-instance \
|
2023-01-19 00:56:33 +00:00
|
|
|
--point-in-time '2012-11-15T16:19:00.094Z'
|
|
|
|
|
|
2025-06-14 05:31:37 +00:00
|
|
|
To clone a deleted instance, include the name and deletion time of the
|
|
|
|
|
source instance:
|
|
|
|
|
|
|
|
|
|
$ gcloud sql instances clone my-source-instance my-cloned-instance \
|
|
|
|
|
--source-instance-deletion-time '2012-11-15T16:19:00.094Z'
|
|
|
|
|
|
2022-03-01 04:29:52 +00:00
|
|
|
POSITIONAL ARGUMENTS
|
|
|
|
|
SOURCE
|
|
|
|
|
Cloud SQL instance ID of the source.
|
|
|
|
|
|
|
|
|
|
DESTINATION
|
|
|
|
|
Cloud SQL instance ID of the clone.
|
|
|
|
|
|
|
|
|
|
FLAGS
|
|
|
|
|
--async
|
|
|
|
|
Return immediately, without waiting for the operation in progress to
|
|
|
|
|
complete.
|
|
|
|
|
|
2026-02-11 11:28:25 +00:00
|
|
|
--destination-network=DESTINATION_NETWORK
|
|
|
|
|
The fully qualified URI of the VPC network to which the cloned instance
|
|
|
|
|
will be connected via Private Services Access for private IP. For
|
|
|
|
|
example: projects/my-network-project/global/networks/my-network. This
|
|
|
|
|
field is required only for cross-project cloning.
|
|
|
|
|
|
|
|
|
|
--destination-project=DESTINATION_PROJECT
|
|
|
|
|
The project ID of the destination project where the cloned instance
|
|
|
|
|
will be created. To perform a cross-project clone, this field is
|
|
|
|
|
required. If not specified, the clone is created in the same project as
|
|
|
|
|
the source instance.
|
|
|
|
|
|
2024-06-06 09:19:36 +00:00
|
|
|
--preferred-secondary-zone=PREFERRED_SECONDARY_ZONE
|
|
|
|
|
The preferred secondary zone for the cloned regional instance. If you
|
|
|
|
|
specify a value for this flag, then the destination instance uses the
|
|
|
|
|
value as the secondary zone. The secondary zone can't be the same as
|
|
|
|
|
the primary zone.
|
|
|
|
|
|
|
|
|
|
--preferred-zone=PREFERRED_ZONE
|
|
|
|
|
The preferred zone for the cloned instance. If you specify a value for
|
|
|
|
|
this flag, then the destination instance uses the value as the primary
|
|
|
|
|
zone.
|
|
|
|
|
|
2025-09-17 11:04:06 +00:00
|
|
|
--source-instance-deletion-time=SOURCE_INSTANCE_DELETION_TIME
|
|
|
|
|
The time the source instance was deleted. This is required if cloning
|
|
|
|
|
from a deleted instance.
|
|
|
|
|
|
2022-03-01 04:29:52 +00:00
|
|
|
At most one of these can be specified:
|
|
|
|
|
|
|
|
|
|
Binary log coordinates for point-in-time recovery.
|
|
|
|
|
|
2026-02-11 11:28:25 +00:00
|
|
|
--bin-log-file-name=BIN_LOG_FILE_NAME
|
|
|
|
|
The name of the binary log file. Enable point-in-time recovery on the
|
|
|
|
|
source instance to create a binary log file. If specified with
|
|
|
|
|
<--bin-log-position> to form a valid binary log coordinate, it
|
|
|
|
|
defines an earlier point in time to clone a source instance from. For
|
|
|
|
|
example, mysql-bin.000001.
|
|
|
|
|
|
|
|
|
|
This flag argument must be specified if any of the other arguments in
|
|
|
|
|
this group are specified.
|
|
|
|
|
|
|
|
|
|
--bin-log-position=BIN_LOG_POSITION
|
|
|
|
|
Represents the state of an instance at any given point in time inside
|
|
|
|
|
a binary log file. If specified along with <--bin-log-file-name> to
|
|
|
|
|
form a valid binary log coordinate, it defines an earlier point in
|
|
|
|
|
time to clone a source instance from. For example, 123 (a numeric
|
|
|
|
|
value).
|
|
|
|
|
|
|
|
|
|
This flag argument must be specified if any of the other arguments in
|
|
|
|
|
this group are specified.
|
2022-03-01 04:29:52 +00:00
|
|
|
|
2023-01-19 00:56:33 +00:00
|
|
|
--point-in-time=POINT_IN_TIME
|
|
|
|
|
Represents the state of an instance at any given point in time inside
|
|
|
|
|
a transaction log file. For MySQL, the binary log file is used for
|
|
|
|
|
transaction logs. For PostgreSQL, the write-ahead log file is used
|
|
|
|
|
for transaction logs. For SQL Server, the log backup file is used for
|
|
|
|
|
such purpose. To create a transaction log, enable point-in-time
|
|
|
|
|
recovery on the source instance. Instance should have transaction
|
|
|
|
|
logs accumulated up to the point in time they want to restore up to.
|
|
|
|
|
Uses RFC 3339 format in UTC timezone. If specified, defines a past
|
|
|
|
|
state of the instance to clone. For example,
|
|
|
|
|
'2012-11-15T16:19:00.094Z'.
|
|
|
|
|
|
|
|
|
|
This flag argument must be specified if any of the other arguments in
|
|
|
|
|
this group are specified.
|
|
|
|
|
|
|
|
|
|
--restore-database-name=RESTORE_DATABASE_NAME
|
|
|
|
|
The name of the database to be restored for a point-in-time restore.
|
|
|
|
|
If set, the destination instance will only restore the specified
|
|
|
|
|
database.
|
|
|
|
|
|
2022-03-01 04:29:52 +00:00
|
|
|
GCLOUD WIDE FLAGS
|
|
|
|
|
These flags are available to all commands: --access-token-file, --account,
|
|
|
|
|
--billing-project, --configuration, --flags-file, --flatten, --format,
|
|
|
|
|
--help, --impersonate-service-account, --log-http, --project, --quiet,
|
|
|
|
|
--trace-token, --user-output-enabled, --verbosity.
|
|
|
|
|
|
|
|
|
|
Run $ gcloud help for details.
|
|
|
|
|
|
|
|
|
|
NOTES
|
|
|
|
|
These variants are also available:
|
|
|
|
|
|
|
|
|
|
$ gcloud alpha sql instances clone
|
|
|
|
|
|
|
|
|
|
$ gcloud beta sql instances clone
|
|
|
|
|
|