Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transfer Firebase Storage Bucket between projects

I am attempting to copy the contents of a folder in one Firebase project's Storage bucket to the storage bucket of another Firebase project.

I have been following the firestore docs and this SO question.

Both projects have the necessary permissions to other's service accounts.

Here is what I have done:

When attempting to transfer files from a folder in the default bucket of Project-A to the default bucket of Project-B using the cloud shell terminal, I first set the project to 'Project-A'. I then ran gcloud beta firestore export gs://[PROJECT_A_ID] --collection-ids=[FOLDER_TO_TRANSFER] --async. This succeeds and creates a folder called "2019-08-26T21:23:23_26014/" in Project-A. This folder contains some metadata. Next, I tried beginning the import by setting the project to Project-B and running gcloud beta firestore import gs://[PROJECT_A_ID]/2019-08-26T21:23:23_26014 This completes and the logs display this message:

done: true metadata: '@type': type.googleapis.com/google.firestore.admin.v1beta1.ImportDocumentsMetadata collectionIds: - [FOLDER_TO_TRANSFER] endTime: '2019-08-26T21:25:56.794588Z' inputUriPrefix: gs://[PROJECT_A_ID]/2019-08-26T21:23:23_26014 operationState: SUCCESSFUL startTime: '2019-08-26T21:25:19.689430Z' name: projects/[PROJECT_B]/databases/(default)/operations/[SOME_ID_STRING] response: '@type': type.googleapis.com/google.protobuf.Empty

However, the Project-B storage bucket doesn't have any new files or folders. It looks like the import did nothing. Am I missing something?

like image 632
Chris Voss Avatar asked Aug 26 '19 22:08

Chris Voss


People also ask

How do I duplicate a project in Firebase?

There is currently no way (neither through the Console or through an API) to create a project that is a clone of another project. At the moment you will have to re-create the config data in the new project manually.

Is Firebase storage same as Google Cloud Storage?

The new Firebase Storage is powered by Google Cloud Storage, giving it massive scalability and allowing stored files to be easily accessed by other projects running on Google Cloud Platform. Firebase now uses the same underlying account system as GCP, which means you can use any GCP product with your Firebase app.


1 Answers

You can create a transfer job in the GCP Console. You can specify source/destination buckets from different projects as long as you have access permissions. You can specify the folder by setting "Specify file filters":

https://console.cloud.google.com/storage/transfer

You can also use the gsutil tool, which is part of gcloud, to move or copy your objects to another bucket.

So your default buckets would be gs://[PROJECT_A_ID].appspot.com and gs://[PROJECT_B_ID].appspot.com Let's say you wanted to copy over the contents of my_directory:

gsutil cp -r gs://[PROJECT_A_ID].appspot.com/my_directory gs://[PROJECT_B_ID].appspot.com
like image 131
Juan Lara Avatar answered Nov 16 '22 02:11

Juan Lara