I have an ECS instance server on alibaba cloud, the server itself installed with Ubuntu 16.04 and it operationally used for a web server and database server for my client. Today my client ask me to backup all website content with the database to his google drive account. So I will share you about how to install google drive on Ubuntu to Upload File to Google drive account via command line.

Install GDrive Client

First you download gdrive cli client (I’m using wget):

wget https://docs.google.com/uc?id=0B3X9GlR6EmbnWksyTEtCM0VfaFE&export=download

You will see a file in home or in your root directory named something like this uc?id=0B3X9G1R6EmbnWksyTEtCM0VfaFE

Then find location or a path of the file by typing this command:

find / -name uc?id*

The screenshot above showing that the file has been stored at /root directory Make a gdrive directory and move thus file there

Give the execute permission to gdrive directory, type this command:

chmod +x /gdrive

Then install with this command:

Install gdrive/uc?id=0B3X9G1R6EmbnWksyTEtCM0VfaFE /usr/local/bin/gdrive

Setting Google Drive Authentication

After installed, then you must configure it to connect gdrive with your google drive account.

Type this command to triggering the authentication process:

gdrive list

You will see an url, then you must copy and paste the url to the browser:

Just paste the url on the browser, then you will get verification code from the browser

Then put again the verification code from the browser to the console:

Done..!!

You will see the console will displaying your list of files on google drive:

Testing Upload

To test upload just type the following command:

Gdrive upload [file to upload]

You will see uploaded status when it done:

Now With Windows Command

Fyi, I’m using Windows 7 professional SP1

First download GDrive for Windows Version. Open your browser to https://github.com/prasmussen/gdrive then download gdrive for windows version 32 / 64 bit depend on your system.

Save the file as C:\Windows\gdrive-windows-x64.exe

Setting Google Drive Authentication

There is no installation process needed, after the file copied then you must configure it to connect with your google drive account.

Type this command to triggering the authentication process:

gdrive-windows-x64 list

Then you will see an url, then you must copy and paste the url to the browser:

Paste the url on the browser, then you will get verification code from the browser

Then put again the verification code from the browser to the console:

Done..!! You will see the console will displaying your list of files on google drive.

Testing Upload File

To test upload just type the following command:

gdrive-windows-x64 upload [file to upload]

For example, I will upload one file at D:\ngoprex.com\gdrive.PNG to google drive.

Result:

Thats all, I hope this useful for you, any questions feel free to mail me

or contact me on my linkedin page

--

--

Mfadly N

Normative citizen, A Husband & Father, IT Guy, Freelance Hacker, Freelance Gamer, Boxing, Basketball and Cuan enthusiast