When you create a bucket, some of the properties you set are permanent and cannot be changed, including the bucket's name, its geographic location, and the project it is part of. However, you can effectively move or rename your bucket:
If there is no data in your old bucket, delete the bucket and create another bucket with a new name, in a new location, or in a new project.
If you have data in your old bucket, create a new bucket with the desired name, location, and/or project, copy data from the old bucket to the new bucket, and delete the old bucket and its contents. The steps below describe this process.
If you want your new bucket to have the same name as your old bucket, you must temporarily move your data to a bucket with a different name. This lets you delete the original bucket so that you can reuse the bucket name.
Moving data between locations incurs network usage costs. In addition, moving data between buckets might incur retrieval fees, early deletion fees, or inter-region replication charges, depending on the storage classes and bucket locations involved.
Required permissions
Console
In order to complete this guide using the Google Cloud console, you must have the proper IAM permissions. If the buckets you want to access exist in a project that you did not create, you might need the project owner to give you a role that contains the necessary permissions.
For a list of permissions required for specific actions, see IAM permissions for the Google Cloud console.
For a list of relevant roles, see Cloud Storage roles. Alternatively, you can create a custom role that has specific, limited permissions.
Command line
In order to complete this guide using a command-line utility, you must have the proper IAM permissions. If the buckets you want to access exist in a project that you did not create, you might need the project owner to give you a role that contains the necessary permissions.
For a list of permissions required for specific actions, see IAM permissions for gsutil commands.
For a list of relevant roles, see Cloud Storage roles. Alternatively, you can create a custom role that has specific, limited permissions.
REST APIs
JSON API
In order to complete this guide using the JSON API, you must have the proper IAM permissions. If the buckets you want to access exist in a project that you did not create, you might need the project owner to give you a role that contains the necessary permissions.
For a list of permissions required for specific actions, see IAM permissions for JSON methods.
For a list of relevant roles, see Cloud Storage roles. Alternatively, you can create a custom role that has specific, limited permissions.
Move data from one bucket to another
Console
Use the Cloud Storage Transfer Service from within Google Cloud console:
- If you don't have a destination bucket yet, create the bucket.
Open the Transfer page in the Google Cloud console.
- Click Create transfer job.
Follow the step-by-step walkthrough, clicking Next step as you complete each step:
Choose a source: Use Google Cloud Storage bucket as your source type, and either enter the name of the wanted bucket directly, or click Browse to find and select the bucket you want.
Choose a destination: Either enter the name of the wanted bucket directly, or click Browse to find and select the bucket you want.
Choose settings: Select the option Delete files from source after they're transferred.
Scheduling options: You can ignore this section.
After you complete the step-by-step walkthrough, click Create.
This begins the process of copying objects from your old bucket into your new one. This process may take some time; however, after you click Create, you can navigate away from the Google Cloud console.
To view the transfer's progress:
Open the Transfer page in the Google Cloud console.
To learn how to get detailed error information about failed Cloud Storage operations in the Google Cloud console, see Troubleshooting.
Once the transfer completes, you don't need to do anything to delete the objects from your old bucket if you selected the Delete source objects after the transfer completes checkbox during setup. You may, however, want to also delete your old bucket, which you must do separately.
Command line
gcloud
If you don't have one yet, create a destination bucket.
To copy the contents of your source bucket to your destination bucket, use one of the following methods:
To recursively copy all your objects from the source bucket to the destination bucket, use the
gcloud storage cpcommand with the--recursiveoption:gcloud storage cp --recursive gs://SOURCE_BUCKET/* gs://DESTINATION_BUCKET
Where:
SOURCE_BUCKETis the name of your original bucket. For example,old-bucket.DESTINATION_BUCKETis the name of the bucket you are moving your data to. For example,my-bucket.
To recursively copy all your objects and managed folders from the source bucket to the destination bucket, use the
gcloud alpha storage cpcommand with the--include-managed-foldersand--recursiveoptions:gcloud alpha storage cp --include-managed-folders --recursive gs://SOURCE_BUCKET/* gs://DESTINATION_BUCKET
Where:
SOURCE_BUCKETis the name of your original bucket. For example,old-bucket.DESTINATION_BUCKETis the name of the bucket you are moving your data to. For example,my-bucket.
To delete the source bucket, use one of the following methods:
To recursively delete all objects from the source bucket, along with the source bucket itself, use the
gcloud storage rmcommand with the--recursiveoption:gcloud storage rm --recursive gs://SOURCE_BUCKET
Where
SOURCE_BUCKETis the name of your original bucket. For example,old-bucket.To recursivley delete all objects and managed folders from the source bucket, along with the source bucket itself, use the
gcloud alpha storage rmcommand with the--recursiveoption:gcloud alpha storage rm --recursive gs://SOURCE_BUCKET
Where
SOURCE_BUCKETis the name of your original bucket. For example,old-bucket.To delete the objects and managed folders from the source bucket without deleting the source bucket itself, use the
gcloud alpha storage rmcommand without the--recursiveflag:gcloud alpha storage rm --all-versions gs://SOURCE_BUCKET/**
Where
SOURCE_BUCKETis the name of your original bucket. For example,old-bucket.
gsutil
If you don't have a destination bucket yet, create the bucket.
Use the
gsutil cpcommand with the-roption to recursively copy all your objects from the source bucket to the destination bucket:gsutil cp -r gs://SOURCE_BUCKET/* gs://DESTINATION_BUCKET
Where:
SOURCE_BUCKETis the name of your original bucket. For example,old-bucket.DESTINATION_BUCKETis the name of the bucket you are moving your data to. For example,my-bucket.
Use the
gsutil rmcommand with the-roption to recursively delete all your objects from the source bucket, as well as the source bucket itself:gsutil rm -r gs://SOURCE_BUCKET
Where
SOURCE_BUCKETis the name of your original bucket. For example,old-bucket.Or, to delete the objects but keep the source bucket:
gsutil rm -a gs://SOURCE_BUCKET/**
REST APIs
JSON API
If you don't have a destination bucket yet, create the bucket.
Copy each object from your source bucket to the destination bucket.
Delete each object in your source bucket.
XML API
If you don't have a destination bucket yet, create the bucket.
Copy each object from your source bucket to the destination bucket.
Delete each object in your source bucket.
What's next
Learn about available bucket locations and bucket naming guidelines.
Learn more about creating and managing data transfers with the Google Cloud console.
Explore the Bucket mover tool, an unofficial tool for making bucket moving easier.
Learn more about folders and managed folders in Cloud Storage.