What is rclone?

Rclone is a versatile command-line program for efficient file management on cloud storage. With support for over 70 cloud storage products, it offers a feature-rich alternative to web storage interfaces provided by cloud vendors. From S3 object stores to business and consumer file storage services, as well as standard transfer protocols, Rclone has got you covered.

How to install rclone?

The easiest way to install rclone is to use your favorite package manager.

MacOS

To install rclone on MacOS you can use brew

$ brew install rclone

Linux

Rclone is included in most of the Linux distros repositories.

Ubuntu, Debian, Linux Mint, Pop OS:

$ sudo apt install rclone

Arch Linux, Manjaro Linux, and EndevourOS run:

$ sudo pacman -S rclone

Linux precompiled binaries

Download and unzip

$ curl -O https://downloads.rclone.org/rclone-current-linux-amd64.zip
$ unzip rclone-current-linux-amd64.zip
$ cd rclone-*-linux-amd64

Copy the binary to $PATH

$ sudo cp rclone /usr/bin/
$ sudo chown root:root /usr/bin/rclone
$ sudo chmod 755 /usr/bin/rclone

Installer Script

To install using the installer script for Linux/macOS/BSD systems, run:

$ sudo -v ; curl https://rclone.org/install.sh | sudo bash

How to configure rclone for Cloudlare R2?

After you've installed the rclone command line program you need to configure it, you can use the built-in configure process by running rclone config but the easiest way is to create the following config file:

~/.config/rclone/rclone.conf

with the following contents

[r2]
type = s3
provider = Cloudflare
access_key_id = <ACCESS_KEY>
secret_access_key = <SECRET_ACCESS_KEY>
endpoint = https://<ACCOUNT_ID>.r2.cloudflarestorage.com

Replace the <ACCESS_KEY>, <SECRET_ACCESS_KEY>, and <ACCOUNT_ID> with the appropriate values from your Cloudflare account.

[r2] is custom alias, you'll use it when you execute the command it can be anything you want, for example, it can be [backup_server] or [cloudflare_backup].

type is the type of file operation. Cloudflare supports the S3 API.

access_key_id and secret_access_key are your credentials generated from the R2 console. To create tokens, navigate to Cloudflare console -> R2, and in the upper right section you'll find Manage R2 API Tokens link. From there you can create new tokens, choose permissions, specify buckets, and client IP address filtering. Note that you need object read and write permissions in order to upload files to R2.

endpoint is your account id

You need more help?

You can find more information and examples on the rclone install page.

Additional resources

  1. How to copy a local folder to an R2 bucket