Skip to main content
Last updated on

Rclone

Rclone is an open-source, cross-platform command-line tool (Windows/macOS/Linux) that supports over 70 cloud storage services, including any S3-compatible storage. Rclone excels at synchronization, backup, mounting buckets as local drives, and transferring data between cloud providers.

Installing Rclone

Linux / macOS

curl https://rclone.org/install.sh | sudo bash

Or use a package manager:

# macOS (Homebrew)
brew install rclone

# Ubuntu / Debian
sudo apt install rclone

# CentOS / RHEL
sudo yum install rclone

Windows

Download the .exe file from https://rclone.org/downloads/, extract it, and add it to your PATH, or run it directly from the extracted folder.

Verify the installation:

rclone version

Configuring the LANIT Cloud Connection

There are two ways to configure Rclone: using the interactive command or editing the configuration file directly.

First, get your Access Key ID and Secret Access Key from the LANIT Cloud Portal (see Access Key):

Access Key management page on LANIT Cloud Portal

Method 1: Interactive configuration

rclone config

Follow these steps:

  1. Enter n to create a new remote.
  2. Name: enter a name, e.g. lanit
  3. Storage: enter s3 (or the number corresponding to Amazon S3)
  4. Provider: select Other (or enter the corresponding number)
  5. env_auth: false
  6. access_key_id: enter your Access Key ID from the LANIT Cloud Portal
  7. secret_access_key: enter your Secret Access Key
  8. region: leave blank or enter hn
  9. endpoint: enter s3.lanit.com.vn
  10. location_constraint: leave blank
  11. acl: leave blank or enter private
  12. Confirm and save.

Method 2: Editing the configuration file directly

Open the Rclone configuration file (usually at ~/.config/rclone/rclone.conf on Linux/macOS, or %APPDATA%\rclone\rclone.conf on Windows):

[lanit]
type = s3
provider = Other
access_key_id = YOUR_ACCESS_KEY_ID
secret_access_key = YOUR_SECRET_ACCESS_KEY
endpoint = s3.lanit.com.vn
region = hn
acl = private

Replace YOUR_ACCESS_KEY_ID and YOUR_SECRET_ACCESS_KEY with your actual credentials.

Test the connection:

rclone lsd lanit:

This command lists all buckets in your account. On success, you see the bucket list.

Common Commands

Listing Buckets and Objects

# List all buckets
rclone lsd lanit:

# List objects in a bucket
rclone ls lanit:bucket-name

# List in tree format
rclone tree lanit:bucket-name

# List objects in a specific folder
rclone ls lanit:bucket-name/images/

Copying Files

# Upload a file to a bucket
rclone copy /path/to/local/file.zip lanit:bucket-name/backup/

# Download a file to your machine
rclone copy lanit:bucket-name/backup/file.zip /path/to/local/

# Upload an entire directory
rclone copy /path/to/local/folder/ lanit:bucket-name/folder/

# Show progress
rclone copy --progress /local/folder/ lanit:bucket-name/

Synchronization (Sync)

The sync command deletes files at the destination that no longer exist at the source. Always check with --dry-run first.

# Preview (dry run) — makes no actual changes
rclone sync --dry-run /local/backup/ lanit:bucket-name/backup/

# Sync local → bucket
rclone sync /local/backup/ lanit:bucket-name/backup/

# Sync bucket → local
rclone sync lanit:bucket-name/backup/ /local/backup/

# Sync between two buckets/remotes
rclone sync lanit:source-bucket/ lanit:destination-bucket/

Migrating Data Between Clouds

# Transfer from AWS S3 to LANIT Cloud
rclone sync aws:aws-bucket/ lanit:lanit-bucket/ --progress

# Transfer from Google Drive to LANIT Cloud
rclone sync gdrive:folder/ lanit:bucket-name/ --progress

Deleting Objects

# Delete a single file
rclone deletefile lanit:bucket-name/file.txt

# Delete all contents of a folder (keeping the folder)
rclone delete lanit:bucket-name/old-backups/

# Clean up a bucket (remove leftover parts from failed multipart uploads)
rclone cleanup lanit:bucket-name

Mounting a Bucket as a Drive

On Linux/macOS (requires fuse to be installed):

# Create a mount point
mkdir -p /mnt/lanit-storage

# Mount the bucket
rclone mount lanit:bucket-name /mnt/lanit-storage --daemon

# Unmount
fusermount -u /mnt/lanit-storage # Linux
umount /mnt/lanit-storage # macOS

After mounting, you can interact with the bucket like a regular drive through your file manager or terminal.

Increasing Transfer Speed

# Increase the number of parallel transfers
rclone copy --transfers 16 /local/folder/ lanit:bucket-name/

# Split large files into multiple parts (multipart)
rclone copy --s3-upload-concurrency 8 large-file.iso lanit:bucket-name/

# Limit bandwidth (to avoid saturating your connection)
rclone copy --bwlimit 50M /local/ lanit:bucket-name/

Automation with Cron (Linux/macOS)

Example: back up every day at 2:00 AM:

crontab -e

Add the following line:

0 2 * * * /usr/bin/rclone sync /data/important/ lanit:my-bucket/backup/ --log-file=/var/log/rclone-backup.log

Troubleshooting

Error AccessDenied:

  • Verify that your Access Key ID and Secret Access Key are correct.
  • Check whether the Bucket Policy permits the action you are attempting.

Error NoSuchBucket:

  • Verify the bucket name is correct (names are case-sensitive).
  • Make sure the endpoint is correct: s3.lanit.com.vn

Error SignatureDoesNotMatch:

  • Check your server clock — a time difference of more than 5 minutes causes signature errors.
  • Run sudo ntpdate pool.ntp.org to synchronize the time.