NoSQL database serving apps published on Firebase.

Basic Rules

  • Make sure you get the rules right. Rules who is allowed to read and/or write content.
  • You should have one document serving content of one page whenever possible. Fewer reads.
  • Firebase console may serve as admin backend to edit content.
  • I haven't seen any automatic backup, snapshots being saved. I use the script below to backup content.
  • You can use a firestore db as your data storage. No need to have a web site or app using it.


Python Code Backup

We use this code to loop through all collections and fetch every document.

import json 

import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore

    cred = credentials.Certificate("../credentials-yourcredentials.json")
    db = firestore.client()
    print('Firestore Connection Created')
    print('Firestore Connection Exists')

# Loops through each collection in the list, fetches each document and 
# stores the document content in a dictionary where the key is the 
# document id 
collections = ['collection1', 'collection2']
for collection in collections:
	documents_ref = db.collection(collection).stream()
	documents = {}
	for item in documents_ref:
		documents[] = item.to_dict()
	with open('backup/'+collection+'.json', 'w', encoding='utf8') as fp:
		json.dump(documents, fp,  indent=4, ensure_ascii=False)


Credentials to connect to firestore instance can be downloaded from Google Cloud Console. Note they are secret and should remain secret.

Content is saved as json files in the backup folder where we zip the files and move them to backup storage.