Backup restore to different instance, in different project

7,446 views
Skip to first unread message

Dan Gardner

unread,
Jan 24, 2017, 12:25:52 PM1/24/17
to Google Cloud SQL discuss
I'm failing to restore a backup from a source instance to a target instance when each instance is in a different project.  Is this simply not supported ?

I get ambiguous permissions error from the target instance restore cmd**.   Also if I look in the console no option is offered to target instances in diff projects,  resonable I suppose for thr console.  

I guess unless you can pass a project in the restoreBackupContext json, as below, this isn't supported yet ?
  
curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
     
--header 'Content-Type: application/json' \
     
--data '{ "restoreBackupContext": {"backupRunId": "[BACKUP_ID]", "instanceId": "[SOURCE_INSTANCE_NAME]", "kind": "sql#restoreBackupContext"}}' \
     
-X POST \
     https
://www.googleapis.com/sql/v1beta4/projects/[PROJECT-ID]/instances/[TARGET_INSTANCE_NAME]/restoreBackup

David Newgas

unread,
Jan 24, 2017, 1:08:31 PM1/24/17
to Google Cloud SQL discuss
Hi,

I just dug into our code and I can confirm that there is not currently a way to do this via our API. I can see that we do have an feature request open internally for this, and I will mention that you are interested in this on it. However I don't expect that it will be implemented in the short term.

The "next best thing" is to restore to an instance in the same project, export the database to GCS and then import it into an instance in another project.

Yours,
David

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/75aa9ab4-fbd2-48cb-96c3-f6ee4b2a86be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dan Gardner

unread,
Jan 24, 2017, 1:35:37 PM1/24/17
to Google Cloud SQL discuss
Thanks David,  I agree.  Was hoping to avoid replacing the CloudSQL backup strategy with rolling our own, but hey ho.  Just FYI our use case is that we need to segregate environments by GCP project +  I always like a daily automatic backsync data from a Production environment back through TEST,SI Ci etc.  I also like to utilise a backup / restore approach as an easy way to also verify the Production backup into the bargain.  Thx.

David Newgas

unread,
Jan 24, 2017, 1:36:57 PM1/24/17
to Google Cloud SQL discuss
Thanks for the context - use cases are really helpful for feature requests!

David

To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscr...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsub...@googlegroups.com.

Gary Krige

unread,
Mar 29, 2017, 9:26:29 AM3/29/17
to Google Cloud SQL discuss
We have the exact same use case and would love to see this feature.


On Tuesday, 24 January 2017 20:36:57 UTC+2, David Newgas wrote:
Thanks for the context - use cases are really helpful for feature requests!

David
On Tue, Jan 24, 2017 at 10:35 AM, Dan Gardner <dan.g...@baddogdown.com> wrote:
Thanks David,  I agree.  Was hoping to avoid replacing the CloudSQL backup strategy with rolling our own, but hey ho.  Just FYI our use case is that we need to segregate environments by GCP project +  I always like a daily automatic backsync data from a Production environment back through TEST,SI Ci etc.  I also like to utilise a backup / restore approach as an easy way to also verify the Production backup into the bargain.  Thx.
 

On Tuesday, 24 January 2017 18:08:31 UTC, David Newgas wrote:
Hi,

I just dug into our code and I can confirm that there is not currently a way to do this via our API. I can see that we do have an feature request open internally for this, and I will mention that you are interested in this on it. However I don't expect that it will be implemented in the short term.

The "next best thing" is to restore to an instance in the same project, export the database to GCS and then import it into an instance in another project.

Yours,
David
On Tue, Jan 24, 2017 at 6:53 AM, Dan Gardner <dan.g...@baddogdown.com> wrote:
I'm failing to restore a backup from a source instance to a target instance when each instance is in a different project.  Is this simply not supported ?

I get ambiguous permissions error from the target instance restore cmd**.   Also if I look in the console no option is offered to target instances in diff projects,  resonable I suppose for thr console.  

I guess unless you can pass a project in the restoreBackupContext json, as below, this isn't supported yet ?
  
curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
     
--header 'Content-Type: application/json' \
     
--data '{ "restoreBackupContext": {"backupRunId": "[BACKUP_ID]", "instanceId": "[SOURCE_INSTANCE_NAME]", "kind": "sql#restoreBackupContext"}}' \
     
-X POST \
     https
://www.googleapis.com/sql/v1beta4/projects/[PROJECT-ID]/instances/[TARGET_INSTANCE_NAME]/restoreBackup

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/75aa9ab4-fbd2-48cb-96c3-f6ee4b2a86be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matt Jackson

unread,
Aug 15, 2018, 9:35:01 AM8/15/18
to Google Cloud SQL discuss
Was this feature ever prioritised? We have a similar use case

Julie (cloud platform support)

unread,
Aug 15, 2018, 12:15:02 PM8/15/18
to Google Cloud SQL discuss
This issue tracker can be used to track the progress of this feature request as further updates will be posted there. Please note that feature requests are not guaranteed and there is no ETA on this feature.

Jiří Zavadil

unread,
Dec 6, 2018, 7:20:34 PM12/6/18
to Google Cloud SQL discuss
Found a way, you can do:
gcloud sql export sql db-production gs://someproject-development-bucket/db-production_dump.sql --project someproject-production && \
gcloud sql import sql db-development gs://someproject-development-bucket/db-production_dump.sql --project someproject-development

As long as permissions are set, you can import/export to/from any project to/from any project.

---

Our setup:
  
project-development:
- Cloud SQL: db-development
- Cloud Storage: bucket-development
- Cloud Build: clone-prod-to-dev

project-production:
- Cloud SQL: db-production

// YAML from Cloud Build trigger:
steps:
  
  # export SQL databases
    args: [
      'sql', 'export', 'sql',
      'db-production',
      'gs://someproject-development-bucket/db-production_dump-$BUILD_ID.sql',
      '--project', 'someproject-production'
    ]
    waitFor: ['-']
    id: 'sql-export'
    
  # import SQL databases
    args: [
      'sql', 'import', 'sql',
      'db-development',
      'gs://someproject-development-bucket/db-production_dump-$BUILD_ID.sql',
      '--project', 'someproject-development'
    ]
    waitFor: ['sql-export']
Reply all
Reply to author
Forward
0 new messages