Skip to content

Instantly share code, notes, and snippets.

@eenchev
Created March 27, 2020 07:08
Show Gist options
  • Save eenchev/a55cd7ecac80d422108c6d924f8d5c18 to your computer and use it in GitHub Desktop.
Save eenchev/a55cd7ecac80d422108c6d924f8d5c18 to your computer and use it in GitHub Desktop.
Export Google Cloud SQL to bucket

create a bucket if you don't have one, run

gsutil mb -p [PROJECT_NAME] -l [LOCATION_NAME] gs://[BUCKET_NAME] Describe the sql instance you are exporting from and copy the sa

gcloud sql instances describe [INSTANCE_NAME] Add the service account to the bucket ACL as a writer

gsutil acl ch -u [SERVICE_ACCOUNT_ADDRESS]:W gs://[BUCKET_NAME] Add the service account to the import file as a reader

gsutil acl ch -u [SERVICE_ACCOUNT_ADDRESS]:R gs://[BUCKET_NAME]/[IMPORT_FILE_NAME] Import the file: gcloud sql import csv [INSTANCE_NAME] gs://[BUCKET_NAME]/[FILE_NAME]
--database=[DATABASE_NAME] --table=[TABLE_NAME]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment