Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcloud Firestore export does not export sub-collections

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.

like image 452
Michael Avatar asked Aug 09 '18 12:08

Michael


1 Answers

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.

like image 198
Michael Avatar answered Oct 02 '22 01:10

Michael