Question

Difficulty: HardManaging Storage and Database Solutions

An operations engineer needs to restore a PostgreSQL database backup file stored in a Google Cloud Storage bucket into a target Cloud SQL for PostgreSQL instance using the gcloud CLI. Place the following operational steps in the correct chronological sequence to perform this restoration.

  1. 1Retrieve the service account email address of the Cloud SQL instance using `gcloud sql instances describe`.
  2. 2Grant the Cloud SQL instance service account the `roles/storage.objectViewer` IAM role on the source Cloud Storage bucket.
  3. 3Execute the `gcloud sql import sql` command referencing the target instance name and the `gs://` URI of the database backup file.
  4. 4Monitor the asynchronous import process using `gcloud sql operations list` until the operation status reaches `DONE`.

Answer

The correct operational sequence is: 1) Retrieve the service account email of the Cloud SQL instance, 2) Grant the service account the Storage Object Viewer role on the Cloud Storage bucket, 3) Execute the gcloud sql import sql command with the Cloud Storage URI, and 4) Monitor the operation status using gcloud sql operations list until DONE.
To perform a Cloud SQL import from Cloud Storage, the instance service account must first be retrieved and granted read permissions (Storage Object Viewer) on the bucket containing the dump file. Only after permission propagation can the `gcloud sql import sql` command be executed, followed by monitoring the operation status via `gcloud sql operations list` to confirm successful completion.

Step-by-Step Solution

1
Identify Instance Service Account
Obtain the unique serviceAccountEmailAddress associated with the Cloud SQL instance.
Cloud SQL accesses Google Cloud Storage using its own system-generated service account, not the user's personal credentials.
2
Configure Bucket IAM Permissions
Grant the Storage Object Viewer (roles/storage.objectViewer) role to the Cloud SQL service account on the bucket.
Without explicit bucket-level read access, Cloud SQL will return permission errors when attempting to read the dump file.
3
Trigger SQL Import
Run gcloud sql import sql <INSTANCE> gs://<BUCKET>/<FILE>.
Initiates the import task using the authenticated Cloud SQL instance service account.
4
Track Operation Completion
Query gcloud sql operations list --instance=<INSTANCE> to verify the status.
Import operations run asynchronously; verifying DONE status confirms data has been loaded successfully.

Key Concept

Cloud SQL Database Import IAM Prerequisites and CLI Execution Sequence
Rate this question