0

I'm trying to restore my Google Cloud SQL instance to a backup from a previous date:

gcloud sql backups restore 1504554300110 --restore-instance=[MY-DB-INSTANCE]

Ultimately, it keeps giving an error:

ERROR: (gcloud.sql.backups.restore) HTTPError 503: Service temporarily unavailable.

I have been trying every day for a week now and continue to get the same error message. I have tried both the web UI and using the gcloud command and neither one seem to work. Anyone have any suggestions?

2

To restore a backup from the same instance:

gcloud sql backups restore [BACKUP_ID] --restore-instance=[INSTANCE_NAME]

To restore a backup from a different instance:

gcloud sql backups restore [BACKUP_ID] --restore-instance=[TARGET_INSTANCE_NAME] \
                                      --backup-instance=[SOURCE_INSTANCE_NAME]

Before you do the above, make sure to run:

gcloud sql backups list --instance [INSTANCE_NAME]

find the backup you want to use, record its ID value, and select a backup that is marked 'SUCCESSFUL'

Here is the complete documentation about Restoring an Instance.

2
  • Yes, as mentioned in the original question, I have tried gcloud restore command. I have read and followed the docs, but this issue is that I get a service error when running the commands. – matt Sep 13 '17 at 15:13
  • @matt, what is the result when you run "gcloud sql instances describe [INSTANCE_NAME]" and "gcloud sql backups list --instance [INSTANCE_NAME]" – Kenworth Sep 13 '17 at 21:51
0

This answer may be too late for you, but I am leaving an answer here just in case it can help someone else.

As pointed out by @Kenworth, the documentation page about Restoring a Cloud SQL instance contains all the information related to how that can be achieved and what are its implications.

However, it seems that both the gcloud and Console approaches did not work for you, so you need to try with something else, which can be making API calls for restoring the desired backup. You can do that in two ways:

Using curl: Get an access token, then list the available backups for the instance, and finally restore it.

echo "Getting Access Token"
ACCESS_TOKEN="$(gcloud auth print-access-token)"

echo "List available backups for the instance [INSTANCE_NAME] in [PROJECT_ID]"
curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
     -X GET \
     https://www.googleapis.com/sql/v1beta4/projects/[PROJECT_ID]/instances/[INSTANCE_NAME]/backupRuns

echo "Restore backup [BACKUP_ID] in instance [INSTANCE_NAME] in [PROJECT_ID]"
curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
     --header 'Content-Type: application/json' \
     --data '{ "restoreBackupContext": {"backupRunId": "[BACKUP_ID]"}}' \
     -X POST \
     https://www.googleapis.com/sql/v1beta4/projects/[PROJECT-ID]/instances/[INSTANCE_NAME]/restoreBackup

Using APIs Explorer: It is the same as with the CURL command, but you have a web UI to make the API calls. First list the available backups, then choose the one you want to restore, and finally restore it.

If you still have problems with restoring a backup in your Cloud SQL instance, you should contact Google Cloud Platform Support in order for us to be able to help you further.

1
  • This published API only seems to work if you are restoring to the same instance. Our instance is hosed, so we need to restore to a different instance. – Alex Ryan Feb 12 '19 at 2:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.