Skip to content

Engine to Backup, Clean, Restore. Work for Firebase.Firestore, Firebase.Storage, Firebase.Auth

License

Notifications You must be signed in to change notification settings

siarheidudko/firebase-engine

Repository files navigation

firebase-engine

Unlock Peak Performance for Your Firebase Project: A Dynamic Engine for Effortless Backup, Thorough Cleaning, and Seamless Restoration. Tailored for Firebase Firestore, Firebase Storage, and Firebase Auth. Streamline Your Workflow with Unrivaled Efficiency!

npm npm NpmLicense GitHub last commit GitHub release

Install

 npm i firebase-engine -g

Launch parameters

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

Launch parameters (only for password recovery for users in Firebase.Auth)

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

Use

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=="

Copy data from project to emulators or from emulators to project

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

Open Source

See source docs

See source

Service Account Key

Get your service account key from IAM Open google IAM

Or from the FIREBASE project Open official firebase docs

WARNING (Password hashes of users)

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

WARNING (restoration of subcollections)

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

LICENSE

Apache-2.0