Search code examples
google-cloud-firestoregcloudgoogle-cloud-sdk

Restoring part of firestore export


I am following up documentation in:

https://cloud.google.com/sdk/gcloud/reference/firestore/import

And I am trying to restore a collection pets in a backup from today. However I am getting this:

# gcloud firestore import gs://pets-backup/2021-02-26T02:27:05_54372/ --collection-ids='pets'
ERROR: (gcloud.firestore.import) INVALID_ARGUMENT: The requested kinds/namespaces are not available

I can confirm the gs-bucket exists and the collection pets too.

The error is not very helpful, I am not sure what I am dealing with.

I noticed within the export, there are folders /all_namespaces/all_kinds. When I try to import from these directly, I am getting:

gcloud firestore import 'gs://pets-backup/2021-02-26T02:27:05_54372/all_namespaces/all_kinds' --collection-ids='pets'
ERROR: (gcloud.firestore.import) NOT_FOUND: Google Cloud Storage file does not exist: /pets-backup/2021-02-26T02:27:05_54372/all_namespaces/all_kinds/all_kinds.overall_export_metadata

I can see there is only a file all_namespaces_all_kinds.export_metadata which doesn't match the file the import tool is looking for.


Solution

  • As confirmed by you in the comments, you are trying to extract a collection from and export of all the collections. Unfortunatelly this is currently not possible, as you can see in this documentation:

    Only an export of specific collection groups supports an import of specific collection groups. You cannot import specific collections from an export of all documents.

    If you'd like this to be changed, you can submit a Feature Request in Google's Issue Tracker so that they can consider this functionality to be implemented.