Move data between projects Stay organized with collections Save and categorize content based on your preferences.
This page describes how to use the managed import and export featuresto moveCloud Firestore data from oneproject to another. This can be useful for setting up a development environmentor as part of permanently migrating an app to another project.The example on this page demonstrates how to export data from asource project and then import that data into a destination project. Moving databetween projects involves the following steps:
- Create aCloud Storage bucket to hold the data from your source project.
- Export the data from your source project to the bucket.
- Give your destination project permission to read from the bucket.
- Import the data from the bucket into your destination project.
Before you begin
Before you can use the managed export and import service, you must complete thefollowing tasks:
- Enable billing for both your source project and destination project. OnlyGoogle Cloud projects with billing enabled can use the export and import functionality.Note: Firebase projects must be on theBlaze plan to use the managed export and import service. Enabling billing for theGoogle Cloud automatically upgrades your Firebase project to the Blaze plan.
Make sure your account has the necessary Cloud IAM permissions in your source project and destination project.If you are a project owner for both projects, your account has the required permissions. Otherwise, the following Cloud IAM roles grant the necessary permissions forCloud Firestore export and import operations:
Note: These roles grant permissions for bothDatastore andCloud Firestore.Owner,Cloud Datastore Owner, orCloud Datastore Import Export AdminA project owner can grant one of these roles by following the steps inGrant access.
Set up the
gcloudcommand-line tool and connect to your project in one of the following ways:Access
gcloudfrom theGoogle Cloud console usingCloud Shell.Make sure
gcloudis configured for the correct project:gcloudconfigsetproject[SOURCE_PROJECT_ID]
Set up indexes in your new project. The composite indexes should match between the source and destination projects. Indexes should be set up first to avoid having to process each document multiple times.
Export data from the source project
Export your data by creating aCloud Storage bucket for yourCloud Firestore export files and starting an export operation.
Create aCloud Storage bucket
Create aCloud Storage bucket in the same location as yourCloud Firestoredatabase. To view your database location, see yourproject location setting.You cannot use a Requester Pays bucket for export and import operations.
If yourCloud Storage bucket is not in yoursource project, you must give the source project'sdefault service account access to the bucket. EachGoogle Cloud projecthas an automatically created default service account with the namePROJECT_ID@appspot.gserviceaccount.com.Cloud Firestoreexport operations use this default service account to authorizeCloud Storagebucket operations. To give thedefault service account access to your source bucket, grant it theStorage Adminrole.
You can grant this role with thegsutil toolavailable inCloud Shell:
gsutiliamchserviceAccount:[service-PROJECT_NUMBER]@gcp-sa-firestore.iam.gserviceaccount.com:roles/storage.admin\gs://[BUCKET_NAME]@
You can alsogrant this role in theGoogle Cloud console.
Disable write operations (optional)
If your app continues to write to your database while you perform an exportoperation, you might not capture all of those writes in your export files. Toexport data from a consistent state, disable writes to your database by updatingyour security rules and halting any Admin SDK operations.
Update security rules
In theCloud FirestoreRules tab of the console, update your source project security rules to deny all writes. For example:
//Denywriteaccesstoallusersunderanyconditionsservicecloud.firestore{match/databases/{database}/documents{match/{document=**}{allowwrite:iffalse;}//Readsdonotaffectexportoperations//Addyourreadruleshere}}Halt writes from Admin SDKs
Security rules do not stop writes coming from privileged server environments created using aFirebase Admin SDK or aGoogle Cloud Server Client Library. Make sure to halt write operations from your admin servers by shutting down or updating your servers.
Begin an export operation
Use thegcloud firestore export command to exportdata from your source project. You can export all your data or onlyspecific collection groups. Replace[SOURCE_BUCKET] with the name of yourCloud Storage bucket:
- Export all data
gcloud firestore export gs://[SOURCE_BUCKET] --async
- Export specific collection groups
gcloud firestore export gs://[SOURCE_BUCKET] --collection-ids=[COLLECTION_GROUP_ID_1],[COLLECTION_GROUP_ID_2] --async
Take note of your export operation'soutputURIPrefix as you will usethis later on. By default,Cloud Firestore adds a pre-fix to your exportfiles based on a timestamp:
outputUriPrefix:gs://[SOURCE_BUCKET]/2019-03-05T20:58:23_56418As the export operation runs, you can use thefirestore operations listcommand to view your operation's progress:
gcloud firestore operations list
Import data into the destination project
Next, give the destination project access to yourCloud Firestore data files and start an import operation.
Give the destination project access to your data files
Before you can begin an import operation, you mustmake sure your destination project can access yourCloud Firestoredata files.
Move data files to a local bucket
If your source bucket location is different from theCloud Firestore location of your destination project, you must moveyour data files to aCloud Storage bucket in the samelocation as your destination project.
Move your data files to anotherCloud Storage bucket by following the stepsinMoving and Renaming Buckets.For all the following steps, use this new bucket as the[SOURCE_BUCKET].
Give the project service account access to your source bucket
If your source bucket is not in your destination project, then you must give thedestination project's default service account access to your source bucket. Thedefault service account is named[DESTINATION_PROJECT_ID]@appspot.gserviceaccount.com. Togive the default service account access to your source bucket, grant it theproper permissions to access the bucket.
You can grant the necessary roles with thegsutil toolavailable inCloud Shell:
gsutiliamchserviceAccount:[DESTINATION_PROJECT_ID]@appspot.gserviceaccount.com:legacyBucketReader,legacyObjectReader\gs://[SOURCE_BUCKET]
You can alsogrant this role in theGoogle Cloud console.
Begin an import operation
Before starting the import operation, make suregcloud is configuredfor the correct project:
gcloudconfigsetproject[DESTINATION_PROJECT_ID]
Use thegcloud firestore import command to import the data inyour source bucket into your destination project:
gcloud firestore import gs://[SOURCE_BUCKET]/[EXPORT_PREFIX] --async
Where[EXPORT_PREFIX] matches the prefix in your export operation'soutputUriPrefix. For example:
gcloud firestore import gs://[SOURCE_BUCKET]/2019-03-05T20:58:23_56418 --async
As the export operation runs, you can use thefirestore operations listcommand to view your operation's progress:
gcloud firestore operations list
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-18 UTC.