Search code examples
google-cloud-datastore

How do I export Google Datastore using a PITR timestamp?


Google Datastore supports "Point-in-time recovery" but the instructions at https://cloud.google.com/datastore/docs/export-import-entities#export-import only show how to export the data using the firestore command.

The equivalent datastore command of gcloud datastore export does not support the --snapshot-time flag.

The firestore command doesn't work because it expects collection IDs which is not a concept in datastore mode.

So how are we supposed to export from PITR data when using Google Datastore?


Solution

  • I have followed the same document and am able to export successfully using the following command.

    gcloud firestore export gs://[BUCKET_NAME_PATH] \
        --snapshot-time=[PITR_TIMESTAMP] \
        --collection-ids=[COLLECTION_ID] \
        --namespace-ids=[NAMESPACE_ID] \
        --database=[DATABASE_NAME]
    

    Here, for collection id you have to use kind name. You can check this document for comparison between Firestore and Datastore.

    Also, Make sure you have required permission for Firestore service agent. The Firestore service agent uses the following naming convention:

    [email protected]
    

    Note: Firestore previously used the App Engine default service account instead of the Firestore service agent. If your database still uses the App Engine service account to import or export data, we recommend that you migrate to the service specific Firestore service agent. You can view which account your import and export operations use in the Google Cloud console.