Cloud

How to sync from Linux to Google Drive with rclone

If you're looking for an open source tool to sync Google Drive to the Linux desktop, look no further than rclone.

drivehero.jpg
Image: Google

I am a Google Drive power user. I depend upon the cloud storage platform daily. And considering I use the Linux operating system as my daily driver, I've had to look elsewhere for sync tools (since Google has not opted to create a native Cloud client for Linux).

My go-to tool for this is Insync, which is an outstanding GUI tool. But I'm always on the lookout for something different. Since Insync is a proprietary (closed-source) project, I thought it would be good to find an open source tool for the task. I've already covered Grive2 (see How to sync your Google Cloud on Linux with Grive2) and wanted to find something else. That search led me to rclone, a command line program to sync files and directories to and from numerous cloud services (such as Amazon S3, Dropbox, FTP, Google Drive, HTTP, OneDrive, Nextcloud, ownCloud, pCloud, WebDAV, and many more).

SEE: Google Drive: Tips and tricks for business professionals (Tech Pro Research)

The installation and set up isn't too difficult, and there is a GUI tool to make managing a sync much easier. Let's install rclone and rclone-browser on Ubuntu Desktop 18.04, connect it to Google Drive, and then use the rclone-browser tool.

Installation

We'll install from a precompiled binary. To do this, open a terminal window and issue the following commands:

cd /tmp
curl -O https://downloads.rclone.org/rclone-current-linux-amd64.zip
unzip rclone-current-linux-amd64.zip
cd rclone-*-linux-amd64

Now, copy the binary file and give it the proper permissions with the following commands:

sudo cp rclone /usr/bin/
sudo chown root:root /usr/bin/rclone
sudo chmod 755 /usr/bin/rclone

Finally, install the manpage with the commands:

sudo mkdir -p /usr/local/share/man/man1sudo
cp rclone.1 /usr/local/share/man/man1/
sudo mandb

Configuring rclone

As I said, we're going to set this up to sync to Google Drive. Should you want to connect to a different service, check out the official docs for more information.

To configure rclone, issue the command:

rclone config

You will be asked a number of questions, most of which are self-explanatory. The only questions that might trip you up are:

Value "client_id"
Value "client_secret"
Value "root_folder_id"
Value "service_account_file"

To all of the above, just hit Enter.

For the Value "scope" = you can type whatever name you want. By default it will be drive. You can leave that or type something more meaningful (such as googledrive or gdrive).

Eventually, your default browser will open, asking you to select which Google account to use. If you've have not already signed into your Google account, you'll need to do so at this point. Once that completes, answer a few more simple questions and then quit the configuration script. Your connection is now setup.

Installing rclone-browser

To install the rclone-browser, open a terminal window and issue the command:

sudo nano /etc/apt/sources.list.d/rclonebrowser.list

In this new file, paste the following:

deb http://ppa.launchpad.net/mmozeiko/rclone-browser/ubuntu xenial main
deb-src http://ppa.launchpad.net/mmozeiko/rclone-browser/ubuntu xenial main

Save and close that file. Update apt with the command sudo apt update and then install rclone browser with the command sudo apt install rclone-browser.

You should now see the rclone-browser entry in your desktop menu. Start it up, and you should see a Google Drive tab (Figure A).

Figure A

Figure A

The rclone-browser tool in action.


Click on the Google Drive tab to see a list of all your Drive files/folders. From this interface you can upload, download, mount, and more ... making the usage of rclone considerably easier.

If you'd rather use the command line for rclone, issue the command man rclone to find out how the tool is used. The gist of the command line is:

  • To see the top level directory of your Drive, issue the command rclone lsd drive.
  • To list all of the files of your Drive, issue the command rclone ls drive.
  • To copy a local file to Drive, issue the command rclone copy /path/to/local/file drive:/path/to/remote/folder.

However, if you're working from a desktop, I highly recommend sticking with rclone-browser.

Also see

About Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.

Editor's Picks

Free Newsletters, In your Inbox