How can I Share and restore cloud sql backup files across account ( project )
For those that stumble across this post 2018. It is now possible to restore cloudSQL between projects. As of this post you still need to use curl but it does work. The link below is to the mysql docs but I got it to work fine with SQL Server.
https://cloud.google.com/sql/docs/mysql/backup-recovery/restoring#projectid
Unfortunately, you cannot restore an instance using a backup created in a different project, as stated in the documentation for instance restoration:
When you are restoring a backup to a different instance, keep in mind the following restrictions and best practices:
- You cannot restore an instance using a backup taken in a different GCP project.
- ...
Maybe the following is not your specific use case, but should you replicate your instance in a new project, you should follow these steps: export your data to a SQL dump or CSV file, and then import it in a new instance in your other project. Here it is a more detailed guide on how to achieve that:
- Export data from your current Cloud SQL instance in a format that can be later usable by Cloud SQL.
- Create a new Cloud SQL instance in the project of your choice. Select the same characteristics as the one in your current instance, or the ones that fit your future requirements better.
- Create the databases and tables in your new instance.
- Import the previously created dump/CSV file to the new instance [4].
Once these steps are completed, you should have a new Cloud SQL instance with the same data as the one in the old instance at the moment of creation of the export files.
However, as I already said, this is not restoring from a backup, so you cannot recover a previous instance state into an instance in a different project.
Restoring a Cloud SQL Backup to a Different Project Instance
Method 1: Using Google Cloud APIs
- Offers more flexibility and can be automated.
- Follow the detailed guide: here
Method 2: Following the Official Cloud SQL Documentation
- Provides a step-by-step process using the Cloud SQL REST API.
- Find the instructions: here
Important Note:
- Ensure you have the necessary permissions (cloudsql.instances.restoreBackup for the target project and cloudsql.backupRuns.get for the source instance).
© 2022 - 2024 — McMap. All rights reserved.