mb - Make buckets

mb - Make buckets

Synopsis

gsutil mb [-c class] [-l location] [-p proj_id] [--retention time] url...

Description

The mb command creates a new bucket. Google 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.

Bucket Storage Classes

You can specify one of the storage classes for a bucket with the -c option.

Example:

gsutil mb -c nearline gs://some-bucket

See online documentation for pricing and SLA details.

If you don't specify a -c option, the bucket is created with the default storage class Standard Storage, which is equivalent to Multi-Regional Storage or Regional Storage, depending on whether the bucket was created in a multi-regional location or regional location, respectively.

Bucket Locations

You can specify one of the available locations for a bucket with the -l option.

Examples:

gsutil mb -l asia gs://some-bucket

gsutil mb -c regional -l us-east1 gs://some-bucket

If you don't specify a -l option, the bucket is created in the default location (US).

Retention Policy

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.

Examples:

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.

Options

-c class Specifies the default storage class. Default is "Standard". Can only be set for gs:// buckets.
-l location Can be any multi-regional or regional location. See https://cloud.google.com/storage/docs/bucket-locations for a discussion of this distinction. Default is US for gs:// buckets. Locations are case insensitive.
-p proj_id Specifies the project ID under which to create the bucket. Can only be set for gs:// buckets.
-s class Same as -c.
--retention time
   
Specifies the retention policy. Default is no retention policy. Can only be set for gs:// buckets and requires using the JSON API.
Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Storage
Need help? Visit our support page.