Downloading your files from Google Cloud Storage using Ubuntu 16.04

Ahmed Ramzy
3 min readDec 18, 2019
Photo by jesse orrico on Unsplash

Hello Everyone, this is my first story so please ignore any Typos.

As you know Google Cloud Storage is essential nowadays as most of people use it to upload all of their files on it.

So what if you had a big project deployed on Google virtual instances as an example and you choose Google cloud storage as your main storage and you want to one day to download all of these data on your hard-drive to backup it or to do any actions on these data.

Simply these are the steps you should follow to be able to download your files from google bucket to your disk with Ubuntu 16.04 :

1- install gsutil tool

Don’t do

 “sudo apt-get install gsutil “ 

as this command will install another program which is “GrandStream configuration dump/restore + reboot”

So you need to download it from this link and extract it: http://commondatastorage.googleapis.com/pub/gsutil.zip

Then go to .bashrc file and add this line:

export PATH=”/home/ahmed/Downloads/gsutil/:$PATH”

thanks to this post https://github.com/GoogleCloudPlatform/gsutil/issues/112

2- Configure your gsutil:

go to terminal and write this command:

gsutil config

it will output some text containing a link , when you open this link it will show you an activation code, copy it then paste it on the terminal

After successfully pasting your activation code , it will ask you to put the project id

you can Get it by clicking on the project name beside the Logo

a popup will open that have the project name and the project ID so copy the project ID and paste it on the terminal

3- Get your bucket name:

go to: https://console.cloud.google.com/

from menu choose: storage

you will find the list of buckets , get the bucket name ( in my case: ahmedramzy)

4- check what you have in the storage by opening the bucket by clicking on it:

so now we have an image and a folder containing the same image so let’s DOWNLOAD them

5- run this command to download all the files where “ahmedramzy” is the bucket name

gsutil cp -r gs://ahmedramzy/* /home/ahmed/Documents/output_folder/

After running this command , this is what will appear:

and finally you can see them at the folder stated in the command.

Now you successfully downloaded all your files to the hard dis google cloud storage using only the terminal in UBUNTU 16.04

More details about gsutil is available in Google Cloud documentation on this link: https://cloud.google.com/storage/docs/gsutil

Hope it helps you.

Have a nice day! .

--

--