Question

Difficulty: EasyManaging Storage and Database Solutions

You need to export a Cloud SQL for MySQL database instance to a Cloud Storage bucket for offline archiving using Google Cloud CLI tools. In what order should you execute the steps to complete this operation?

  1. 1Create a target Cloud Storage bucket to hold the database dump file.
  2. 2Grant the Cloud SQL instance service account the Storage Object Admin role on the Cloud Storage bucket.
  3. 3Execute the `gcloud sql export sql` command specifying the database instance and the Cloud Storage URI destination.

Answer

The correct order of operations is: first, create the target Cloud Storage bucket; second, grant the Cloud SQL instance service account write permissions on the bucket; third, execute the `gcloud sql export sql` command.
Exporting data from Cloud SQL to Cloud Storage requires preparing the storage destination prior to initiating the export command. First, the destination bucket must exist. Second, because Cloud SQL performs exports using the instance service account identity, that account must be granted Storage Object Admin permissions on the target bucket. Finally, the user runs `gcloud sql export sql` to execute the export.

Step-by-Step Solution

1
Create the destination Cloud Storage bucket.
A Cloud Storage bucket URI is available for storing the database dump file.
The export command requires a valid destination bucket URI.
2
Assign write permissions on the bucket to the Cloud SQL service account.
The Cloud SQL instance's service account is authorized to write objects to the destination bucket.
Cloud SQL executes export operations asynchronously under its own service account identity, not the identity of the user running gcloud.
3
Execute `gcloud sql export sql`.
The export job is submitted and database contents are written to the specified Cloud Storage object path.
Running the gcloud command initiates the export process after prerequisites are satisfied.

Key Concept

Cloud SQL data export procedures and IAM authorization requirements
Rate this question