gcloud sql export sql Stay organized with collections Save and categorize content based on your preferences.
- NAME
- gcloud sql export sql - exports data from a Cloud SQL instance to a SQL file
- SYNOPSIS
gcloud sql export sqlINSTANCEURI[--async][--clean][--database=DATABASE,[DATABASE,…],-dDATABASE,[DATABASE,…]][--if-exists][--offload][--parallel][--table=TABLE,[TABLE,…],-tTABLE,[TABLE,…]][--threads=THREADS][GCLOUD_WIDE_FLAG …]
- DESCRIPTION
- Exports data from a Cloud SQL instance to a Google Cloud Storage bucket as a SQLdump file.
NOTE: Certain roles and permissions are required to export data to Google CloudStorage. For more information on exporting data from Google Cloud SQL seeExportfrom Cloud SQL to a SQL dump file.
- POSITIONAL ARGUMENTS
INSTANCE- Cloud SQL instance ID.
URI- The path to the file in Google Cloud Storage where the export will be stored.The URI is in the form gs://bucketName/fileName. If the file already exists, theoperation fails. If the filename ends with .gz, the contents are compressed.
- FLAGS
--async- Return immediately, without waiting for the operation in progress to complete.
--clean- Include SQL statements (DROP <object>) required to drop database objectsprior to import; corresponds to the clean flag for pg_dump. Only applies toPostgreSQL non-parallel exports.
--database=DATABASE,[DATABASE,…],-dDATABASE,[DATABASE,…]- Database(s) from which the export is made. Information on requirements can befound here:https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/instances/export#exportContext.databases
--if-exists- Include an SQL statement (IF EXISTS) with each drop statement produced by theclean flag; corresponds to the if-exists flag for pg_dump. Only applies toPostgreSQL non-parallel exports.
--offload- Offload an export to a temporary instance. Doing so reduces strain on sourceinstances and allows other operations to be performed while the export is inprogress.
--parallel- Perform a parallel export. This flag is only applicable to MySQL and Postgres.
--table=TABLE,[TABLE,…],-tTABLE,[TABLE,…]- Tables to export from the specified database. If you specify tables, specify oneand only one database. For PostgreSQL instances, only one table can be exportedat a time.
--threads=THREADS- Specifies the number of threads to use for the parallel export. If
--parallelis specified and this flag is not provided, Cloud SQLuses a default thread count to optimize performance.
- GCLOUD WIDE FLAGS
- These flags are available to all commands:
--access-token-file,--account,--billing-project,--configuration,--flags-file,--flatten,--format,--help,--impersonate-service-account,--log-http,--project,--quiet,--trace-token,--user-output-enabled,--verbosity.Run
$gcloud helpfor details. - NOTES
- These variants are also available:
gcloudalphasqlexportsqlgcloudbetasqlexportsql
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-07 UTC.