Install and setup Rclone for Google Drive on Ubuntu 16.04 and Ubuntu 18.04.

share on:
install and setup Rclone in Ubuntu 16.04 and uubntu 18.04

Rclone is a command line program which we can use to securely sync files and directories to and from a number of cloud/remote storages like Amazon S3, Backblaze B2, Box, Ceph, DigitalOcean Spaces, Dropbox, FTP, Google Cloud Storage, Google Drive and lots more. For detailed list, you can check this LINK.

To setup ubuntu 16.04 with Free ssl, please follow this linkSetup HTTPS with letsencrypt on ubuntu 16.04..

Rclone has many useful features like :

  • MD5/SHA1 hashes checked at all times for file integrity
  • Timestamps preserved on files
  • Partial syncs supported on a whole file basis
  • Copy mode to just copy new/changed files
  • Sync (one way) mode to make a directory identical
  • Check mode to check for file hash equality
  • Can sync to and from network, eg two different cloud accounts
  • Optional encryption (Crypt)
  • Optional cache (Cache)
  • Optional FUSE mount (rclone mount)

Installation:

You can install rclone either by running the script povided by rclone or by latest stable rclone package as snap package in ubuntu 16.04/18.04.

[[email protected] user]# curl https://rclone.org/install.sh | sudo bash

 

Install rclone as Snap package in ubuntu 16.04 or Ubuntu 18.04.

[[email protected] user]# snap install rclone --classic

 

Configure Rclone for Google Drive on ubuntu 16.04 or 18.04 server.

Start by tying rclone config in your terminal or putty.

[[email protected] user]# rclone config
2018/07/28 19:35:28 NOTICE: Config file "/root/.config/rclone/rclone.conf" not found - using defaults
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> GDrive
Type of storage to configure.
Choose a number from below, or type in your own value
1 / Alias for a existing remote
\ "alias"
2 / Amazon Drive
\ "amazon cloud drive"
3 / Amazon S3 Compliant Storage Providers (AWS, Ceph, Dreamhost, IBM COS, Minio)
\ "s3"
4 / Backblaze B2
\ "b2"
5 / Box
\ "box"
6 / Cache a remote
\ "cache"
7 / Dropbox
\ "dropbox"
8 / Encrypt/Decrypt a remote
\ "crypt"
9 / FTP Connection
\ "ftp"
10 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
11 / Google Drive
\ "drive"
12 / Hubic
\ "hubic"
13 / Local Disk
\ "local"
14 / Mega
\ "mega"
15 / Microsoft Azure Blob Storage
\ "azureblob"
16 / Microsoft OneDrive
\ "onedrive"
17 / OpenDrive
\ "opendrive"
18 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
19 / Pcloud
\ "pcloud"
20 / QingCloud Object Storage
\ "qingstor"
21 / SSH/SFTP Connection
\ "sftp"
22 / Webdav
\ "webdav"
23 / Yandex Disk
\ "yandex"
24 / http Connection
\ "http"
Storage> 11
Google Application Client Id - leave blank normally.
client_id> 
Google Application Client Secret - leave blank normally.
client_secret> 
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"
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> 3
ID of the root folder - leave blank normally. Fill in to access "Computers" folders. (see docs).
root_folder_id> 3Hty4Fkfvb3294xxxxxxxxxxxxxxxxxxf
Service Account Credentials JSON file path - leave blank normally.
Needed only if you want use SA instead of interactive login.
service_account_file> 
Remote config
Use auto config?
* Say Y if not sure
* Say N if you are working on a remote or headless machine or Y didn't work
y) Yes
n) No
y/n> n
If your browser doesn't open automatically go to the following link: https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=324342xxx434.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.file&state=7xxxxxxxxxxx72e9f9s9erdso87dsf0
Log in and authorize rclone for access
Enter verification code> 2/DDfGEG40kj34m43t342ixxxxxxxxxxxxxxxxxxxdfl94-Gp349k459d
Configure this as a team drive?
y) Yes
n) No
y/n> n
--------------------
GDrive]
type = drive
client_id = 
client_secret = 
scope = drive.file
root_folder_id = 3Hty4Fkfvb3294xxxxxxxxxxxxxxxxxxf
service_account_file = 
token = {"access_token":"u432.GJ8945jlk32429hdxxxxxxxxxxxxxxxxxxxxx05hs9723jolsdkfvb32940_495dlkgT_jxxxxxxxxxxxxxxxxxx3259lkdfl94-Gp349k459duris9732jne8203f","token_type":"Bearer","refresh_token":"6/olsdkfvb3294xxxxxxxxxxxxxxxxxxfsdnGere9323k","expiry":"2018-07-28T20:36:36.654343489Z"}
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y
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> q

 

Test the working of Rclone.

Create a new folder in your Google Drive with name test.

Now view with rclone the list of folders available on your remote (GDrive).

[[email protected] user]# rclone lsd GDrive:
-1 2018-07-28 19:42:52 -1 test

 

Uploaad files on Google Drive:

[[email protected] user]# rclone copy -v testfile.zip GDrive:

 

Check the file status on GDrive.

[[email protected] user]# rclone lsd GDrive:
-1 2018-07-28 19:42:52 -1 test
[[email protected] user]# rclone ls GDrive:
3190541 testfile.zip
0 test-file-to-google-drive

 

Note:

View list of folders on remote with : rclone lsd [remote]
View list of folders and files on remote with : rclone ls [remote]

Delete files with Rclone:

[[email protected] user]# rclone ls GDrive:
3190541 testfile.zip
0 test-file-to-google-drive

[[email protected] ~]# rclone deletefile -v GDrive:test-file-to-google-drive
[[email protected] ~]# rclone ls GDrive:
3190541 testfile.zip

 

NOTE: Remember the name of the remote in rclone is the one you chose in the very first step.
In this example, it is GDrive.

 

Now you have setup Rclone on your ubuntu 16.04 or 18.04 server. You can follow the same guide for setup on CentOS 7 server also. Thanks for visiting this page. Please share this post with your friends on social media! Stay tuned for more Linux tutorials. Have a Great Day. 🙂

share on:
engy

engy

Hello there, My name is Rishi Guleria and I work as a Linux system administrator. I have created this blog to share what I have learned so far and to learn new things. Good Day. :)

Leave a Response

share on: