How to maintain emulator’s firestore data after relaunching emulator
If you restart firebase emulator, you will lose all of the data in the firestore. To keep the data, you need to export and import execution.
Export data
> firebase emulators:export ./firestore-snapshotFound running emulator hub for project speech at http://localhost:4400
? The directory /Users/fredriccliver/Projects/Speech/firestore-snapshot already contains export data. Exporting again to the same directory will overwrite all data. Do you want to continue? Yes
i Deleting directory /Users/fredriccliver/Projects/Speech/firestore-snapshot/firestore_export
i Exporting data to: /Users/fredriccliver/Projects/Speech/firestore-snapshot
✔ Export complete
In my case, I’d export data in the same path already, so it warned me, and I overwrote it.
Import data
firebase emulators:start --import ./firestore-snapshot --inspect-functions
I’m using inspector for cloud function debugging, so if you not, just ignore the last part ‘ — inspect-functions’
Just you need to do is adding this after the emulators:start command.
--import [path]