mb - Make buckets
gsutil mb [-b <on|off>] [-c class] [-l location] [-p proj_id] [--retention time] url...
The mb command creates a new bucket. Cloud Storage has a single namespace, so you are not allowed to create a bucket with a name already in use by another user. You can, however, carve out parts of the bucket name space corresponding to your company's domain name (see "gsutil help naming").
If you don't specify a project ID using the -p option, the bucket is created using the default project ID specified in your gsutil configuration file (see gsutil help config). For more details about projects see gsutil help projects.
The -c and -l options specify the storage class and location, respectively, for the bucket. Once a bucket is created in a given location and with a given storage class, it cannot be moved to a different location, and the storage class cannot be changed. Instead, you would need to create a new bucket and move the data over and then delete the original bucket.
The --retention option specifies the retention period for the bucket. For more details about retention policy see gsutil help retention.
The -b option specifies the Bucket Policy Only setting of the bucket. ACLs assigned to objects are not evaluated in buckets with Bucket Policy Only enabled. Consequently, only IAM policies grant access to objects in these buckets.
Bucket Storage Classes
You can specify one of the storage classes for a bucket with the -c option.
gsutil mb -c nearline gs://some-bucket
If you don't specify a -c option, the bucket is created with the default storage class Standard Storage.
You can specify one of the available locations for a bucket with the -l option.
gsutil mb -l asia gs://some-bucket gsutil mb -c standard -l us-east1 gs://some-bucket
If you don't specify a -l option, the bucket is created in the default location (US).
You can specify retention period in one of the following formats:
- --retention <number>s
- Specifies retention period of <number> seconds for objects in this bucket.
- --retention <number>d
- Specifies retention period of <number> days for objects in this bucket.
- --retention <number>m
- Specifies retention period of <number> months for objects in this bucket.
- --retention <number>y
- Specifies retention period of <number> years for objects in this bucket.
gsutil mb --retention 1y gs://some-bucket gsutil mb --retention 36m gs://some-bucket
If you don't specify a --retention option, the bucket is created with no retention policy.
Bucket Policy Only
You can specify one of the available settings for a bucket with the -b option.
gsutil mb -b off gs://bucket-with-acls gsutil mb -b on gs://bucket-with-no-acls
|-b <on|off>||Specifies the Bucket Policy Only setting. Default is "off"|
|-c class||Specifies the default storage class. Default is "Standard".|
|-l location||Can be any supported location. See https://cloud.google.com/storage/docs/locations for a discussion of this distinction. Default is US. Locations are case insensitive.|
|-p proj_id||Specifies the project ID under which to create the bucket.|
|-s class||Same as -c.|
|Specifies the retention policy. Default is no retention policy. This can only be set on gs:// buckets and requires using the JSON API.|