Reputation: 31375
I've started building my app with React for the UI and Firebase as the backend service. I'm using Firestore for my database.
I've reached the point where I began uploading data to it (manually, through the UI I've build for this operation - Add/Edit/Delete form).
By now, I have a few collections with all my data stored into Firestore.
Sometimes I need to make some bulk editing scripts using the firebase-admin SDK. For example: imagine that I've decided that I need to change some images src
to a different domain. I can't do it manually.
But now I'm handling my whole data at once, and if I make a mistake, the disaster potential is great.
So I searched for a way to export my data as a backup and found this piece of doc:
https://firebase.google.com/docs/firestore/manage-data/export-import
I've followed the tutorial and managed to export all my data at once to my storage bucket using gcloud
SDK, by doing:
gcloud beta firestore export gs://[BUCKET_NAME]
And now I have this folder in my bucket, which a bunch of files and metadata that I can't really inspect/explore.
QUESTION 1:
Is it possible to inspect/explore the collections and documents that are inside the exported files?
And as far as importing goes, the docs says I can do:
// TO IMPORT EVERYTHING
gcloud beta firestore import gs://[BUCKET_NAME]/[EXPORT_PREFIX]/
// TO IMPORT SPECIFIC COLLECTIONS
gcloud beta firestore import gs://[BUCKET_NAME]/[EXPORT_PREFIX]/ --collection-ids=[COLLECTION_ID_1],[COLLECTION_ID_2]
QUESTION 2:
How does the importing process work? Will it replace the existing collections that currently exist inside my Firestore? Do I need to clear/empty my Firestore before importing or does it overwrite the whole thing?
I thinking that if I have collection1
and collection2
and I import only collection1
, I'm assuming the collection2
will remain intact, am I right?
Upvotes: 0
Views: 886
Reputation: 31375
This is the answer I got from Firebase official support team:
For your first question, the answer is no. You are not able to see the data that just exported as it is converted to a binary format. Nonetheless, there are several third party npm packages that may help you to download some data and able to see the data, one of them is
firestore-backup-restore
, you may use it to see the data as a JSON format.For your second question, the answer is yes, it will overwrite all the data that you have in that specific collection. For example, let's say you have the following collection structure:
/test/iqifEWiQ3FaePS/data:xxxxx
And you create an export for this specific collection, and later on you start writing more and more data to the collection, and then you import the data that is saved in the bucket to that exact collection, your result will be the exact same data as it is given above.
Upvotes: 2