When working with Firebase Cloud Firestore, it is a common pattern to have development/staging projects or local emulators with the same collections as the production environment. Sometimes it’s necessary to copy data from production to development, for example to implement new features and debug production issues.
Making this process as easy as possible was one of the reasons we created Firefoo, a GUI client for Firestore!
In a convenient user interface, it’s simple to copy data between Firebase projects. Use cases include daily data transfers between different environments, regular data backups, or populating the local emulator. Without code or complex configuration you can migrate data with fine-grained control, e.g. by selecting only specific collections, documents or subcollections.
Transfer Firestore Data between Projects
- Download and install Firefoo.
- If prompted, sign in with Google.
- Right-click the source project in the sidebar and choose Transfer Data…
4. Choose a target project.
5. Select all collections that you want to copy.
6. That’s it! Click the blue Start Transfer button.
The data transfer is starting and a progress popup opens. The process will continue to run in the background when you close that popup. Get back to the progress popup again through File › Tasks. Use the Cancel button in this popup if you want to stop the transfer after it has started.
Options
☑️ Clean target collections
When selected, Firefoo will remove all selected collections from the target project (delete all their documents and subcollections) before transferring data to them. Collections that are not selected in the list will be left unchanged in the target project regardless of whether this option is selected. Documents in the source collection will never be changed or deleted.
☑️ Include subcollections
When selected, Firefoo will recursively include all subcollections and their documents in the data transfer. Unselect this option if you know that your collections do not contain any subcollections to speed up the transfer and reduce the number of Firebase requests.
☑️ Limit docs per collection
Some collections might be huge and you’re only interested in a tiny fraction of the data. Use this limit to control how many documents are transferred per collection. If your collections contain documents with subcollections, every single subcollection will also copy up to this many documents.
☑️ Custom target paths
Use this option to rename collections during the transfer, e.g. give a prefix to a collection in the target database. This feature also allows you to duplicate data within the same project.
Custom Paths
At the bottom of the collection list you can add any number of custom target paths. These can point to any Firestore reference, be it a collection (e.g. /cities
), a document (e.g. /cities/berlin
) or subcollection (/cities/berlin/restaurants
). Use this if you want to copy only specific data from a collection.
FAQ
How is the data transferred?
If you select the ☑️ Clean target collections option, Firefoo will delete documents of the target collections (and their subcollections) before transferring any data.
Then Firefoo proceeds to go through the source collections, downloads documents in batches and uploads them to the target collections. This happens on-the-fly, so that only a tiny portion of the whole data needs to fit into the working memory of your machine at a time. The data is not permanently saved on your machine during data transfers, check out the Export feature for that matter.
Documents in the source collections will never be changed or deleted. Documents in the target collections (or their subcollections) will be overwritten when they share the same document ID.
Can I execute the same transfer multiple times?
You can save Transfers and open them later. Click the ⭐ icon left of the blue Start Transfer button in the transfer tab. Open the saved data transfer later by clicking the star icon at the bottom of the sidebar. The transfer will not automatically get executed when you open it, you can still edit it before starting.
Can I Copy data within one Project
Yes! But to duplicate a collection, there’s already an easier way to do that. Just right-click the collection in the sidebar and select Duplicate Collection…
How many requests will this take away from my quota?
Firefoo uses two Firestore read requests on the source project for every document that is exported. The first to fetch the data, the second to check for subcollections. If you unselect the ️️☑️ Include subcollections option, only one request is necessary, saving half of these read requests! On the target Firebase project, one write request is used for every document that it receives. If the ☑️ Clean target collections option was selected, two read requests and one delete request is performed for every document that was deleted.