This page describes how to schedule exports of your Firestore in Datastore mode data. To run exports on a schedule, we recommend using Cloud Run functions and Cloud Scheduler. Create a Cloud Function that initiates exports and use Cloud Scheduler to run your function.
Before you begin
Before you schedule data exports, you must complete the following tasks:
- Enable billing for your Google Cloud project. Only Google Cloud projects with billing enabled can use the export and import feature.
- Create a Cloud Storage bucket in a location near your Datastore mode database location. Export operations require a destination Cloud Storage bucket. You cannot use a Requester Pays bucket for export operations.
Create a Cloud Function and Cloud Scheduler job
Follow the steps below to create a Cloud Function that initiates data exports and a Cloud Scheduler job to call that function:
Create a datastore_export Cloud Function
-
Go to the Cloud Functions page in the Google Cloud console:
- Click Create Function
- Enter a function name such as
datastoreExport - Under Trigger, select Cloud Pub/Sub. Cloud Scheduler uses your pub/sub topic to call your function.
- In the Topic field, select Create a topic. Enter a name for
the pub/sub topic such as
startDatastoreExport. Take note of the topic name as you need it to create your Cloud Scheduler job. - Under Source code, select Inline editor.
- In the Runtime dropdown, select Python 3.7.
- Enter the following code for
main.py: