How to synchronize a MinIO bucket with a Cloudflare R2 bucket using Rclone
Posted on May 27, 2024 - by Andy Cinquin
MinIOCloudflare R2RcloneSynchronizationObject storageAmazon S3 APIBackupsData migration
Introduction
In this tutorial, we'll learn how to synchronize a MinIO bucket with a Cloudflare R2 bucket using the Rclone command-line tool. MinIO is an open source object storage server compatible with the Amazon S3 API, while Cloudflare R2 is an object storage service offered by Cloudflare, also compatible with the S3 API. By synchronizing buckets between these two services, you can create backups, migrate data or maintain synchronized copies of your files across multiple clouds.
Installing Rclone
Before you can synchronize your MinIO and Cloudflare R2 buckets, you need to install Rclone on your local machine. Here's how to do it:
On Linux :
- Open a terminal.
- Run the following command to automatically download and install the latest version of Rclone:
curl https://rclone.org/install.sh | sudo bash
On macOS (using Homebrew):
- Open a terminal.
- If you don't have Homebrew installed, install it first by running :
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Install Rclone with Homebrew:
brew install rclone
On Windows:
- Visit the Rclone download page: https: //rclone.org/downloads/.
- Download the installation file for Windows (for example,
rclone-current-windows-amd64.msi
). - Double-click on the downloaded file and follow the installation wizard instructions.
After installation, you can check that Rclone is correctly installed by running the following command in your terminal:
rclone --version
This will display the version of Rclone installed on your system.
Prerequisites
- A MinIO server with a bucket created. See the MinIO documentation to find out how to configure a server and create buckets: https: //docs.min.io/.
- A Cloudflare account with R2 enabled and a bucket created. Follow Cloudflare's guide to enable R2 and create buckets: https: //developers.cloudflare.com/r2/.
- Rclone installed on your local machine.
Step 1: Configure remote MinIO
- Run
rclone config
to open the interactive Rclone configuration menu. - Choose
n
to create a new remote. - Give your remote a name, e.g. "minio-andy".
- Choose "s3" as storage type.
- Leave the
provider
field blank. - Enter the URL of your MinIO server, your
access_key_id
and yoursecret_access_key
. This information can be obtained from your MinIO administration interface. Make sure you keep these credentials secure. - Leave the other options as default, or adjust them as required.
- Choose
y
to confirm remote creation.
Step 2: Configure the Cloudflare R2 remote
- Run
rclone config
again. - Choose
n
to create a new remote. - Give your remote a name, e.g. "r2-andy".
- Choose "s3" as storage type.
- Choose "Cloudflare" as provider.
- Enter your R2
access_key_id
, your R2secret_access_key
and the URL of your R2 bucket. This information can be obtained from your Cloudflare R2 account. Make sure you keep these credentials secure. - Leave the other options as default, or adjust them as required.
- Choose
y
to confirm remote creation.
Step 3: Synchronize buckets
- To synchronize your MinIO bucket with your R2 bucket, run the following command:
rclone sync "minio-andy:name-of-bucket-source" "r2-andy:name-of-bucket-destination"
Replace
name-du-bucket-source
with the name of your source MinIO bucket and name-du-bucket-destination
with the name of your destination R2 bucket.- Rclone will start synchronizing files from your MinIO bucket to your R2 bucket. It will display progress and a summary at the end.
Step 4: Verify synchronization
- To check that synchronization has been successful, you can list the contents of your R2 bucket:
rclone ls "r2-andy:bucket-name-destination"
Replace
name-of-bucket-destination
with the name of your destination R2 bucket.- You should see the files that have been synchronized from your MinIO bucket.
Explanation
Rclone is a powerful tool for managing files on different cloud storage services. In this tutorial, we used Rclone to synchronize a MinIO bucket with a Cloudflare R2 bucket.
By configuring Rclone remotes for MinIO and R2, we can use the
rclone sync
command to easily synchronize files between the two buckets. Rclone compares source and destination files and transfers only those files that have been modified, making it effective for keeping multiple buckets in sync.There are many advantages to using Rclone, including
- Ease of use: Rclone offers a simple, intuitive command-line interface for managing your files on different cloud storage services.
- Efficiency: Rclone optimizes file transfers by transferring only modified files, saving time and bandwidth.
- Compatibility: Rclone supports a wide range of cloud storage services, enabling you to synchronize your files between different providers.
Conclusion
In this tutorial, we've learned how to synchronize MinIO and Cloudflare R2 buckets using Rclone. By following the remotes configuration steps and using the
rclone sync
command, you can easily keep your files synchronized between these two object storage services.Thank you for your visit, feel free to contact me for
any information, quote or collaboration proposal. I will
be happy to answer you as soon as possible.
Did you like this article? Feel free to share it!