Exporting firebase data to json

Viewed 36

I'm trying to export a particular Firestore collection using gcloud Right now, I did

gcloud storage buckets create gs://my-bucket 
gcloud firestore export gs://my-bucket --collection-ids=my-collection 
gcloud storage cp -r gs://my-bucket/2022-09-22T09:20:16_11252 my-directory

which results in some content in my-directory/all_namespaces/.../output-1. The output-1 file definitely seems to contain some relevant data but it is not very readable. Hence some questions:

  • which file format is used?
  • can I export to JSON (or CSV or XML) directly
  • can I convert the current file to JSON, CSV or XML

And related

  • why is output-0 empty?
2 Answers

Firestore does not support exporting existing data to a readable file but Firestore do have a managed Exporting and importing data that allows you to dump your data into a GCS bucket. It produces a format that is the same as Cloud Datastore uses. This means you can then import it into BigQuery. You can refer to this stack overflow and this video

Also as mentioned above in comment by Dazwilkin, The output of a managed export uses the LevelDB log format.

Additionally you can have a look at this link1 & link2

Related