Exporting data from Cloud Firestore to local emulator
Steps to export data from Cloud Firestore to local emulator.
1. Login to Firebase or Google Cloud:
firebase loginor
gcloud auth login 2. Connect to your project:
firebase use your-project-nameor
gcloud config set project your-project-name3. Export your production data to the Google Cloud storage bucket folder:
gcloud firestore export gs://your-project-name.appspot.com/<your-choosen-folder-name>4. Copy bucket folder to your local machine:
gsutil -m cp -r gs://your-project-name.appspot.com/<your-choosen-folder-name> /path/to/some/folderNow we have production data in our local machine, but we need to make some modifications in order to make it available to emulators. Just follow these three simple steps.
First, switch to the newly created folder:
cd /path/to/some/folderRename the metadata file as firestore_export.overall_export_metadata:
mv your-choosen-folder-name.overall_export_metadata firestore_export.overall_export_metadataAnd finally, copy all files to .emulator-data/firestore_export in your workspace folder:
cp -R * /path/to/workspace/emulator/.emulator-data/firestore_export/That's it! The next time you run emulators, Firestore will have all the imported data.
PreviousImporting existing data into local emulatorsNextExporting user accounts from Firebase to local emulator
Last updated
Was this helpful?