How to Import and Export Firebase Emulator Data Easily
Use the Firebase CLI commands
firebase emulators:export <path> to export emulator data and firebase emulators:start --import <path> to import it. This lets you save and restore your local emulator state easily.Syntax
The Firebase CLI provides commands to export and import emulator data locally.
firebase emulators:export <path>: Saves the current emulator data to the specified folder.firebase emulators:start --import <path>: Starts emulators and loads data from the specified folder.
Replace <path> with your desired folder path for storing or loading data.
bash
firebase emulators:export ./saved-data firebase emulators:start --import ./saved-data
Example
This example shows how to export your current emulator data to a folder named backup and then start the emulators loading that data.
bash
firebase emulators:export ./backup firebase emulators:start --import ./backup
Output
✔ Exported data to ./backup
i Starting emulators with imported data from ./backup
Common Pitfalls
- Not specifying the
--importflag when starting emulators means data won't be loaded. - Exporting data while emulators are not running will fail.
- Using relative paths incorrectly can cause import/export to fail; always verify the folder path.
- Data exported from one emulator version might not be compatible with another version.
bash
Wrong:
firebase emulators:start ./backup
Right:
firebase emulators:start --import ./backupQuick Reference
Remember these key commands for managing Firebase emulator data:
- Export data:
firebase emulators:export <folder> - Import data:
firebase emulators:start --import <folder> - Always export while emulators are running.
- Use absolute or correct relative paths.
Key Takeaways
Use
firebase emulators:export <path> to save emulator data.Start emulators with
--import <path> to load saved data.Always export data while emulators are running to avoid errors.
Verify folder paths to prevent import/export failures.
Data compatibility depends on emulator versions; keep them updated.