Giter Club home page Giter Club logo

node-firestore-backup's Introduction

firestore-backup

A Google Firebase Firestore backup tool.

codebeat badge Codacy Badge David badge Known Vulnerabilities

Installation

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

Retrieving Google Cloud Account Credentials

  1. Visit the Firebase Console
  2. Select your project
  3. Navigate to Project Settings (at the time of writing the gear icon button at the top left of the page).
  4. Navigate to Service Accounts
  5. Click Generate New Private Key

This downloaded json file contains the proper credentials needed for firestore-backup to authenticate.

Usage

Backup:

  • -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

Backup with pretty printing:

  • -P, --prettyPrint - JSON backups done with pretty-printing.

Example:

firestore-backup --accountCredentials path/to/credentials/file.json --backupPath /backups/myDatabase --prettyPrint

Backup from a starting path:

  • -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

Limit number of requests:

  • -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

Exclude top level collections from backup:

  • -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

Exclude paths by regex:

  • --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'

Fetch documents in batches:

  • --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

Relax:

That's it! โœจ๐ŸŒˆ

Contributions

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!

node-firestore-backup's People

Contributors

yoiang avatar jeremylorino avatar lewchuk-inkling avatar nosyjoe avatar qwales1 avatar arpitkotecha avatar s-shiva1995 avatar steve8708 avatar

Watchers

James Cloos avatar Pradeep Saran avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.