Pages

06 February 2016

629. Google drive with rclone on debian jessie

My free dropbox account has 6Gb storage, whereas my google drive has 15Gb. Dropbox pro is way too expensive, so here's what you can do to get your google drive to work ok-ish with linux.

To set up rclone, do:
cd ~/Downloads
wget http://downloads.rclone.org/rclone-current-linux-amd64.zip
unzip rclone-current-linux-amd64.zip
cd rclone-v1.27-linux-amd64
sudo cp rclone /usr/bin/
rclone config
No remotes found - make a new one n) New remote q) Quit config n/q> n name> google_drive What type of source is it? Choose a number from below 1) amazon cloud drive 2) b2 3) drive 4) dropbox 5) google cloud storage 6) swift 7) hubic 8) local 9) onedrive 10) s3 11) yandex type> 3 Google Application Client Id - leave blank normally. client_id> Google Application Client Secret - leave blank normally. client_secret> Remote config Use auto config? * Say Y if not sure * Say N if you are working on a remote or headless machine or Y didn't work y) Yes n) No y/n> y If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth Log in and authorize rclone for access Waiting for code... Got code -------------------- [google_drive] client_id = client_secret = token = {"access_token":"y**5","token_type":"Bearer","refresh_token":"1/o**T","expiry":"2016-02-06T18:41:22.167889627+11:00"} -------------------- y) Yes this is OK e) Edit this remote d) Delete this remote y/e/d> y Current remotes: Name Type ==== ==== google_drive drive e) Edit existing remote n) New remote d) Delete remote q) Quit config e/n/d/q> q

Syncing is a bit of an issue as you can't sync based on last changed file. So, my solution is that each device has it's own folder that it syncs up to, and each device syncs down all other folders. For my two devices, nb and be, I have thus set it up like this:

Create new dirs and sync:
mkdir ~/gdrive/nbdrive -p
mkdir ~/gdrive/bedrive

On Nb the crontab looks like this:
*/2 *    * * * rclone sync /home/me/gdrive/nbdrive google_drive:/nbdrive
*/10 *   * * * rclone sync google_drive:/bedrive /home/me/gdrive/bedrive

and on Be it looks like this:
*/10 *    * * * rclone sync google_drive:/nbdrive /home/me/gdrive/nbdrive 
*/2 *   * * * rclone sync /home/me/gdrive/bedrive google_drive:/bedrive 

If I do work on a file on Be I then copy it to bedrive, and edit it. To edit it late on Nb I copy it from bedrive to nbdrive and edit it. Of course I could always sync manually and avoid this, but the above is a solution for people who might not feel comfortable working on the command line or if you want everything automated.