Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automatically backup Firestore database daily

I would like to backup a Firestore database on a daily basis.

My data structure is like this:

usersCollection
  uid
     defaultCurrency: 'USD'
     name: 'something'
     dreamsCollection
                     name
                     image

I have looked at firestore-export-import and node-firestore-backup to do the backup and export the data to a JSON file.

My questions are:

  1. If I create a cloud function how do I run the cloud function daily?
  2. What is the best way to do the backup?
    • Should I store the data in firebase storage and how to do this?
    • Should I save the JSON to a separate service etc?

Any help, no matter how small would be appreciated.

Thanks

like image 731
Peter Fields Avatar asked May 15 '18 08:05

Peter Fields


People also ask

How do I automatically backup my firestore database?

As of today, Firestore does not support automatic backups, but it DOES support exports via the gcloud CLI or REST API. Although not technically a backup in database jargon, an automatic export is valuable to have for disaster recovery because it can be re-imported to replace lost data.

Does firestore have backup?

☝️ We assume that you are an owner of the Firebase project and that you have enabled billing. Read more here. The Firestore backups are initiated by a cloud function and are stored in a dedicated storage bucket on Google Cloud Platform.

What is firestore persistence?

Cloud Firestore supports offline data persistence. This feature caches a copy of the Cloud Firestore data that your app is actively using, so your app can access the data when the device is offline. You can write, read, listen to, and query the cached data.


1 Answers

You can now export and import the data to the specified bucket.

More info here: https://firebase.google.com/docs/firestore/manage-data/export-import

Here is an info on how to do it automatically:

https://firebase.google.com/docs/firestore/solutions/schedule-export

like image 74
uksz Avatar answered Oct 06 '22 09:10

uksz