#!/usr/bin/env bash # This script uses a shallow-get technique to get a list of all top level keys # in a Firebase Realtime Database, then extract the tree under each key into a # separate JSON file, one per top level key. # # It’s great for making backups because you don’t end up with one ginormous # export file which is really hard to manage with other tools. # # It can also immediately give you a sense of where your space is going per key, # which is hard to do any other way. Just look at the size of each JSON file. for i in `firebase database:get --shallow / | jq -r 'keys[]'`; do firebase database:get --export -o backup/$i.json /$i done