If you need save some separate collection on your computer or you want backup your data outside of Firebase and default options on Google bucket.
Working together firestore.client and tinyDb you can store your data on your computer or any other server.
Google has a well-functioning system for import / export data, but in exceptional cases it needs extra copy, then you can execute it with such a script.
dbfile = "data/CategoryToLabelMapper.json"
cred = credentials.Certificate("firebase-adminsdk-m3mts-d27dbb2c96.json")
firebase_admin.initialize_app(cred)
db = firestore.client()
tiny = TinyDB(dbfile)
collection = db.collection('CategoryToLabelMapper')
docs = collection.stream()
for doc in docs:
dic = doc.to_dict()
tiny.insert({doc.id: dic})
So, your export file will be something like this.
For default solution please follow this documentation.
https://firebase.google.com/docs/firestore/manage-data/export-import
Go to the Cloud Firestore Import/Export page in the Google Cloud Platform Console.
Click Export.
Click the Export one or more collection groups option. Use the dropdown menu to select one or more collection groups.
Below Choose Destination, enter the name of a Cloud Storage bucket or use the Browse button to select a bucket.
Click Export.
The console returns to the Import/Export page. If the operation successfully starts, the page adds an entry to the recent imports and exports page. On failure, the page displays an error message.
Comments
Post a Comment