Engine to Backup, Clean, Restore. Work for Firebase.Firestore, Firebase.Storage, Firebase.Auth
npm i firebase-engine -g
Name | Short name | Description |
---|---|---|
operations | o | backup (b), restore (r) or clean (c). Default: backup |
path | p | Path to service account JSON file |
services | s | firestore (f), storage (s), auth (a), can be separated by commas. Default: all |
backup | b | Path to backup or restore file. Default: ./{$PROJECT_ID + $TIMESTAMP}.backup |
collections | coll | Apply to Collections (in Firestore service). Default: all, if it is not set |
buckets | buck | Apply to Buckets (in Storage service). Default: all, if it is not set |
--nocompress | -nc | Do not use data compression |
--emulators | -em | Use firebase emulators (work for firestore) |
- collections - the rule also applies to all nested collections and documents
Name | Short name | Description |
---|---|---|
algorithm | alg | The password hashing information (algorithm, only SCRYPT). Default: SCRYPT |
base64_signer_key | bsk | The password hashing information (key in base64 encoding). Default: user passwords are not restored if not set. |
base64_salt_separator | bss | The password hashing information (salt separator in base64). Default: Bw== |
rounds | rnd | The password hashing information (rounds). Default: 8 |
mem_cost | mc | The password hashing information (memory cost). Default: 14 |
With full names
firebase-engine operations="clean, restore" path="./test.json" services="firestore, storage" backup="test.backup"
With one bucket
firebase-engine operations="clean" path="./test.json" services="storage" buckets="test.appspott.com"
With collection & subcollection
firebase-engine operations="backup" path="./test.json" services="firestore" collections="authors,books.pages"
With short names and use emulators
firebase-engine o="b, c" s="f" p="./test.json" b="test.backup" -em
With password recovery for users
firebase-engine operations="restore" path="./test.json" services="firestore, auth" backup="test.backup" bsk="nMyNs6sFWp0GZ/JSW2tsNGvGZ70oiv13gxO7ub7rxPwK271P945BiZmjrdsBRbgZmzPPgwATLR6FaXq3rUspVg=="
Name | Short name | Description |
---|---|---|
--to-emulators | -to | Copy data from project to emulators (only firestore) |
--from-emulators | -from | Copy data from emulators to project (only firestore) |
path | p | Path to service account JSON file |
With full names
firebase-engine-emulators path="./test.json" --to-emulators
With short names
firebase-engine-emulators p="./test.json" -from
Get your service account key from IAM Open google IAM
Or from the FIREBASE project Open official firebase docs
Firebase API also returns the passwordSalt and passwordHash hashed by the Firebase Auth backend for password users if the user/service account used to generate the request OAuth access token has the firebaseauth.configs.getHashConfig permission. Otherwise the passwordHash and passwordSalt will not be set. Open official firebase docs
I recommend using only the top collection level in the collections parameter. Because you can get shadow document by restoring a subcollection in a non-existent document. To a full database cleanup, including shadow documents, use the command in firebase tools
firebase firestore:delete -r
Apache-2.0