How to use Rclone to Back Up to Google Drive on Linux
Rclone is a command-line tool for managing and synchronizing files between different storage services, including Google Drive. Here are the steps to use Rclone to back up to Google Drive on Linux.
1 . Installing Rclone
On Ubuntu, run this command to install it:
$ sudo apt install rclone
When the Rclone installation has finished, you’ll see a success message
This has installed the Rclone program on your Linux computer. The next step is to run through the setup process and authenticate Rclone to access your Google Drive.
2. Creating an Rclone Remote Connection
Connections to remote cloud services are called “remotes” in the rclone world. We need to create one for Google Drive. Start the Rclone configuration process with this command
$ rclone config
There are a lot of questions in the configuration process. But don’t be disheartened, many of them can be left at their default values and simply accepted by pressing “Enter.”
Rclone tells us there are no remotes configured. Press “n” and press “Enter” to create a new remote. It will prompt you for a name. We’re going to call it “Google Drive.” Use whatever name you like.
A long menu allows you to choose the type of storage you’re creating a remote connection to.
Scroll through the list until you see the entry for Google Drive, and make a note of its number.
We can see that in this instance, it is number 18. Enter this as the storage type and press “Enter.”
You’re prompted for a Google Application Client ID. Press “Enter” to accept the default.
You’re then prompted for a Google Application Client Secret.
Again, just press “Enter.” You’re asked to provide the scope that Rclone will have when it is operating on your Google Drive. Press “1” and then press “Enter.”
At the “Service Account Credentials” prompt, press “Enter.”
At the “Edit advanced config” prompt, just press “n” At the “Use auto config” menu, press “y” and then press “Enter.”
This causes rclone to communicate to your Google Drive, and to launch your browser to allow you to give permission for Rclone to interact with your Google Drive.
In your browser window, click on the Google account you wish to use.
image
Click the “Allow” button to allow Rclone to have access to your Google Drive
When authenticate has completed, you’ll see a “Success!” message in the browser window. You can close the browser and return to the terminal window.
At the “Configure this as a team drive” prompt, type “n” and then press “Enter”
At the “Yes, Edit, Delete” menu type “y” and then press “Enter”
That’s it, you can now test with the directory listing command in the remote connection:
# rclone listremotes
3. Mount Google Drive Locally Using Rclone
In order to access the contents of Google Drive from your file manager, you need to mount it first.
Create a mount point to mount your Google Drive. I am going to create a new mount point named “gdrive”.
# mkdir ~/gdrive
# chmod 775 ~/gdrive
Next, mount the Google Drive using Rclone as shown below:
# rclone mount gdrive: ~/gdrive
Here, “gdrive” is the remote name and “gdrive” is the mount point name. Replace them with your values.
Click on it to access the contents of your Google Drive.
Check it out on your Google Drive and see what happened in our cloud storage.
From now on, you can create, copy, move, rename, and delete files/folders the way you do in your local file manager. Anything you put in the local mount folder (i.e. ~/gdrive folder) will be uploaded to your Google Drive.
4. Unmount Google Drive
To unmount the Google Drive, go to the Terminal window where you run the “rclone mount
” command and simply press "CTRL+c"
to stop the mount.
You can also do it from the file manager as well. From the file manager, right-click on the mount point i.e. “gdrive” and click Unmount.
The unmount operation may fail, for example when the mount point is busy. When that happens, you can stop the mount manually using the command:
# fusermount -u ~/gdrive
Conclusion
In this guide, we looked at how to mount Google Drive locally with Rclone in Linux, and two basic operations – how to copy and sync the files from the local drive to Google Drive.