Perform point-in-time recovery (PITR)

MySQL  |  PostgreSQL  |  SQL Server

You can use point-in-time-recovery (PITR) to restore your primary Cloud SQLinstances whether the instance is live, or is deleted. PITR lets you restorethe instance to a specific point-in-time. For a deleted instance, youcan restore the instance to a specific point-in-time to a new or existinginstance.

Cloud SQL provides the following options to restore your instanceusing PITR:

For performing a PITR on an unavailable or deleted instance, you'll need tofind thelatest and earliest recovery time.

Perform a PITR

Console

  1. In the Google Cloud console, go to theCloud SQL Instances page.

    Go to Cloud SQL Instances

  2. Open the more actions menuMore actions icon. for the instance you want to recover and clickCreate clone.
  3. Optionally, on theCreate a clone page, update the ID of the new clone.
  4. SelectClone from an earlier point in time.
  5. Enter a PITR time.
  6. ClickCreate clone.

gcloud

Create a clone using PITR.

Replace the following:

  • SOURCE_INSTANCE_NAME - Name of the instance you're restoring from.
  • NEW_INSTANCE_NAME - Name for the clone.
  • TIMESTAMP - UTC timezone for the source instance in RFC 3339 format. For example, 2012-11-15T16:19:00.094Z.
gcloudsqlinstancescloneSOURCE_INSTANCE_NAME\NEW_INSTANCE_NAME\--point-in-time'TIMESTAMP'

REST v1

Before using any of the request data, make the following replacements:

  • project-id: The project ID
  • target-instance-id: The target instance ID
  • source-instance-id: The source instance ID
  • restore-timestamp The point-in-time to restore up to

HTTP method and URL:

POST https://sqladmin.googleapis.com/v1/projects/project-id/instances/source-instance-id/clone

Request JSON body:

{  "cloneContext":  {    "kind": "sql#cloneContext",    "destinationInstanceName": "target-instance-id",    "pointInTime": "restore-timestamp"  }}

To send your request, expand one of these options:

curl (Linux, macOS, or Cloud Shell)

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://sqladmin.googleapis.com/v1/projects/project-id/instances/source-instance-id/clone"

PowerShell (Windows)

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://sqladmin.googleapis.com/v1/projects/project-id/instances/source-instance-id/clone" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

Response

{  "kind": "sql#operation",  "targetLink": "https://sqladmin.googleapis.com/v1/projects/project-id/instances/target-instance-id",  "status": "PENDING",  "user": "user@example.com",  "insertTime": "2020-01-21T22:43:37.981Z",  "operationType": "CREATE",  "name": "operation-id",  "targetId": "target-instance-id",  "selfLink": "https://sqladmin.googleapis.com/v1/projects/project-id/operations/operation-id",  "targetProject": "project-id"}

REST v1beta4

Before using any of the request data, make the following replacements:

  • project-id: The project ID
  • target-instance-id: The target instance ID
  • source-instance-id: The source instance ID
  • restore-timestamp The point-in-time to restore up to

HTTP method and URL:

POST https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/source-instance-id/clone

Request JSON body:

{  "cloneContext":  {    "kind": "sql#cloneContext",    "destinationInstanceName": "target-instance-id",    "pointInTime": "restore-timestamp"  }}

To send your request, expand one of these options:

curl (Linux, macOS, or Cloud Shell)

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/source-instance-id/clone"

PowerShell (Windows)

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/source-instance-id/clone" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

Response

{  "kind": "sql#operation",  "targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/target-instance-id",  "status": "PENDING",  "user": "user@example.com",  "insertTime": "2020-01-21T22:43:37.981Z",  "operationType": "CREATE",  "name": "operation-id",  "targetId": "target-instance-id",  "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/operations/operation-id",  "targetProject": "project-id"}

Perform a PITR using the backup vault

Preview —Enhanced backups

This feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of theService Specific Terms. You can process personal data for this feature as outlined in theCloud Data Processing Addendum, subject to the obligations and restrictions described in the agreement under which you access Google Cloud. Pre-GA features are available "as is" and might have limited support. For more information, see thelaunch stage descriptions.

If your Cloud SQL instance is enabled to useenhanced backups,then you can perform point-in-time-recovery for your instance using thebackup vault.

Console

  1. In the Google Cloud console, go to theCloud SQL Instances page.

    Go to Cloud SQL Instances

  2. Open the more actions menuMore actions icon. for the instance youwant to recover and clickCreate clone.

  3. SelectClone from an earlier point in time.

  4. Enter a PITR time.

  5. ClickCreate clone.

gcloud

To perform a PITR on an instance from the backup vault, you'll need to find thedata-source for the backup that is nearest to the time you want to performthe PITR. To find the backup, seeList all the backups in the backup vault for an instance. Once you've identified the backup, run the following command to perform the PITR:

gcloud sql instances point-in-time-restoreDATA_SOURCEPITR_TIMESTAMP--project=TARGET_PROJECT

Replace the following:

  • DATA_SOURCE: the path of thedata-source for the backupthat is closest to the PITR timestamp you want to recover to.
  • PITR_TIMESTAMP: the UTC timestamp for the sourceinstance PITR log you want to restore your instance to, inRFC 3339 format. For example, 2012-11-15T16:19:00.094Z.
  • TARGET_PROJECT: the project ID of your Cloud SQLinstance.

REST v1

REST v1beta4

Perform PITR on an unavailable instance

Console

You might want to recover aninstance that isn't available to a different zone because of the following reasons:

  • The zone in which the instance is configured isn't accessible. This instance has aFAILED state.
  • The instance is undergoing maintenance. This instance has aMAINTENANCE state.

To recover an unavailable instance, complete the following steps:

  1. In the Google Cloud console, go to theCloud SQL Instances page.

    Go to Cloud SQL Instances

  2. Find the row of the instance to clone.
  3. In theActions column, click theMore Actions menu.
  4. ClickCreate clone.
  5. On theCreate a clone page, complete the following actions:
    1. In theInstance ID field, update the instance ID, if needed.
    2. ClickClone from an earlier point in time.
    3. In thePoint in time field, select a date and time from which you want to clone data. This recovers the state of the instance from that point in time.
    4. ClickCreate clone.
  6. While the clone initializes, you're returned to the instance listing page.

gcloud

You might want to recover aninstance that isn't available to a different zone because the zone in which the instance is configured isn't accessible.

gcloudsqlinstancescloneSOURCE_INSTANCE_NAMETARGET_INSTANCE_NAME\--point-in-timeDATE_AND_TIME_STAMP\--preferred-zoneZONE_NAME\--preferred-secondary-zoneSECONDARY_ZONE_NAME

The user or service account that's running thegcloud sql instances clonecommand must have thecloudsql.instances.clone permission. For moreinformation about required permissions to rungcloud CLI commands, seeCloud SQL permissions.

REST v1

You might want to recover aninstance that isn't available to a different zone because the zone in which the instance is configured isn't accessible.

Before using any of the request data, make the following replacements:

  • PROJECT_ID: the project ID.
  • SOURCE_INSTANCE_NAME: the name of the source instance.
  • TARGET_INSTANCE_NAME: the name of the target (cloned) instance.
  • DATE_AND_TIME_STAMP: a date-and-time stamp for the source instance in theUTC time zone and in theRFC 3339 format (for example,
    2012-11-15T16:19:00.094Z).
  • ZONE_NAME: Optional. The name of the primary zone for the target instance. This is used to specify a different primary zone for the Cloud SQL instance that you want to clone. For a regional instance, this zone replaces the primary zone, but the secondary zone remains the same as the instance.
  • SECONDARY_ZONE_NAME: Optional. The name of the secondary zone for the target instance. This is used to specify a different secondary zone for the regional Cloud SQL instance that you want to clone.

HTTP method and URL:

POST https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/SOURCE_INSTANCE_NAME/clone

Request JSON body:

{  "cloneContext":  {    "destinationInstanceName": "TARGET_INSTANCE_NAME",    "pointInTime": "DATE_AND_TIME_STAMP",    "preferredZone": "ZONE_NAME",    "preferredSecondaryZone": "SECONDARY_ZONE_NAME"  }}

To send your request, expand one of these options:

curl (Linux, macOS, or Cloud Shell)

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/SOURCE_INSTANCE_NAME/clone"

PowerShell (Windows)

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/SOURCE_INSTANCE_NAME/clone" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

Response

{  "kind": "sql#operation",  "targetLink": "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/TARGET_INSTANCE_NAME",  "status": "PENDING",  "user": "user@example.com",  "insertTime": "2020-01-21T22:43:37.981Z",  "operationType": "CLONE",  "name": "OPERATION_ID",  "targetId": "TARGET_INSTANCE_NAME",  "selfLink": "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/operations/OPERATION_ID",  "targetProject": "PROJECT_ID",  "instanceUid": "INSTANCE_ID"}

The user or service account that's using theinstances.clone API method must have thecloudsql.instances.clone permission. For more information about required permissions to use API methods, seeCloud SQL permissions.

REST v1beta4

You might want to recover aninstance that isn't available to a different zone because the zone in which the instance is configured isn't accessible.

Before using any of the request data, make the following replacements:

  • PROJECT_ID: the project ID.
  • SOURCE_INSTANCE_NAME: the name of the source instance.
  • TARGET_INSTANCE_NAME: the name of the target (cloned) instance.
  • DATE_AND_TIME_STAMP: a date-and-time stamp for the source instance in theUTC time zone and in theRFC 3339 format(for example,
    2012-11-15T16:19:00.094Z).
  • ZONE_NAME: Optional. The name of the primary zone for the target instance. This is used to specify adifferent primary zone for the Cloud SQL instance that you want to clone. For a regional instance,this zone replaces the primary zone, but the secondary zone remains the same as the instance.
  • SECONDARY_ZONE_NAME: Optional. The name of the secondary zone for the target instance. This is used to specify a different secondary zone for the regional Cloud SQL instance that you want to clone.

HTTP method and URL:

POST https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/SOURCE_INSTANCE_NAME/clone

Request JSON body:

{  "cloneContext":  {    "destinationInstanceName": "TARGET_INSTANCE_NAME",    "pointInTime": "DATE_AND_TIME_STAMP",    "preferredZone": "ZONE_NAME",    "preferredSecondaryZone": "SECONDARY_ZONE_NAME"  }}

To send your request, expand one of these options:

curl (Linux, macOS, or Cloud Shell)

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/SOURCE_INSTANCE_NAME/clone"

PowerShell (Windows)

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/SOURCE_INSTANCE_NAME/clone" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

Response

{  "kind": "sql#operation",  "targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/TARGET_INSTANCE_NAME",  "status": "PENDING",  "user": "user@example.com",  "insertTime": "2020-01-21T22:43:37.981Z",  "operationType": "CLONE",  "name": "OPERATION_ID",  "targetId": "TARGET_INSTANCE_ID",  "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/operations/OPERATION_ID",  "targetProject": "PROJECT_ID",  "instanceUid": "INSTANCE_ID"}

The user or service account that's using theinstances.clone API method must have thecloudsql.instances.clone permission. For more information about required permissions to use API methods, seeCloud SQL permissions.

If you try to create a PITR clone at a time after the latest recoverable time,then the following error message is given:

Thetimestampforpoint-in-timerecoveryisafterthelatestrecoverytimeofTimestampoflatestrecoverytime.Clonetheinstancewithatimethat'searlierthanthisrecoverytime.

Perform PITR on a deleted instance

To use PITR to restore a deleted instance, you'll need:

  • the PITR timestamp (timestamp) you want to restore your instance to
  • the target instance name
  • the time the source instance was deleted (source-instance-deletion-time)

You can usePITR on a deleted instance using gcloud CLI or the Cloud SQLAPI only. For more information, seeRestore a deleted instance using a PITR.

gcloud

Find your PITR window

To find your deleted instance's PITR window, get theearliest and latest recovery timefor your instance. You can select anytime timestamp in this window toperform a PITR.

Find source instance deletion time and log retention days

Thesource-instance-deletion-time andlog-retention-days for thedeleted instance are stored with the retained backups for your instance afterdeletion. To find these values for your deleted instance, seeList retained backups.

Restore using a PITR

To restore your deleted instance using a PITR, run the following command:

gcloud sql instances cloneSOURCE_INSTANCE_NAME \NEW_INSTANCE_NAME \--point-in-time='PITR_TIMESTAMP' \--source-instance-deletion-time=SOURCE_INSTANCE_DELETION_TIMESTAMP

Replace the following:

  • SOURCE_INSTANCE_NAME: the name of the source instancethat you want to restore.
  • NEW_INSTANCE_NAME: the name of the new instance.
  • PITR_TIMESTAMP: the UTC timestamp for the sourceinstance PITR log you want to restore your instance to, inRFC 3339 format. For example,2012-11-15T16:19:00.094Z.
  • SOURCE_INSTANCE_DELETION_TIMESTAMP: the UTC timestampfor the time that the source instance was deleted, in RFC 3339 format.For example, 2012-11-15T16:19:00.094Z.

REST v1

Find your PITR window

To find your deleted instance's PITR window, get theearliest and latest recovery timefor your instance. You can select anytime timestamp in this window toperform a PITR.

Find source instance deletion time and log retention days

Thesource-instance-deletion-time andlog-retention-days for thedeleted instance are stored with the retained backups for your instance afterdeletion. To find these values for your deleted instance, seeList retained backups.

Restore using a PITR

Before using any of the request data, make the following replacements:

  • project-id: the project ID
  • target-instance-id: the target instance ID
  • source-instance-id: the source instance ID
  • source-instance-deletion-time: the deletion time of the source instance
  • restore-timestamp the point-in-time which you want to restore the instance

HTTP method and URL:

POST https://sqladmin.googleapis.com/v1/projects/project-id/instances/source-instance-id/clone

Request JSON body:

{  "cloneContext":  {    "kind": "sql#cloneContext",    "destinationInstanceName": "target-instance-id",    "sourceInstanceDeletionTime: "source-instance-deletion-time",    "pointInTime": "restore-timestamp"  }}

To send your request, expand one of these options:

curl (Linux, macOS, or Cloud Shell)

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://sqladmin.googleapis.com/v1/projects/project-id/instances/source-instance-id/clone"

PowerShell (Windows)

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://sqladmin.googleapis.com/v1/projects/project-id/instances/source-instance-id/clone" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

Response

{  "kind": "sql#operation",  "targetLink": "https://sqladmin.googleapis.com/v1/projects/project-id/instances/target-instance-id",  "status": "PENDING",  "user": "user@example.com",  "insertTime": "2020-01-21T22:43:37.981Z",  "operationType": "CLONE",  "name": "operation-id",  "targetId": "target-instance-id",  "selfLink": "https://sqladmin.googleapis.com/v1/projects/project-id/operations/operation-id",  "targetProject": "project-id"}

REST v1beta4

Find your PITR window

To find your deleted instance's PITR window, get theearliest and latest recovery timefor your instance. You can select anytime timestamp in this window toperform PITR.

Find source instance deletion time and log retention days

Thesource-instance-deletion-time andlog-retention-days for thedeleted instance are stored with the retained backups for your instance afterdeletion. To find these values for your deleted instance, seeList retained backups.

Restore using PITR

Before using any of the request data, make the following replacements:

  • project-id: the project ID
  • target-instance-id: the target instance ID
  • source-instance-id: the source instance ID
  • source-instance-deletion-time: the deletion time of the source instance
  • restore-timestamp the point-in-time which you want to restore the instance

HTTP method and URL:

POST https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/source-instance-id/clone

Request JSON body:

{  "cloneContext":  {    "kind": "sql#cloneContext",    "destinationInstanceName": "target-instance-id",    "sourceInstanceDeletionTime: "source-instance-deletion-time",    "pointInTime": "restore-timestamp"  }}

To send your request, expand one of these options:

curl (Linux, macOS, or Cloud Shell)

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/source-instance-id/clone"

PowerShell (Windows)

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/source-instance-id/clone" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

Response

{  "kind": "sql#operation",  "targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/target-instance-id",  "status": "PENDING",  "user": "user@example.com",  "insertTime": "2020-01-21T22:43:37.981Z",  "operationType": "CREATE",  "name": "operation-id",  "targetId": "target-instance-id",  "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/operations/operation-id",  "targetProject": "project-id"}

Get the earliest and latest recovery time

For an available instance, you can perform a PITR to any timestamp in theinstance's PITR window. The PITR window starts a the earliest recovery timeand ends at the latest recovery time. If theinstance is unavailable and the instance logs are stored inCloud Storage,or the instance was deleted and hadPITR retention enabled,then you can retrieve the earliest and latest recovery time, and perform thePITR to any timestamp in that window.In all cases, you canrestore the instance to a different primary or secondary zoneby providing values for the preferred zones.

gcloud

Unavailable instance

To get the earliest and latest time to which you can recover aCloud SQL instance that's not available, run the following command:

gcloud sql instances get-latest-recovery-timeINSTANCE_NAME

Replace the following:

  • INSTANCE_NAME: the name of the instance you want tofind the latest recovery time for.

Deleted instance

To get the earliest and latest time to which you can recover aCloud SQL deleted instance to, run the following command:

gcloud sql instances get-latest-recovery-timeINSTANCE_NAME--source-instance-deletion-time='SOURCE_INSTANCE_DELETION_TIMESTAMP'

Replace the following:

  • INSTANCE_NAME: the name of the instance you want tofind the latest recovery time for.
  • SOURCE_INSTANCE_DELETION_TIMESTAMP: the UTC timestampfor the time that the source instance was deleted, in RFC 3339 format.For example, 2012-11-15T16:19:00.094Z.

REST v1

Unavailable instance

Before using any of the request data, make the following replacements:

  • PROJECT_ID: the project ID
  • INSTANCE_NAME: the name of the instance for which you're querying for the latest recovery time

HTTP method and URL:

GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_NAME/getLatestRecoveryTime

To send your request, expand one of these options:

curl (Linux, macOS, or Cloud Shell)

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Execute the following command:

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_NAME/getLatestRecoveryTime"

PowerShell (Windows)

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_NAME/getLatestRecoveryTime" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{  "kind": "sql#getLatestRecoveryTime",  "earliestRecoveryTime": "2023-06-10T17:23:59.648821586Z",  "latestRecoveryTime": "2023-06-20T17:23:59.648821586Z"}

Deleted instance

Before using any of the request data, make the following replacements:

  • PROJECT_ID: the project ID
  • INSTANCE_NAME: the name of the source instance for which you're querying for the latest recovery time
  • SOURCE_INSTANCE_DELETION_TIME: the time that the source instance was deleted

HTTP method and URL:

GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_NAME/getLatestRecoveryTime

To send your request, expand one of these options:

curl (Linux, macOS, or Cloud Shell)

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Execute the following command:

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_NAME/getLatestRecoveryTime"

PowerShell (Windows)

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_NAME/getLatestRecoveryTime" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{  "kind": "sql#getLatestRecoveryTime",  "earliestRecoveryTime": "2023-06-10T17:23:59.648821586Z",  "latestRecoveryTime": "2023-06-20T17:23:59.648821586Z"}

REST v1beta4

Unavailable instance

Before using any of the request data, make the following replacements:

  • PROJECT_ID: the project ID
  • INSTANCE_NAME: the name of the instance for which you're querying for the latest recovery time

HTTP method and URL:

GET https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/INSTANCE_NAME/getLatestRecoveryTime

To send your request, expand one of these options:

curl (Linux, macOS, or Cloud Shell)

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Execute the following command:

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/INSTANCE_NAME/getLatestRecoveryTime"

PowerShell (Windows)

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/INSTANCE_NAME/getLatestRecoveryTime" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{  "kind": "sql#getLatestRecoveryTime",  "earliestRecoveryTime": "2023-06-10T17:23:59.648821586Z",  "latestRecoveryTime": "2023-06-20T17:23:59.648821586Z"}

Deleted instance

Before using any of the request data, make the following replacements:

  • PROJECT_ID: the project ID
  • INSTANCE_NAME: the name of the source instance for which you're querying for the latest recovery time
  • SOURCE_INSTANCE_DELETION_TIME: the time that the source instance was deleted

HTTP method and URL:

GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_NAME/getLatestRecoveryTime

To send your request, expand one of these options:

curl (Linux, macOS, or Cloud Shell)

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Execute the following command:

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_NAME/getLatestRecoveryTime"

PowerShell (Windows)

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_NAME/getLatestRecoveryTime" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{  "kind": "sql#getLatestRecoveryTime",  "earliestRecoveryTime": "2023-06-10T17:23:59.648821586Z",  "latestRecoveryTime": "2023-06-20T17:23:59.648821586Z"}

Troubleshoot

IssueTroubleshooting

argument --point-in-time: Failed to parse date/time:
Unknown string format: 2021-0928T30:54:03.094;
received: 2021-0928T30:54:03.094Z

OR

Invalid value at 'body.clone_context.point_in_time'
(type.googleapis.com/google.protobuf.Timestamp), Field 'pointInTime',
Invalid time format: Failed to parse input,

The timestamp you provided is invalid.

HTTP Error 400: Successful backup required for carrying out the operation was not found.

OR

Successful backup required for carrying out the operation was not found. or Time where no backups can be found.

The timestamp that you provided is for a time where backups or when binlog coordinates could not be found.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-11-24 UTC.