How to Export Firestore Data Completely Free
Are you using firebase?
But if you are using Free Plan
, exporting firestore data is not free!
With my 2 minutes tutorial, you can save $5 per month.
The plain way to export firestore data
Normally, you have to upgrade your plan to use this feature(Export Firestore Data). But this is not what we want.
Currently, I run 14 mobile applications on firebase completely free. And when I think it’s ready to move onto another database, I need to export firestore data.
But why do I have to pay when I want to use another service?
So, this is my solution.
Prerequisite
- Make sure
npm
is installed on local machine.
Package Installation
# Install npm library
npm install -g node-firestore-import-export
Warning! We don’t need to write any code to export firestore data. So just install node-firestore-import-export
globally. For people who want to know more about this library, go to this link.
Get your service account
- Go to
Project settings
- Go to
Service accounts
andGenerate new private key
- Check your downloaded file.
Now you have json
file which contains your service account information. You can move this file wherever you want and change its name, too. I personally changed its name to account_info.json
.
Export Data!
# Export Data
firestore-export -a path/to/your_key.json -b path/to/firestore_data.json -p # My Command
firestore-export -a service_account.json -b data.json -p
-a
flag means ‘accountCredentials’ -b
flag means backupFile
. -p
flag, as you guessed, ‘prettyPrint’.
You can try this command.
firestore-export --accountCredentails /path/to/your_account.json --backupFile /path/to/result.json --prettyPrint
Check Result!
Oh it works fine!
Bonus! Import Data
# Export Data
firestore-import -a path/to/your_key.json -b path/to/firestore_data.json
I think I don’t need any further explanation for this :)
Conclusion
- Install
node-firestore-import-export
- prepare
service_account.json
- Run command!
firestore-export -a path/to/your_key.json -b path/to/firestore_data.json -p
That’s it!
Leave a comment if you have any question!