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. This post will show you how to Setup Rclone For Google Drive On Ubuntu 18.04 or older versions. You can follow the same steps for CentOS 7 or Debian.
To setup ubuntu 16.04 with Free ssl, please follow this link: Setup 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.
[root@debyum user]# curl https://rclone.org/install.sh | sudo bash
Install rclone as Snap package in ubuntu 16.04 or Ubuntu 18.04.
[root@debyum 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.
[root@debyum 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 / 1Fichier \ "fichier" 2 / Alias for an existing remote \ "alias" 3 / Amazon Drive \ "amazon cloud drive" 4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc) \ "s3" 5 / Backblaze B2 \ "b2" 6 / Box \ "box" 7 / Cache a remote \ "cache" 8 / Dropbox \ "dropbox" 9 / Encrypt/Decrypt a remote \ "crypt" 10 / FTP Connection \ "ftp" 11 / Google Cloud Storage (this is not Google Drive) \ "google cloud storage" 12 / Google Drive \ "drive" 13 / Google Photos \ "google photos" 14 / Hubic \ "hubic" 15 / JottaCloud \ "jottacloud" 16 / Koofr \ "koofr" 17 / Local Disk \ "local" 18 / Mega \ "mega" 19 / Microsoft Azure Blob Storage \ "azureblob" 20 / Microsoft OneDrive \ "onedrive" 21 / OpenDrive \ "opendrive" 22 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH) \ "swift" 23 / Pcloud \ "pcloud" 24 / Put.io \ "putio" 25 / QingCloud Object Storage \ "qingstor" 26 / SSH/SFTP Connection \ "sftp" 27 / Union merges the contents of several remotes \ "union" 28 / Webdav \ "webdav" 29 / Yandex Disk \ "yandex" 30 / http Connection \ "http" 31 / premiumize.me \ "premiumizeme" Storage> 12 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).
[root@debyum user]# rclone lsd GDrive: -1 2018-07-28 19:42:52 -1 test
Upload files on Google Drive:
[root@debyum user]# rclone copy -v testfile.zip GDrive:
Check the file status on GDrive.
[root@debyum user]# rclone lsd GDrive: -1 2018-07-28 19:42:52 -1 test [root@debyum 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:
[root@debyum user]# rclone ls GDrive: 3190541 testfile.zip 0 test-file-to-google-drive [root@debyum ~]# rclone deletefile -v GDrive:test-file-to-google-drive [root@debyum ~]# 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.