gsutil

Written by

gsutil is part of Google Cloud SDK allow you to work with Google Cloud Storage.

Configure

Before you can use gsutil, run

gcloud auth login

You will be given a special URL, open the link in browser, login to your google cloud account. Then you get a code, copy and paste it in terminal.

Now you are authenticated. Next you need to tell gcloud which project to use by running

gcloud config set project PROJECT_ID

Google Cloud

Create a Bucket

root@india:~# gsutil mb gs://backup-india
Creating gs://backup-india/...
root@india:~# 

List all Buckets

root@india:~# gsutil ls
gs://backup-india/
gs://credible-tesla-182607.appspot.com/
gs://staging.credible-tesla-182607.appspot.com/
root@india:~# 

To sync everything in a folder

gsutil rsync -r /path/to/folder/ gs://BUCKET_NAME/

-r == recursively.

Everything inside /path/to/folder/ will be synced to specified bucket. To speed up, you can use -m option.

gsutil -m rsync -r /home/indiamed/public_html/ gs://backup-india/site-files/

To list all files in a bucket, run

gsutil ls gs://bucket-name/

To copy files to a bucket, run

gsutil cp *.* gs://bucket-name/

See Google Cloud Storage, Google Cloud

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *