Exporting Data from Cloud SQL

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


  1. Go to the Cloud SQL Instances page in the Google Cloud Platform Console.

    Go to the Cloud SQL Instances page

  2. Click the instance you want to export data from to open its Instance details page.
  3. Click Export in the button bar.
  4. Under Cloud Storage file, choose where to save your export in Google Cloud Storage.
  5. Enter the name of the database you want to export.
  6. Click Export to start the export.


To export a dump file from an instance to a Google Cloud Storage bucket:

  1. 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.

  2. Describe the instance you are exporting from:
    gcloud sql instances describe [INSTANCE_NAME]
  3. Copy the serviceAccountEmailAddress field.
  4. Add the service account to the bucket ACL as a writer:
    gsutil acl ch -u [SERVICE_ACCOUNT_ADDRESS]:W gs://[BUCKET_NAME]
  5. Export the database:
    gcloud sql instances export [INSTANCE_NAME] gs://[BUCKET_NAME]/sqldumpfile.gz --database [DATABASE_NAME]

    For information about using the export command, see the sql instances export command reference page.

  6. 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.

What's next

Send feedback about...

Cloud SQL for PostgreSQL