Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to backup Firebase DB? [closed]

Tags:

firebase

Was wondering if there are any common practices in backup up a firebase DB. My concern is some process accidentally wiping out our Database.

Thanks!

like image 985
BigPoppa Avatar asked Jan 12 '15 21:01

BigPoppa


People also ask

Can Firebase Realtime Database work offline?

By enabling persistence, any data that the Firebase Realtime Database client would sync while online persists to disk and is available offline, even when the user or operating system restarts the app. This means your app works as it would online by using the local data stored in the cache.

Does Firebase have backups?

Blaze plan users can set up their Firebase Realtime Database for automatic backups, a self-service feature that enables daily backups of your Database application data and rules in JSON format to a Cloud Storage bucket.

How can I recover my Firebase database?

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.


1 Answers

As of the time of this question, Firebase backs up all instances daily. So while keeping your own backups may still be useful, it's not essential.

To create your own backups, you can simply curl the data:

curl https://<instance>.firebaseio.com/.json?format=export 

Note that for multiple gigabytes of data, this will slow things down and lock read access for a short period. It would be better in this case to chunk the backups and work with smaller portions. The shallow parameter can help here by providing a list of keys for any given path in Firebase, without having to fetch the data first.

curl https://<instance>.firebaseio.com/.json?shallow=true 

As previously mentioned, there are also several GitHub libs available for this, and incremental backups are practical with some creativity and a worker thread on the real-time SDK.

like image 112
Kato Avatar answered Nov 10 '22 02:11

Kato