How to Use rclone to Back Up to Google Drive on Linux

The Google Drive logo on a color background of the terminal.Google

There is still no official Linux client for Google Drive, but you can back up to your Google Drive using the rclone utility directly from the command line. We show you how.

Where is Google Drive on Linux?

Despite promising Linux support “to come” in 2012, there is no indication that Google will ever produce a native Linux client for Google Drive. There are several unofficial third party solutions, such as InSync, overGrive and ODrive, and some file browsers allow integration with your Google Drive, such as Files in GNOME.

Third-party applications are commercial products, requiring either a firm purchase or a subscription. They work well, they don’t cost much, and in fact, overGrive has a free version, offering limited functionality for free.

But what if you want to create and run backups from the command line? Or integrate this functionality into scripts? All this is possible thanks to an amazing application called rclone. In fact, with rclone, you can backup, download and synchronize files to over forty different cloud solutions. It’s like rsync for the clouds.

Installing rclone

rclone will certainly not be installed by default on your Linux computer. Fortunately, there is an installation script that should work on all distributions. The installation process uses loop. On the computers used to search for this article, Fedora 31 and Manjaro 18.1.0 had already installed curl but curl had to be installed on Ubuntu 18.04 LTS.

On Ubuntu, run this command to install it:

sudo apt-get install curl

sudo apt-get install curl in a terminal window

Once curl is installed, install rclone with this command:

curl | sudo bash

curl | sudo bash in a terminal window

When the rclone installation is complete, a success message is displayed.

Installation script success message rclone in a terminal window

This installed the rclone program on your Linux computer. The next step is to complete the configuration process and authenticate rclone to access your Google Drive.

Create a rclone remote connection

Connections to remote cloud services are called “remote controls” in the rclone world. We need to create one for Google Drive. Start the rclone configuration process with this command:

rclone configuration

rclone configuration in a terminal window

There are many questions in the configuration process. But do not be discouraged, many of them can be left at their default values ​​and simply accepted by pressing “Enter”.

rclone tells us that no remote control is configured. Press “n” and press “Enter” to create a new remote control. He will ask you for a name. We’re going to call it “google-drive”. Use the name of your choice.

rclone menu to create a new remote control, in a terminal window

A long menu allows you to choose the type of storage to which you create a remote connection.

Remote connection type menu rclone in a terminal window

Scroll down until you see the entry for Google Drive, and note its number.

rclone configuration in a terminal window

We can see that in this case it is number 13. Enter it as the storage type and press “Enter”.

Defining the storage type rclone in a terminal window

You are asked to enter a Google Application Client ID. Press “Enter” to accept the default value.

Request a Google application client ID in a terminal window

You are then asked to provide a Google application client secret.

request a secret Google application client in a terminal window

Again, just press “Enter”. You are asked to provide the extent that rclone will have when it works on your Google Drive. Press “1” then press “Enter”.

provide rclone scope in a terminal window

For “Root Folder ID”, just press “Enter”.

prompt for the root folder ID in a terminal window

At the “Service Account Identification Information” prompt, press “Enter.”

Request service account credentials in a terminal window

At the “Change advanced configuration” prompt, just press “Enter.” In the “Use automatic configuration” menu, press “y” then “Enter”.

This forces rclone to communicate with your Google Drive and launch your browser to allow you to allow rclone to interact with your Google Drive.

rclone about to launch a browser in a terminal window

In your browser window, click the Google account you want to use.

Choose the Google account to use in a browser window

Click the “Allow” button to allow rclone to access your Google Drive.

Allow rclone to work with Google Drive in a terminal window

Once authentication is complete, a “Success!” Message Appears in the browser window. You can close the browser and return to the terminal window.

Success message in a browser window

At the “Configure this as a team disk” prompt, type “n” and then press “Enter.”

In the “Yes, modify, delete” menu, type “y” then press “Enter”.

In the final menu, type “q” and press “Enter”.

The final menu clones in a terminal window

The rclone backup script

The rclone application is very rich in functionality. It’s great, but it means there are a lot of options. The command that we will review below copies the files from your local computer to your Google Drive. It is a one-way copy to the cloud; it’s not a two-way sync between your Google Drive and your local computer, although rclone can do that. We use it as a basic form of offsite backup.

Type (or copy and paste) this into a text editor and save it to your computer. We called it You can call it whatever you want.

#! / bin / bash

/ usr / bin / rclone copy –update –verbose –transfers 30 –checkers 8 –contimeout 60s –timeout 300s –retries 3 –low-level-retries 10 –stats 1s “/ home / dave / Documents “” google-drive: LinuxDocs ”

Here’s what the parameters mean:

copy: Copy the files from the local computer to the remote storage, ignoring the files already present on the remote storage.
-update: Ignore all files on the remote storage whose modified time is more recent than the file on the local computer.
-verbose: Gives information about each file transferred.
–Transfers 30: This defines the number of files to copy in parallel.
–Checkers 8: How many “verifiers” must be run in parallel. The controllers monitor the transfers in progress.,
–Contimeout 60s: The connection delay. It defines the time at which rclone will attempt to connect to the remote storage.
– Timeout 300s: If a transfer becomes inactive during this period, it is considered as interrupted and is disconnected.
–Retries 3: If there are as many errors, all the copy action will be restarted.
–Low level attempts 10: A low-level retry attempts to repeat a failed operation, such as a single HTTP request. This value defines the limit on the number of attempts.
–Stats 1s: rclone can provide statistics on transferred files. This sets the frequency for updating statistics to one second.
“/ Home / dave / Documents”: The local directory to which we will copy the remote storage.
“Google-drive: LinuxDocs”: The destination directory in the remote storage. Note the use of “google-drive”, which is the name we gave to this remote connection during the rclone configuration sequence. Also note the two dots “:” which are used as a separator between the name of the remote storage and the name of the directory. The subdirectories are separated by the usual forward slash “/”. If the destination directory does not exist, it will be created.

Some of these values ​​are the default values, but we have included them here so that we can discuss them. That way, if you need to change a value, you know which setting to adjust.

Make the script executable with this command:

chmod + x

Running the backup script

Our backup script will copy our Documents folder to our Google Drive. In our Documents folder, we have a collection of scores.

Collection of partitions in ~ / Documents in a file browser

We can run the backup script with this command:


./ in a terminal window

We asked for statistics updates every second (–stats 1s), and we also asked for detailed output (–verbose). So it will not be surprising that we get a lot of screen output. It is usually a good option to enable detailed output for new features to detect problems. You can reduce the amount of output once you are satisfied that everything is going well.

rclone output in a terminal window

We obtain a final summary indicating that 60 files have been transferred without error. The transfer took approximately 24 seconds.

Let’s check out our Google Drive and see what happened in our cloud storage.

LinuxDocs folder in Google Drive

A “LinuxDocs” directory has been created, which looks promising. If we double click on it to take a look inside, we can see that all the files have been transferred to our Google Drive.

Using rclone to view files on Google Drive

We can use rclone to take a look at the folder on Google Drive, right from the terminal window:

rclone ls google-drive: / LinuxDocs

rclone ls google-drive: / LinuxDocs in a terminal window

The tip of the iceberg

It’s great that we can do this type of copying directly from the command line. We can integrate the use of our cloud storage into scripts, and we could schedule the execution of backup scripts using cron.

rclone has an absolute wealth of commands, you are encouraged to check out their documentation and their great website. We’ve barely scratched the surface here, and a little reading and playing with rclone will pay off the effort several times.

Strictly speaking, this is not a real backup. It’s a remote, off-site copy of your files and data, which is certainly a good thing, but it’s just a file copy. It does not offer any version or other features that real backup solutions would offer.

So use rclone in conjunction with other backup techniques. As an additional layer to an existing backup scheme, rclone is an easy way to store your data in a location that is geographically removed from your home or office. And it must be a good thing.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.