Google Cloud Storage Command-line Utility [GSUTIL]

GSUTIL Command-line utility for Google Cloud Storage




Create Bucket (Including Storage Class, Location)

gsutil mb -c [storage class] -l [location] gs://bucket-name
Remove Bucket 

gsutil rm -r gs://bucket-name
Parallel multi-threading copy 

gsutil -m  cp -r . gs://bucket-name
Turn on versioning on bucket (get details of versioning enable or not) 

gsutil versioning get gs://bucket-name
Set versioning off

gsutil versioning set off gs://bucket-name
Enable the versioning

gsutil versioning set on gs://bucket-name
List all version of a file

gsutil ls -a gs://bucket-name
Long listing format generation and meta-generation

gsutil ls -al gs://bucket-name
Changes the storage class of a object in a bucket 

gsutil rewrite -s NEARLINE gs://bucket-name/*
Change the storage class of multiple objects (Multi-Threading Parallel) 

gsutil -m rewrite -s NEARLINE gs://bucket-name/*
Access Control List (ACL) on objects (Public access to the general public)

gsutil acl ch -u AllUsers:R gs://bucket-name/filename
ACL Remove the public access to the general public 

gsutil acl ch -d AllUsres gs://bucket-name/filename
Removed the bucket and inside it's objects

gsutil -m rm -r gs://bucket-name
Removed only objects inside a bucket

gsutil -m rm -r gs://bucket-name/*
Check the storage space of a bucket 

gsutil du -h gs://bucket-name 
gsutil help for commands 

gsutil [command] help
Rsync within folders in bucket 

gsutil rsync [source-folder] [target-folder]
Rsync from local folder to GCS bucket folder 

gsutil rsync [local-folder] gs://bucket-name
Rsync deleted the contents in the target when deleted from the source 

gsutil -m rsync -r -d [local-folder] gs://bucket-name/
Signed URL (Give access to a object for the specific time period)

We need to create a service account for that and use the same json key for Sign URL -

gsutil signurl -d 10m -m GET [path-to-the-json-key] gs://bucket-name

Popular posts from this blog

Firewalld Command - Useful firewall-cmd Examples (RHEL based)

How to Convert PEM KeyFile into PPK KeyFile and vice versa?