Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/steadyequipment/node-firestore-backup
Google Firebase Firestore backup tool
https://github.com/steadyequipment/node-firestore-backup
backup cli firebase firestore
Last synced: 2 months ago
JSON representation
Google Firebase Firestore backup tool
- Host: GitHub
- URL: https://github.com/steadyequipment/node-firestore-backup
- Owner: steadyequipment
- Created: 2017-11-02T17:42:36.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-18T18:25:33.000Z (almost 6 years ago)
- Last Synced: 2024-10-02T07:28:42.371Z (4 months ago)
- Topics: backup, cli, firebase, firestore
- Language: JavaScript
- Size: 288 KB
- Stars: 190
- Watchers: 12
- Forks: 51
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-github-repos - steadyequipment/node-firestore-backup - Google Firebase Firestore backup tool (JavaScript)
README
# firestore-backup
A Google Firebase Firestore backup tool.[![codebeat badge](https://codebeat.co/badges/febdaccc-2648-4a74-9596-57b00c3f7af8)](https://codebeat.co/projects/github-com-steadyequipment-node-firestore-backup-master)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/b7e94350eba84ec198f83c05c3a10bd0)](https://www.codacy.com/app/Steadyequipment/node-firestore-backup?utm_source=github.com&utm_medium=referral&utm_content=steadyequipment/node-firestore-backup&utm_campaign=Badge_Grade)
[![David badge](https://david-dm.org/steadyequipment/node-firestore-backup.svg)](https://david-dm.org/steadyequipment/node-firestore-backup)# Note: Firebase now has an official backup and restore tool
Read more about how to use it here: https://firebase.google.com/docs/firestore/manage-data/export-import## Installation
Install using [__npm__](https://www.npmjs.com/).```sh
npm install -g firestore-backup
```or [__yarn__](https://yarnpkg.com/en/)
```sh
yarn global add firestore-backup
```Alternatively download the source.
```sh
git clone https://github.com/steadyequipment/node-firestore-backup.git
```### Retrieving Google Cloud Account Credentials
1. Visit the [Firebase Console](https://console.firebase.google.com)
1. Select your project
1. Navigate to __Project Settings__ (at the time of writing the __gear__ icon button at the top left of the page).
1. Navigate to __Service Accounts__
1. Click _Generate New Private Key_This downloaded json file contains the proper credentials needed for __firestore-backup__ to authenticate.
## Usage
### Backup:
* `-a`, `--accountCredentials` `` - Google Cloud account credentials JSON file.
* `-B`, `--backupPath` ``- Path to store the backup.Example:
```sh
firestore-backup --accountCredentials path/to/credentials/file.json --backupPath /backups/myDatabase
```### Backup with pretty printing:
* `-P`, `--prettyPrint` - JSON backups done with pretty-printing.Example:
```sh
firestore-backup --accountCredentials path/to/credentials/file.json --backupPath /backups/myDatabase --prettyPrint
```### Backup from a starting path:
* `-S`, `--databaseStartPath` `` - The database collection or document path to begin backup.Example:
```sh
firestore-backup --accountCredentials path/to/credentials/file.json --backupPath /backups/myDatabase --databaseStartPath /myCollection/document_3
```### Limit number of requests:
* `-L`, `--requestCountLimit` `` - The maximum number of requests to be made in parallel.Example:
```sh
firestore-backup --accountCredentials path/to/credentials/file.json --backupPath /backups/myDatabase --requestCountLimit 2
```### Exclude top level collections from backup:
* `-E`, `--excludeCollections` `` - 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:
```sh
firestore-backup --accountCredentials path/to/credentials/file.json --backupPath /backups/myDatabase --excludeCollections myFirstAnnoyingCollection --excludeCollections mySecondAnnoyingCollection
```### Exclude paths by regex:
* `--excludePattern` `` - 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:
```sh
firestore-backup --accountCredentials path/to/credentials/file.json --backupPath /backups/myDatabase --excludePattern '^/collectionToIgnore' --excludePattern '^/[^/]*/[^/]*/subcollectionToIgnore'
```### Fetch documents in batches:
* `--batchSize` `