Google Professional Cloud Database Engineer Question 150
Select 4Google Cloud PlatformYour team is working on migrating a PostgreSQL database from Google Cloud SQL to a local on-premises environment. To ensure minimal downtime, you decide to export the database from Cloud SQL and then import it locally. Which of the following steps are necessary to perform this task successfully?
- A
Use the gcloud sql export command to export the database to a Cloud Storage bucket.
- B
Export the database directly from Cloud SQL to your local machine using the mysqldump utility.
- C
Grant the Cloud SQL service account the necessary permissions to write to the target Cloud Storage bucket.
- D
Download the exported SQL dump file from the Cloud Storage bucket to your local machine.
- E
Import the SQL dump file into the on-premises PostgreSQL database using the pg_restore utility.
Show answer and explanation
Correct answers: A, C, D, E
Explanation
To migrate a PostgreSQL database from Cloud SQL to an on-premises environment, you must first export the database using the gcloud sql export command to a Cloud Storage bucket. Ensure the Cloud SQL service account has the necessary permissions to write to the bucket. After exporting, download the SQL dump file to your local machine and then use the pg_restore utility to import the data into the on-premises PostgreSQL database. The mysqldump utility is applicable for MySQL, not PostgreSQL, and direct exports to local machines are not supported.
- A. Correct.
This is correct. Using the gcloud sql export command is the recommended way to export a Cloud SQL database to a Cloud Storage bucket.
- B. Incorrect.
This is incorrect. The mysqldump utility is used for MySQL databases, not PostgreSQL. Additionally, direct export from Cloud SQL to a local machine is not supported.
- C. Correct.
This is correct. The Cloud SQL service account must have permissions to write to the Cloud Storage bucket where the exported data will be stored.
- D. Correct.
This is correct. Once the export is completed, the SQL dump file must be downloaded from the Cloud Storage bucket to your local machine to proceed with the import.
- E. Correct.
This is correct. The pg_restore utility is used to import SQL dump files into PostgreSQL databases, making it an essential step in the process.