Scheduling Cloud SQL Exports with Cloud Scheduler and Pub/Sub
Short answer
B Use Cloud Scheduler to trigger a Cloud Function through Pub/Sub to call the cloudsql.instances.export API.
Question
Key Takeaways
The main trap is choosing Cloud Composer for a simple scheduled task or trying to pass SQL queries directly to the export API instead of using the designated API parameters.
Learn how to schedule daily Cloud SQL for MySQL exports in CSV format using Google-recommended practices involving Cloud Scheduler, Pub/Sub, and Cloud Functions.
Common mistake: Candidates often select Cloud Composer (C) because it handles scheduling and execution, but it is overkill for a single-task workflow. Others choose A, mistakenly believing Cloud Functions can execute raw SQL to feed the export API, which is technically invalid.
Expert Analysis
The core of this question lies in distinguishing between scheduling a task and orchestrating a complex workflow. The requirement is to export data from Cloud SQL for MySQL into CSV format on a daily basis. Google’s official documentation and best practices for routine, automated exports favor the combination of Cloud Scheduler, Pub/Sub, and Cloud Functions.
Option A is incorrect because it suggests running a SELECT * query within the Cloud Function. The cloudsql.instances.export API does not accept raw SQL queries as input; it requires specific parameters like the database name, file type (CSV), and URI. Passing a SQL query would result in an API error.
Option D is also incorrect for similar reasons: Cloud Composer executing a raw SQL query does not automatically produce a CSV file via the export API, nor does it handle the scheduling mechanism natively without additional orchestration logic that mimics simpler tools.
Option C (Cloud Composer) is a common trap. While Cloud Composer (Airflow) is powerful for complex, multi-step workflows with dependencies, using it for a single, simple daily export is considered over-engineering. It introduces significant operational overhead and cost for a task that can be handled by lighter-weight services.
Option B is the correct approach. Cloud Scheduler triggers a message to a Pub/Sub topic. A Cloud Function subscribed to that topic then calls the cloudsql.instances.export API. This decoupled architecture is scalable, reliable, and aligns with Google’s recommended pattern for scheduled backups and exports, as detailed in their official guides.
Official Reference
- https://cloud.google.com/sql/docs/mysql/backup-recovery/scheduling-backups
- https://cloud.google.com/blog/topics/developers-practitioners/scheduling-cloud-sql-exports-using-cloud-functions-and-cloud-scheduler
These links open the official vendor documentation in a new tab.
Exam Strategy
When asked about 'Google-recommended practices' for routine automation, prefer lightweight, managed services (Scheduler + Pub/Sub + Functions) over heavy orchestration platforms (Composer) unless the workflow involves multiple dependent steps. Always verify API capabilities: the export API expects file paths and formats, not SQL queries.
Frequently Asked Questions
Can I use Cloud Functions directly without Pub/Sub?
Why not just use Cloud Composer for all scheduling tasks?
Community Votes
43% of anonymous learners picked answer B. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 13 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 13
-
dynamic_dba 👍 4B. Performing a “SELECT * FROM TABLE” wouldn’t give you CSV output and that alone wouldn’t call an API. Eliminate A. There’s no need for Cloud Composer in this scenario, especially when the solution is a known combination of Cloud Scheduler, Cloud Function and a Pub/Sub Topic, which is B.
-
sp57 👍 3As noted in text from this link, Cloud Function can be triggered with/without pub/sub. I think distinction between A & B is suggestion in A the API s called from query, which is not correct - the 'select query' is passed as parameter in call, so I think B is correct. "Note that we could also have a Pub/Sub Trigger configured Cloud Function get triggered by the Scheduler by using the same steps given above to create a job. Except that in the target, you will select Pub/Sub and provide the Pub/Sub Topic name. At the scheduler trigger time, the Cloud Scheduler will publish a message to the topic with the message body that you specify." https://rominirani.com/google-cloud-functions-tutorial-using-the-cloud-scheduler-to-trigger-your-functions-756160a95c43
-
njda 👍 3why will someone use 3 services when it can be done using 1 service only, in this case composer. Secondly export can be for multiple tables, and ,cloud functions has a execution time limit.? C still looks most appropriate solution.
-
GCP72 👍 3 Answered AA is the correct answer, PUSUB is not required for this task
-
KennyHuang 👍 2 Answered CC is the recommended choice as it leverages Cloud Composer's workflow orchestration capabilities to schedule and automate the export process. By calling the cloudsql.instances.export API within the workflow, you can ensure that the data is exported from Cloud SQL for MySQL in CSV format as needed by your data analysis team.
Show 8 more comments
-
gabrielosluz 👍 2The answer is letter B. Google recomends this pattern to perform this task: https://cloud.google.com/sql/docs/mysql/backup-recovery/scheduling-backups
-
pk349 👍 2A: Use Cloud Scheduler to trigger a Cloud Function that will run a select from table(s) query to call the cloudsql.instances.export ** API.
-
Nirca 👍 2 Answered Bhttps://cloud.google.com/blog/topics/developers-practitioners/scheduling-cloud-sql-exports-using-cloud-functions-and-cloud-scheduler
-
nhiguchi 👍 2 Answered CC is correct.
-
KennyHuang 👍 1 Answered CCloud Composer is a fully managed workflow orchestration service. It allows you to define and manage complex workflows using Apache Airflow. By using Cloud Composer, you can create a workflow that includes a task to export data from Cloud SQL for MySQL using the cloudsql.instances.export API. You can specify the export format as CSV to meet the requirement of your data analysis team. This approach provides a scalable and manageable solution for regular data exports. Therefore, option C is the recommended choice as it leverages Cloud Composer's workflow orchestration capabilities to schedule and automate the export process. By calling the cloudsql.instances.export API within the workflow, you can ensure that the data is exported from Cloud SQL for MySQL in CSV format as needed by your data analysis team.
-
ebd62a2 👍 1 Answered BCloud Scheduler, Cloud Functions and the Cloud Admin API can do this at lower cost, less maintenance and complexity. Cloud Composer for a single stage DAG is over engineering.
-
cardareel 👍 1Doing a SELECT won't call the API. Pub/Sub is not needed, you are correct, the problem is the SELECT (nothing to do there).
-
learnazureportal 👍 1The most accurate answer based on Google-recommended practices would be C
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.