gsutil
gsutil is part of Google Cloud SDK allow you to work with Google Cloud Storage.
Configure
Before you can use gsutil, run
1 |
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
1 |
gcloud config set project PROJECT_ID |
Create a Bucket
1 2 3 |
root@india:~# gsutil mb gs://backup-india Creating gs://backup-india/... root@india:~# |
List all Buckets
1 2 3 4 5 |
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
1 |
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.
1 |
gsutil -m rsync -r /home/indiamed/public_html/ gs://backup-india/site-files/ |
To list all files in a bucket, run
1 |
gsutil ls gs://bucket-name/ |
To copy files to a bucket, run
1 |
gsutil cp *.* gs://bucket-name/ |