Created
August 1, 2017 00:54
-
-
Save crrobinson14/71a0d22aabe3a0d855d34b46b7d7a115 to your computer and use it in GitHub Desktop.
Firebase Realtime Database Backup Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment