Table of Contents

  1. What is Rclone?
  2. How to install Rclone?
  3. How to configure Rclone with Google Drive?
  4. How to use Rclone with Google Drive?
  5. Common problems

# What is Rclone?

Rclone is a versatile command-line program for efficient file management on cloud storage. With support for over 70 cloud storage products (like Google Drive), it offers a feature-rich alternative to web storage interfaces provided by cloud vendors. From S3 object stores to business and consumer file storage services, as well as standard transfer protocols, Rclone has got you covered.

# How to install Rclone?

The easiest way to install rclone is with your favorite package manager. This guide uses version v1.63.1.

MacOS install

$ brew install rclone

Linux install

Ubuntu, Debian, Linux Mint, Pop OS

$ sudo apt install rclone

Arch Linux, Manjaro LInux, and EndevourOS

$ sudo pacman -S rclone

Precompiled binaries (Works on all distros)

$ curl -O https://downloads.rclone.org/rclone-current-linux-amd64.zip
$ unzip rclone-current-linux-amd64.zip
$ cd rclone-*-linux-amd64
$ sudo cp rclone /usr/bin/
$ sudo chown root:root /usr/bin/rclone
$ sudo chmod 755 /usr/bin/rclone

Installer script (Works on all distros)

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

Windows install

You can use Winget package manager which comes preinstalled with the latest version of Windows.

winget install Rclone.Rclone

# How to configure Rclone with Google Drive?

To configure Rclone run rclone config

$ rclone config
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q>

type n for a new remote.

Enter name for new remote.
name>

type name for the new remote, for example gdrive

In the next step, you'll get a long list of all storage types supported by rclone, find Google Drive in the list and type the number in the prompt. 

...
48 / Yandex Disk
   \ (yandex)
49 / Zoho
   \ (zoho)
50 / premiumize.me
   \ (premiumizeme)
51 / seafile
   \ (seafile)
Storage>
This value is required and it has no default.
Storage> ?? <-- enter value here

In the next step, you need to enter client_id and client_secret.

Option client_id.
Google Application Client Id
Setting your own is recommended.
See https://rclone.org/drive/#making-your-own-client-id for how to create your own.
If you leave this blank, it will use an internal key which is low performance.
Enter a value. Press Enter to leave empty.
client_id>

Here you have two options.

Use shared credentials or use your own. Using your own credentials is the preferred method, but it requires more time to configure.

Option 1 - Use shared credentials (Quick setup)

You can leave these fields empty and use the credentials provided by Rclone, which are shared between all Rclone users. However, there is a global rate limit on the number of queries per second that each client_id can do. This is a hard limit set by Google. If you go with this option, just leave both client_id and client_secret empty.

Option 2 - Use your own credentials (Recommended)

Using your own credentials is the preferred method because the shared credentials (Option 1) are heavily used and may result in poor performance. Note that Google limit is 10 transactions per second even for your own credentials, if you exceed that limit, Rclone will become slower and will be forced to wait for available quota.

Tip: If you have more than one service that uses Google Drive, it is recommended to create a separate client_id and client_secret pair.

We've created a short video tutorial on how to create Google Drive credentials.

You can also check the official guide on the Rclone docs page.

In the next step, you need to choose access scope, Full Access, Write & Read, Read Only, and so on. Depending on your needs choose what's appropriate. In this guide, we'll choose option 1 - Full Access.

Option scope.
Scope that rclone should use when requesting access from drive.
Choose a number from below, or type in your own value.
Press Enter to leave empty.
 1 / Full access all files, excluding Application Data Folder.
   \ (drive)
 2 / Read-only access to file metadata and file contents.
   \ (drive.readonly)
   / Access to files created by rclone only.
 3 | These are visible in the drive website.
   | File authorization is revoked when the user deauthorizes the app.
   \ (drive.file)
   / Allows read and write access to the Application Data folder.
 4 | This is not visible in the drive website.
   \ (drive.appfolder)
   / Allows read-only access to file metadata but
 5 | does not allow any access to read or download file content.
   \ (drive.metadata.readonly)
scope> 

In the next step, the program requires Service Account Credentials JSON file path. you can leave that empty and just type enter.

Option service_account_file.
Service Account Credentials JSON file path.
Leave blank normally.
Needed only if you want use SA instead of interactive login.
Leading `~` will be expanded in the file name as will environment variables such as `${RCLONE_CONFIG_DIR}`.
Enter a value. Press Enter to leave empty.
service_account_file>

In the next step for advanced config just type enter as well.

Option service_account_file.
Service Account Credentials JSON file path.
Leave blank normally.
Needed only if you want use SA instead of interactive login.
Leading `~` will be expanded in the file name as will environment variables such as `${RCLONE_CONFIG_DIR}`.
Enter a value. Press Enter to leave empty.
service_account_file>

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

In the next step, you need to authenticate Rclone with your Google Drive account. This happens in the browser

Use web browser to automatically authenticate rclone with remote?
 * Say Y if the machine running rclone has a web browser you can use
 * Say N if running rclone on a (remote) machine without web browser access
If not sure try Y. If Y failed, try N.

y) Yes (default)
n) No

Here you have two options - Option 1 for local install and Option 2 for remote install.

Option 1 (y) - Choose this option if you are installing Rclone locally.

Rclone opens up a browser window for Google Drive authentication right away.

Options 2 (n) - Choose this option if you're installing remotely

You'll get a command to execute on a machine with a web browser and Rclone installed, preferably the same version of Rclone.

Option config_token.
For this to work, you will need rclone available on a machine that has
a web browser available.
For more help and alternate methods see: https://rclone.org/remote_setup/
Execute the following on the machine with the web browser (same rclone
version recommended):
        rclone authorize "drive" "YOUR_TOKEN"
Then paste the result.
Enter a value.
config_token> 

Paste the rclone authorize "drive" "YOUR_TOKEN" command on your local machine, and replace the YOUR_TOKEN with the actual token from the program. This will open up a browser and the authentication process will start.

rclone authorize "drive" "XXXXXX"
2023/08/14 13:22:35 NOTICE: Make sure your Redirect URL is set to "http://127.0.0.1:53682/" in your custom config.
2023/08/14 13:22:35 NOTICE: If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=XXXXX
2023/08/14 13:22:35 NOTICE: Log in and authorize rclone for access
2023/08/14 13:22:35 NOTICE: Waiting for code...
2023/08/14 13:23:09 NOTICE: Got code
Paste the following into your remote machine --->
XXXXXXXXX
<---End paste

Either you go with Option 1 or Option 2 you'll need to go through the process of granting access to your Google Drive. This happens in the browser. Option 1 (local install) automatically fetches the code after authorization whereas in Option 2 you'll need to manually paste that into the remote machine prompt.

If you created your own credentials you'll see a warning message that your app is not validated. This is okay. You need to click Show Advanced and then Go to {project name}.

google verification warning

After that, you'll see a permission prompt asking you if you trust and allow {your app} to access read, manage, and edit files on your Google Drive. Click Continue and this step is complete.

google drive authorise account

If you went with Option 1 this is the last step of the authorization process and you should see Success in your browser

success page

and Got code message in the console.

2023/08/14 10:07:11 NOTICE: Make sure your Redirect URL is set to "http://127.0.0.1:53682/" in your custom config.
2023/08/14 10:07:11 NOTICE: If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=XXXXXXX
2023/08/14 10:07:11 NOTICE: Log in and authorize rclone for access
2023/08/14 10:07:11 NOTICE: Waiting for code...
2023/08/14 10:07:21 NOTICE: Got code

If you went with Option 2, you'll need to enter the authorization code you got locally in Rclone prompt on the remote machine.

In the next step, you'll be asked if you want to configure it as Shared Drive (Team Drive). If this is your personal account, choose n (No).

2023/08/11 14:29:42 NOTICE: Make sure your Redirect URL is set to "http://127.0.0.1:53682/" in your custom config.
2023/08/11 14:29:42 NOTICE: If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=5MirMODBRIT7dGqZCPmHiQ
2023/08/11 14:29:42 NOTICE: Log in and authorize rclone for access
2023/08/11 14:29:42 NOTICE: Waiting for code...
2023/08/11 14:31:54 NOTICE: Got code
Configure this as a Shared Drive (Team Drive)?

y) Yes
n) No (default)

In the next and final step, you'll be asked to verify your config. Just type Enter and you'll be all set!

Configuration complete.
Options:
- type: drive
- client_id: XXXXXX.apps.googleusercontent.com
- client_secret: XXXXX
- scope: drive
- token: {"access_token":"XXXXXX","token_type":"Bearer","refresh_token":"XXXXX","expiry":"2023-08-11T15:31:53.624971+03:00"}
- team_drive:
Keep this "gdrive" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote

Google Drive remote is now added! Rclone will now ask you for your next step and you need to type q to exit.

Current remotes:

Name                 Type
====                 ====
gdrive               drive

e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q>

Verify that it's working

Assuming your remote is named gdrive you can execute the following command to verify your remote is working correctly.

rclone ls gdrive:

This should list your files in the root directory of Google Drive. If this is indeed what you see that means you have successfully configured rclone with Google Drive. Good job!

If you see an error, try to start over and carefully follow the steps once again.

# How to use Rclone with Google Drive?

How to list files and directories?

List objects with size and path

rclone ls gdrive:

List buckets/directories/containers 

rclone lsd gdrive:

List objects in path with modification time, size, and path

rclone lsl gdrive:

How to copy files from and to Google Drive?

Copy a single file to Google Drive

rclone copy myfile.txt gdrive: --progress

Copy a directory to Google Drive

rclone copyto my_dir gdrive:my_dir

Copy a single file from Google Drive to local

rclone copy gdrive:myfile.txt myfile.txt --progress

Copy a directory from Google Drive to local

rclone copyto gdrive:my_dir my_dir

How to sync a directory to Google Drive?

Rclone sync command makes source and destination identical, modifying the destination only. It does not transfer identical files, meaning if you already have the file/directory on the destination, the file will be skipped. Only the destination is updated to match the source.

Sync from local to remote

rclone sync my_dir gdrive:my_dir --progress

Sync from remote to local (just reverse the arguments)

Warning: Destination is updated to match source including deleting files if necessary. Use sync with caution!

rclone sync gdrive:my_dir my_dir --progress

How to mount Google Drive directory locally?

Rclone mount allows MacOS, Linux, Windows, and FreeBSD to mount any Google Drive directory as a local folder with FUSE.

Mount Google Drive on Linux/MacOS/FreeBSD

/path/to/local/my_dir should be an empty directory.

rclone mount gdrive:my_dir /path/to/local/my_dir

Now you can access my_dir on your local filesystem, you can copy, move, and delete files like it's a normal directory.

mount can be run in two modes, foreground and background mode. In foreground mode, the mount is active until you stop the process with Ctrl + C. In background mode --daemon flag the program spawns another process that runs in the background to keep the mount active.

Note: To get mount working on MacOS you need to install it from source or from the precompiled binary, the brew package doesn't support mount.

To terminate mount in background mode run:

# Linux
fusermount -u /path/to/local/my_dir
# MacOS
umount /path/to/local/my_dir

Mount Google Drive on Windows?

To run rclone mount on Windows you need to download and install WinFsp. WinFsp provides FUSE emulation layer on Windows and rclone uses FUSE.

Windows unlike the other operating system provides two types of mounting options. You can mount it as fixed or network drive. Fixed drives are preferably physical drives where network drives are network-attached storage like in our case Google Drive.

Rclone uses fixed mount as default, but if you experience issues you can mount as a network-attached storage by using the --network-mode option.

Mounting as a fixed disk drive

When you are mounting as a fixed disk drive you can either mount to an unused disk drive X: for example or to a path representing a nonexistent directory of an existing parent directory.

rclone mount gdrive:my_dir X:
rclone mount gdrive:my_dir C:\path\parent\my_dir

C:\path\parent should exist whereas C:\path\parent\my_dir should not exist.

Mounting as a network drive

To mount as a network drive on Windows you can use the --network-mode option.

rclone mount gdrive:my_dir X: --network-mode

How to mount Google Drive on Linux on startup?

The recommended way to mount Google Drive on startup under Linux is to use systemd .

Create empty directory mkdir /mnt/google-drive

Create /etc/systemd/system/rclone.service file with the following contents. 

[Unit]
Description=Google Drive (rclone)
AssertPathIsDirectory=/mnt/google-drive

[Service]
Type=simple
ExecStart=/usr/bin/rclone mount \
        --config=/root/.config/rclone/rclone.conf \
        --allow-other \
        --checkers=8 \
        --bwlimit=5M \
        --cache-tmp-upload-path=/tmp/rclone/upload \
        --cache-chunk-path=/tmp/rclone/chunks \
        --cache-workers=4 \
        --cache-writes \
        --cache-dir=/tmp/rclone/vfs \
        --cache-db-path=/tmp/rclone/db \
        --dir-cache-time=60m \
        --cache-info-age=60m gdrive:/ /mnt/google-drive
ExecStop=/bin/fusermount -u /mnt/google-drive
Restart=always
RestartSec=10

[Install]
WantedBy=default.target

Config options explained:

--config  location of Rclone config file
--bwlimit limit download and upload speed to 5MiB/s
--cache-tmp-upload-path Directory to keep temporary files until they are uploaded
--cache-chunk-path=/tmp/rclone/chunks Directory to cache chunk files
--cache-workers=4 How many workers should run in parallel to download chunks.
--cache-writes Cache file data on writes through the FS.
--cache-dir=/tmp/rclone/vfs Directory to use for vfs caching
--cache-db-path=/tmp/rclone/db Directory to store file structure metadata DB.

Once this file is created execute the following

# Start the service
systemctl start rclone 

# Enable the service so that it starts on reboot automatically
systemctl enable rclone

Check if Rclone service is running by executing

# Check if running
systemctl status rclone 

# Common problems

Access blocked, Error 400: redirect_uri_mismatch

If you are getting Error 400, make sure you choose Desktop App when creating OAuth Client ID Credentials in the Create credentials step.