A Google Firebase Firestore backup tool.
Read more about how to use it here: https://firebase.google.com/docs/firestore/manage-data/export-import
Install using npm.
npm install -g firestore-backup
or yarn
yarn global add firestore-backup
Alternatively download the source.
git clone https://github.com/steadyequipment/node-firestore-backup.git
- 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
This downloaded json file contains the proper credentials needed for firestore-backup to authenticate.
-a
,--accountCredentials
<path>
- Google Cloud account credentials JSON file.-B
,--backupPath
<path>
- Path to store the backup.
Example:
firestore-backup --accountCredentials path/to/credentials/file.json --backupPath /backups/myDatabase
-P
,--prettyPrint
- JSON backups done with pretty-printing.
Example:
firestore-backup --accountCredentials path/to/credentials/file.json --backupPath /backups/myDatabase --prettyPrint
-S
,--databaseStartPath
<path>
- The database collection or document path to begin backup.
Example:
firestore-backup --accountCredentials path/to/credentials/file.json --backupPath /backups/myDatabase --databaseStartPath /myCollection/document_3
-L
,--requestCountLimit
<number>
- The maximum number of requests to be made in parallel.
Example:
firestore-backup --accountCredentials path/to/credentials/file.json --backupPath /backups/myDatabase --requestCountLimit 2
-E
,--excludeCollections
<id>
- Top level collection id(s) to exclude from backing up.
Note: because of how the command line parsing library works multiple collection ids must be specified as separate parameters.
Example:
firestore-backup --accountCredentials path/to/credentials/file.json --backupPath /backups/myDatabase --excludeCollections myFirstAnnoyingCollection --excludeCollections mySecondAnnoyingCollection
--excludePattern
<regex>
- Patterns to match against paths to exclude from the backup. All subpaths of matched paths will also be excluded.
These patterns can support excluding several different sections of trees, e.g.:
- Exclude top level collection: ^/collectionToIgnore
- Exclude sub collections of all documents in a collection: ^/organizations/[^/]*/subcollectionToIgnore
- Exclude sub collections at a given level: ^/[^/]/[^/]/subcollectionToIgnore
- Exclude a particular document: ^/organizations/organizationToIgnore
Note: when combining excludePattern with databaseStartPath, the patterns are tested against the full path of the document off the root of database (with a leading slash).
Note: because of how the command line parsing library works multiple exclude patterns must be specified as separate parameters.
Example:
firestore-backup --accountCredentials path/to/credentials/file.json --backupPath /backups/myDatabase --excludePattern '^/collectionToIgnore' --excludePattern '^/[^/]*/[^/]*/subcollectionToIgnore'
--batchSize
<number
- The maximum number of documents to fetch in a single request.
Example:
firestore-backup --accountCredentials path/to/credentials/file.json --backupPath /backups/myDatabase --batchSize 25
That's it! ✨🌈
This project has been made much better by it's contributors, feel free to report bugs and make feature requests in the Issue Tracker, fork and create pull requests!