/firestore-export-json

Convert google firestore/datastore LevelDB exports to JSON data.

Primary LanguagePythonMIT LicenseMIT

Firestore Export JSON

Stars License

Convert google firestore/datastore LevelDB exports to JSON data.

Dependencies

Setup

Method 1 - Direct Install

  1. Clone the repository.

    $ git clone git@github.com:labbots/firestore-export-json.git
    $ cd firestore-export-json
  2. Create a new virtual environment within the project directory.

    $ python -m venv venv
  3. Activate the virtual environment in the project.

    $ source ./venv/bin/activate
  4. Install framework dependencies.

    $ pip install -e .

Method 2 - Make

  1. Clone the repository.

    $ git clone git@github.com:labbots/firestore-export-json.git
    $ cd firestore-export-json
  2. Run the make command

    $ make install
    

Usage

  1. Export firestore collections using firestore admin tools. Follow the instructions here to backup firestore.
  2. The exports are stored in google cloud storage. Download the exported data directory from cloud storage.
  3. Use the below command to convert the exported data to JSON.

Method 1

fs_to_json.py can be used to convert the firestore/datastore export files to JSON data.

$ python fs_to_json.py [path_to_source_dir] -d [path_to_destination]
  1. Provide the path to the directory where files such as output-0 exists as source directory usually this would be kinds_* directory.
  2. Destination directory can be specified where the json files will be created. If not provided then the json files will be created using json folder in source directory.

Method 2

The project exposes console script using setuptools to provide fs_to_json CLI command which can be used to convert exports to JSON.

$ fs_to_json [path_to_source_dir] -d [path_to_destination]

Inspired By