iTranslated by AI
Duplicating Firebase Projects and Changing Project IDs
What to do
To clone a project, you will need to:
- Create the destination project
- Change IDs in the source code
- Switch the source project to the Blaze Plan (if not already)
- Migrate Firestore data
I am documenting this process, focusing primarily on Firestore data migration.
Changing IDs in the source code
Regarding deployment, it seems like changing .firebaserc is basically all that's required.
Firestore data migration
In this explanation, the source project ID is old_name and the new project ID is new_name.
Follow the steps in Exporting and importing data | Firebase.
Create a bucket for the data in the Storage Browser – Storage – scoreform – Google Cloud Platform.
Make a note of the gsutil link.
(Example: gs://old_name-backup)
# Switch to the source project
$ gcloud config set project old_name
# Export to the bucket
$ gcloud firestore export gs://old_name-backup
Make a note of the exported folder name.
(Example: /2020-07-26T13:00:29_42888)
# Switch to the new project
$ gcloud config set project new_name
# Grant bucket permissions to the service account of new_name
$ gsutil iam ch serviceAccount:{new project name}@appspot.gserviceaccount.com:admin gs://old_name-backup
# Import from the bucket to the new Firestore
$ gcloud firestore import gs://old_name-backup/2020-07-26T13:00:29_42888
Following these steps, I was able to complete the migration.
If the regions of the source and destination Firestore are different, an error will occur during import or export.
In that case, I confirmed that it is possible to import by preparing buckets in both regions and moving the data.
Discussion