This page describes how to export data from Google Cloud SQL to Google Cloud Storage. You can then download your data from Cloud Storage to your local environment if you want to access it locally.
Exporting data to a SQL dump file
- Go to the Cloud SQL Instances page in the Google Cloud Platform Console.
- Click the instance you want to export data from to open its Instance details page.
- Click Export in the button bar.
- Under Cloud Storage file, choose where to save your export in Google Cloud Storage.
- Enter the name of the database you want to export.
- Click Export to start the export.
To export a dump file from an instance to a Google Cloud Storage bucket:
- Create a bucket for the export:
gsutil mb -p [PROJECT_NAME] -l [LOCATION_NAME] gs://[BUCKET_NAME]
This step is not required, but strongly recommended, so you do not open up access to any other data.
- Describe the instance you are exporting from:
gcloud beta sql instances describe [INSTANCE_NAME]
- Copy the serviceAccountEmailAddress field.
- Add the service account to the bucket ACL as a writer:
gsutil acl ch -u [SERVICE_ACCOUNT_ADDRESS]:W gs://[BUCKET_NAME]
- Export the database:
gcloud beta sql instances export [INSTANCE_NAME] gs://[BUCKET_NAME]/sqldumpfile.gz --database [DATABASE_NAME]
For information about using the export command, see the
sql instances exportcommand reference page.
- Remove the service account from the bucket ACL:
gsutil acl ch -d [SERVICE_ACCOUNT_ADDRESS] gs://[BUCKET_NAME]
This step is strongly recommended for security.
- Learn how to check the status of import and export operations.