Rclone

4 minute read

Published:

Rclone is a software for managing files on cloud storage (Google Drive, Dropbox, OneDrive, etc.) and can be used to connect local storage to these services for backups, restorations, and so on. The service comes with functionality similar to unix commands (e.g., cp, mv, ls), some of which is described below.

Setup

Installation

Rclone is provided as a binary file, able to be installed on Windows, Linux, macOS, and others. Rclone archives can be downloaded from the Official Rclone Downloads page. Once the relevant version is downloaded, extract the zip archive into a desired location.

Windows

Once the archive is downloaded, use an archive manager to extract the files and place them in a desired location.

Linux and macOS

On Unix operating systems, there are a few ways to retrieve the Rclone archive. These

From archive

Download the appropriate binary from the Official Rclone Downloads page and extract the executable with an archive manager. Now, in a terminal, orient to the extracted Rclone directory. For my installation, this looked like

~/Downloads/rclone-v1.59.1-linux-amd64/

With curl or brew

Use the following commands to install Rclone with curl (Linux and macOS) or brew (macOS).

curl: sudo -v ; curl https://rclone.org/install.sh | sudo bash

brew: brew install rclone

From a precompiled binary

Follow the instructions on the Official Rclone Downloads page to install Rclone from a precompiled binary.

Configuration

Following installation, in a terminal (Command Prompt, PowerShell, etc.), orient the path to the Rclone directory. For my installations, this looked like

Windows: C:\Users\Dan\Downloads\rclone-v1.59.1-windows-amd64\

Ubuntu: ~/Downloads/rclone-v1.59.1-linux-amd64/

To configure Rclone, run the config command as follows

Windows: rclone.exe config

Ubuntu: rclone config

Follow the configuration settings for your cloud storage service in the [Rclone documentation]https://rclone.org/docs/).

Google Drive

I had a need to configure Rclone to connect a Linux system to Google Drive. To do so, I ran rclone config and followed the instructions in the Rclone Google Drive documentation, leaving most configuration with default values.

I setup a new remote

No remotes found, make a new one?
n) New remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
n/r/c/s/q> n

and named it “remote”

name> remote

I declared it will be a Google Drive remote,

Storage> drive

The following prompts were left blank

Google Application Client Id - leave blank normally.
client_id> [Enter]

Google Application Client Secret - leave blank normally.
client_secret> [Enter]

I wanted Rclone to have full access to my Drive repository, so I set the scope to full access

Scope that rclone should use when requesting access from drive.
Choose a number from below, or type in your own value
 1 / Full access all files, excluding Application Data Folder.
   \ "drive"
scope> 1

Left root_folder_id and service_account_file as default

root_folder_id> [Enter]

service_account_file> [Enter]

I do not edit the advanced config, so I select “n” when prompted.

Edit advanced config?
y) Yes
n) No (default)
y/n> n

Here, the instructions will diverge depending on whether the computer being accessed is local or remote. You will be prompted to choose to use the auto config or go without.

Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine
y) Yes (default)
n) No
y/n> 

If local (i.e., able to be interfaced with by a keyboard and monitor), choose to use the auto config (select “y”) and a window will open prompting you to select the Google Drive account to be accessed and approve the application. After approval, return to the terminal to continue configuration.

If performing this setup on a remote computer, select “n” and follow the Rclone Remote Setup instructions. The setup prompt will ask you to run rclone authorize "drive" "<passcode>" on a computer where Rclone is installed and you have the ability to open a browser. This command will open a browser window and prompt you to connect your Google Drive and approve the application. Upon completion, the terminal running rclone authorize will return a long string that should be input to the original setup.

Following connecting the Google account, return to the terminal running config.

This was not a shared Drive, so I did not configure it as such

Configure this as a Shared Drive (Team Drive)?
y) Yes
n) No
y/n> n

I reviewed my configuration and approved it. It looked something like the following (copied from the documentation)

--------------------
[remote]
client_id = 
client_secret = 
scope = drive
root_folder_id = 
service_account_file =
token = {"access_token":"XXX","token_type":"Bearer","refresh_token":"XXX","expiry":"2014-03-16T13:57:58.955387075Z"}
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y

and configuration was completed!

Copying files from local machine to Drive

Copy a directory or file from a local computer to the remote Drive with

rclone copy /path/to/local/file/or/dir remote:path/to/Drive/dir