10
votes

I am running the following command to export my Firestore collection.

gcloud alpha firestore export gs://[...] --collection-ids='[...]'

The resulting export only contains documents at root level, but not any sub-collection under any documents.

How can I export all sub-collections from my collection?

I am following this doc from google.

1

1 Answers

10
votes

To back up also sub-collections, I have to specify the collection ids of sub-collections.

gcloud alpha firestore export gs://[...] --collection-ids='[COLLECTION_ID]','[SUB_COLLECTION_ID_1]','[SUB_COLLECTION_ID_2]'

Without --collection-ids option, it can also back up the whole firestore including all sub-collections. But specific collection cannot be imported from this backup.