Requires authorization
Exports data from a Cloud SQL instance to a Google Cloud Storage bucket as a MySQL dump or CSV file. Try it now.
Request
HTTP request
POST https://www.googleapis.com/sql/v1beta4/projects/project/instances/instance/export
Parameters
| Parameter name | Value | Description |
|---|---|---|
| Path parameters | ||
instance |
string |
Cloud SQL instance ID. This does not include the project ID. |
project |
string |
Project ID of the project that contains the instance to be exported. |
Authorization
This request requires authorization with the following scope (read more about authentication and authorization).
| Scope |
|---|
https://www.googleapis.com/auth/cloud-platform |
Request body
In the request body, supply data with the following structure:
{
"exportContext": {
"kind": "sql#exportContext",
"fileType": string,
"uri": string,
"databases": [
string
],
"sqlExportOptions": {
"tables": [
string
]
},
"csvExportOptions": {
"selectQuery": string
}
}
}
| Property name | Value | Description | Notes |
|---|---|---|---|
exportContext |
nested object |
Contains details about the export operation. | |
exportContext.kind |
string |
This is always sql#exportContext. |
|
exportContext.uri |
string |
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, the operation fails. If fileType is SQL and the filename ends with .gz, the contents are compressed. |
|
exportContext.fileType |
string |
The file type for the specified uri. SQL: The file contains SQL statements. CSV: The file contains CSV data. |
|
exportContext.databases[] |
list |
Databases (for example, guestbook) from which the export is made. If fileType is SQL and no database is specified, all databases are exported. If fileType is CSV, you can optionally specify at most one database to export. If csvExportOptions.selectQuery also specifies the database, this field will be ignored. |
|
exportContext.sqlExportOptions |
object |
Options for exporting data as SQL statements. | |
exportContext.sqlExportOptions.tables[] |
list |
Tables to export, or that were exported, from the specified database. If you specify tables, specify one and only one database. | |
exportContext.csvExportOptions |
object |
Options for exporting data as CSV. | |
exportContext.csvExportOptions.selectQuery |
string |
The select query used to extract the data. |
Response
If successful, this method returns an operation resource in the response body. Note that only the fields that are relevant to the export operation will be populated.
{
"kind": "sql#operation",
"selfLink": string,
"targetProject": string,
"targetId": string,
"targetLink": string,
"name": string,
"operationType": string,
"status": string,
"user": string,
"insertTime": datetime,
"startTime": datetime,
"endTime": datetime,
"error": {
"errors": [
{
"kind": "sql#operationError",
"code": string,
"message": string
}
]
},
"importContext": {
"kind": "sql#importContext",
"fileType": string,
"uri": string,
"database": string,
"csvImportOptions": {
"table": string,
"columns": [
string
]
}
},
"exportContext": {
"kind": "sql#exportContext",
"fileType": string,
"uri": string,
"databases": [
string
],
"sqlExportOptions": {
"tables": [
string
]
},
"csvExportOptions": {
"selectQuery": string
}
}
}
| Property name | Value | Description | Notes |
|---|---|---|---|
kind |
string |
This is always sql#operation. |
|
selfLink |
string |
The URI of this resource. | |
targetProject |
string |
The project ID of the target instance related to this operation. | |
targetId |
string |
Name of the database instance related to this operation. | |
targetLink |
string |
The URI of the instance related to the operation. | |
name |
string |
An identifier that uniquely identifies the operation. You can use this identifier to retrieve the Operations resource that has information about the operation. | |
operationType |
string |
The type of the operation. Valid values are CREATE, DELETE, UPDATE, RESTART, IMPORT, EXPORT, BACKUP_VOLUME, RESTORE_VOLUME, CREATE_USER, DELETE_USER, CREATE_DATABASE, DELETE_DATABASE . |
|
status |
string |
The status of an operation. Valid values are PENDING, RUNNING, DONE, UNKNOWN. |
|
user |
string |
The email address of the user who initiated this operation. | |
insertTime |
datetime |
The time this operation was enqueued in UTC timezone in RFC 3339 format, for example 2012-11-15T16:19:00.094Z. |
|
startTime |
datetime |
The time this operation actually started in UTC timezone in RFC 3339 format, for example 2012-11-15T16:19:00.094Z. |
|
endTime |
datetime |
The time this operation finished in UTC timezone in RFC 3339 format, for example 2012-11-15T16:19:00.094Z. |
|
error |
object |
If errors occurred during processing of this operation, this field will be populated. | |
error.errors[] |
list |
The list of errors encountered while processing this operation. | |
error.errors[].kind |
string |
This is always sql#operationError. |
|
error.errors[].code |
string |
Identifies the specific error that occurred. | |
error.errors[].message |
string |
Additional information about the error encountered. | |
importContext |
nested object |
The context for import operation, if applicable. | |
importContext.kind |
string |
This is always sql#importContext. |
|
importContext.fileType |
string |
The file type for the specified uri. SQL: The file contains SQL statements. CSV: The file contains CSV data. |
|
importContext.uri |
string |
A path to the file in Google Cloud Storage from which the import is made. The URI is in the form gs://bucketName/fileName. Compressed gzip files (.gz) are supported when fileType is SQL. |
|
importContext.database |
string |
The database (for example, guestbook) to which the import is made. If fileType is SQL and no database is specified, it is assumed that the database is specified in the file to be imported. If fileType is CSV, it must be specified. |
|
importContext.csvImportOptions |
object |
Options for importing data as CSV. | |
importContext.csvImportOptions.table |
string |
The table to which CSV data is imported. | |
importContext.csvImportOptions.columns[] |
list |
The columns to which CSV data is imported. If not specified, all columns of the database table are loaded with CSV data. | |
exportContext |
nested object |
The context for export operation, if applicable. | |
exportContext.kind |
string |
This is always sql#exportContext. |
|
exportContext.fileType |
string |
The file type for the specified uri. SQL: The file contains SQL statements. CSV: The file contains CSV data. |
|
exportContext.uri |
string |
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, the operation fails. If fileType is SQL and the filename ends with .gz, the contents are compressed. |
|
exportContext.databases[] |
list |
Databases (for example, guestbook) from which the export is made. If fileType is SQL and no database is specified, all databases are exported. If fileType is CSV, you can optionally specify at most one database to export. If csvExportOptions.selectQuery also specifies the database, this field will be ignored. |
|
exportContext.sqlExportOptions |
object |
Options for exporting data as SQL statements. | |
exportContext.sqlExportOptions.tables[] |
list |
Tables to export, or that were exported, from the specified database. If you specify tables, specify one and only one database. | |
exportContext.csvExportOptions |
object |
Options for exporting data as CSV. | |
exportContext.csvExportOptions.selectQuery |
string |
The select query used to extract the data. |
Try it!
Use the APIs Explorer below to call this method on live data and see the response.