November 11, 2016 - rob

Installing google drive without having a x server

I have a few vps servers that I use, and I wanted to upload some backup files to one of my google drive’s.   While I have used google-drive-ocamlfuse on my workstation pc’s, it requires a web browers for the initial drive connection and also uses FUSE which I could not run on my vps servers.  I came across a app called gdrive which can upload files to google drive without the need for FUSE.   The installation is quite simple:

First head over to the page and download it:

https://github.com/prasmussen/gdrive

I downloaded the 64 bit version using:

wget -O drive https://drive.google.com/uc?id=0B3X9GlR6EmbnMHBMVWtKaEZXdDg

Now move the file to /usr/sbin/

mv drive /usr/sbin/drive

And finally, make it executable:
chmod 755 /usr/sbin/drive

Now just run drive and you will get a link to put in any browser:

Go to the following link in your browser:
https://accounts.google.com/o/oauth2/auth?client_id=123456789123-7n0vf5akeru7on6o2fjinrecpdoe99eg.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=state

It will prompt you to login to your google account and allow access.  Once done, it will give you a code you paste back in your terminal:

Enter verification code: 4/9gKYAFAJ326XIP6JJHAEhs342t35LPiA5QGW0935GHWHy9

If you run drive with no options, the help page will appear:
Usage: drive [global options] <verb> [verb options]

Global options:
-a, –advanced Advanced Mode — lets you specify your own oauth client id and secret on setup
-c, –config Set application path where config and token is stored. Defaults to ~/.gdrive
-v, –version Print version
-h, –help Show this help

Verbs:
delete:
-i, –id File Id (*)
download:
-i, –id File Id (*)
–format Download file in a specified format (needed for google docs)
-s, –stdout Write file content to stdout
–force Overwrite existing file
–pop Download latest file, and remove it from google drive
folder:
-t, –title Folder to create (*)
-p, –parent Parent Id of the folder
–share Share created folder
info:
-i, –id File Id (*)
–bytes Show size in bytes
list:
-m, –max Max results
–include-docs Include google docs in listing
-t, –title Title filter
-q, –query Query (see https://developers.google.com/drive/search-parameters)
-s, –shared Show shared status (Note: this will generate 1 http req per file)
-n, –noheader Do not show the header
–bytes Show size in bytes
quota:
–bytes Show size in bytes
share:
-i, –id File Id (*)
unshare:
-i, –id File Id (*)
upload:
-f, –file File or directory to upload (*)
-s, –stdin Use stdin as file content (*)
-t, –title Title to give uploaded file. Defaults to filename
-p, –parent Parent Id of the file
–share Share uploaded file
–mimetype The MIME type (default will try to figure it out)
–convert File will be converted to Google Docs format
-C, –chunksize Set chunk size in bytes. Minimum is 262144, default is 4194304. Recommended to be a power of two.
url:
-i, –id File Id (*)
-p, –preview Generate preview url (default)
-d, –download Generate download url

 

Linux