Skip to content
Claude Pageau edited this page May 1, 2018 · 52 revisions

rclone4pi - Setup and Configure rclone on a Raspberry Pi computer

Introduction

Rclone is a command line program to sync files and directories to and from many remote storage services. This utility can be used to update and manage folders/files between your raspberry pi computer and remote cloud storage service(s). For more information about Rclone See https://rclone.org and GitHub Repo https://github.com/ncw/rclone

Quick Install

Step 1 Highlight curl command in code box below using mouse left button. Right click mouse in highlighted area and Copy.
Step 2 On RPI putty SSH or terminal session right click, select paste then Enter to download and run script.

curl -L https://raw.github.com/pageauc/rclone4pi/master/rclone-install.sh | bash

Command above will install rclone-install.sh, rclone-sync.sh and create a subfolder rpi-sync in users home eg. /home/pi

Manual Install

From a logged in putty SSH or RPI Terminal session execute commands below

cd ~
wget -O rclone-install.sh https://raw.github.com/pageauc/rclone4pi/master/rclone-install.sh  
more rclone-install.sh  # Review what script does if required 
chmod +x rclone-install.sh
./rclone-install.sh    # Run Install Script.  You may review script first.

Upgrade

To upgrade/repair existing installation specify any parameter eg.

cd ~/rpi-sync
./rclone-install.sh upgrade 

How to Configure a Remote Storage Service

To configure one rclone remote storage service on a raspbery pi computer follow the steps below. If a service is already installed you will see an interactive configuration menu that allows you to change/remove existing service(s) or add a new one.

Example Steps for Google Drive

  • Open putty SSH login session to Raspberry Pi and execute command below, then follow rclone config interactive prompts. You will be required to have a login account on the remote storage service.

    rclone config
    
  • Select new, At name> prompt, Enter your choice of service name eg gdmedia

  • At Storage> prompt enter number for google drive

  • Follow prompts and accept defaults where appropriate.

  • At Use auto config? select n

  • rclone will display a long url at link: prompt.

  • On RPI SSH session, click and hold left mouse button and highlight https url after link: (do not press enter key)

  • On computer web browser that is logged into service, right click, paste and go on browser url bar.

  • On computer web browser service security web page, Select user account if appropriate. On service security web page confirm access.

  • On confirmation page a Long verification code will be displayed. Use mouse left button to highlight code then right click to copy verification code.

  • On RPI SSH session at prompt Enter verification code> right click, paste verification code then Enter to accept

  • At team drive? prompt Select n if the drive is not part of a team

  • Review and accept settings when prompted.

For more Setup Details see

For a Full list Select Storage Systems pull down menu at top of rclone.org Home Page.

How to Test rclone

To test connection to remote service. Execute the following command where gdmedia: is the name you gave your remote storage service. After a short delay this will list the files and folders in the root of your remote drive. Note Remote Paths are specified as remote:path where remote: is name you gave remote storage service.

list All files on remote storage service

rclone ls gdmedia:

list directories

rclone lsd gdmedia:

To get command help, type rclone with no parameters or rclone --help

Example sync From RPI Folder rpi-sync To remote service name gdmedia: and rpi-sync folder. This will make local source folder identical to remote destination. *WARNING It will delete files on remote that do not exist locally and update/change remote files to be the same as local version.

rclone sync -v /home/pi/rpi-sync gdmedia:/rpi-sync

How to Automate rclone

To avoid multiple instances of rclone running, a small batch file called rclone-sync.sh will only allow one instance to run. Run commands below to edit the rclone-sync.sh script variables.

cd ~/rpi-sync
nano rclone-sync.sh

Edit variables for source, destination, remote storage name as required ctrl-x y to save and exit nano editor

Run the test script per commands below. After a short delay you should see sync progress. Default script will sync contents of the rpi-sync folder into the remote service into a syncdemo folder.

cd ~/rpi-sync
./rclone-sync.sh

You should copy the rpi-sync.sh script to another name and modify for your own purposes.

The best way to automate rclone is to add a crontab entry to run rclone-sync.sh at regular intervals. See example below

sudo crontab -e

Add entry to the crontab similar to below. Make sure to include the quotes around command. To save crontab entry. I you are using nano editor press ctrl-x y to save crontab changes and exit.

*/5 * * * * su pi -c "/home/pi/rclone-sync.sh" > /dev/null 2>&1

This will run rclone-sync.sh as pi user every five minutes and make the remote folder identical to the source folder. You can change the frequency to what every you like. Just make sure you leave enough time to upload files.

How to Remove RClone

To delete rclone config files. List the current RClone configuration path with the following command

rclone config file

This will list the path for the current configuration file. You can then just delete the path location per example below. This will remove credentials to your remote storage services.
IMPORTANT After deletion you will no longer have access to your remote storage services and will need to recreate them again.

sudo rm /home/pi/.config/rclone/rclone.conf

To remove rclone command and man pages just delete the files per the following commands

sudo rm /usr/bin/rclone
sudo rm /usr/local/share/man/man1/rclone.1
Clone this wiki locally
You can’t perform that action at this time.