NPM package for backup, restore, delete and replace Firebase
Install the firebase-replace CLI as a global CLI.
npm install -g firebase-replace
- Visit the Firebase Console
- Select your project
- Navigate to Project Settings (at the time of writing the gear icon button at the top left of the page).
- Navigate to Service Accounts
- Click Generate New Private Key
# Your Firebase Project ID
export FIREBASE_PROJECT_ID=XXXX-XXXXX
# Your Firebase Service Account File Path
export GOOGLE_APPLICATION_CREDENTIALS=./XXXX-XXXXX-firebase-adminsdk-XXXXX-XXXXXXXXXX.json
# Backup Firestore, Authentication, Storage
firebase-replace backup
tree ./data
# data
# ├── auth
# │ └── users.json
# ├── firestore
# │ └── collections.json
# └── storage
# Restore Firestore, Authentication, Storage
firebase-replace restore
# Delete Firestore, Authentication, Storage
firebase-replace delete
# Delete and restore
firebase-replace replace