Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I export data from Firebase Realtime Database?

I am developing with Firebase and have data stored in the Realtime Database. I need to share my database structure for a question here on Stack Overflow, or just take a backup before making breaking changes. How can I do this using the Firebase Console?

like image 607
Grimthorr Avatar asked Nov 08 '17 14:11

Grimthorr


People also ask

How do I get particular data from Firebase?

Firebase data is retrieved by either a one time call to GetValueAsync() or attaching to an event on a FirebaseDatabase reference. The event listener is called once for the initial state of the data and again anytime the data changes.


2 Answers

Data can be exported from the Firebase Realtime Database as JSON:

  1. Login to the Database section of the Firebase Console.
  2. Navigate to the node you wish to export by clicking on it in the list (skip this to export all data).
  3. Click the 3-dot overflow menu icon, at the top-right of the data panel.
  4. Click Export JSON from the menu.

    console menu screenshot

Likewise, you can import a structure in the same fashion, using Import JSON.

like image 64
Grimthorr Avatar answered Oct 04 '22 00:10

Grimthorr


There is an Node.js tool called firebase-export, similar to firebase-import but not from Firebase itself, that will export JSON from the command line.

Firebase export helper utility for exporting excluded JSON from Firebase.

To install

npm install -g firebase-export

Usage example

$ firebase-export --database_url https://test.firebaseio-demo.com --firebase_secret '1234' --exclude 'settings/*, users/*/settings'

Github Repo


Note: Firebase has a REST API, so you can use any language to retrieve (export) data:

curl 'https://[PROJECT_ID].firebaseio.com/users/jack/name.json'

Here's an example curl request with filters

curl 'https://dinosaur-facts.firebaseio.com/dinosaurs.json?orderBy="height"&startAt=3&print=pretty'
like image 31
philshem Avatar answered Oct 04 '22 01:10

philshem