LinuxPublished on January 19, 202623 min read

Rclone: expert guide for cloud synchronization on Linux VPS

Rclone is a command-line tool for your files in the cloud. On Linux, it copies, syncs and encrypts data between a server and more than 70 storage services. This guide installs rclone on a Linux VPS running Ubuntu or Debian. It then covers remotes, everyday commands, FUSE mounts, encryption, automation, monitoring and troubleshooting.

What is rclone?

Rclone is free, open-source software, often described as "rsync for cloud storage". It works with Google Drive, Amazon S3, Cloudflare R2, Backblaze B2, SFTP, WebDAV and many other services. Each configured storage account is called a remote.

Rclone is built in layers. Its core handles the basic operations. The VFS layer handles mounts and caching. The crypt layer encrypts data on the client side. The chunker layer splits large files. A common layer gives the same access to every provider.

Rclone needs few resources. It runs with 512 MB of RAM, 1 vCPU and 100 MB of disk. For a mount with a cache, plan for 2 GB of RAM, 2 vCPUs and room for the cache on disk. Mounting uses FUSE 3, available on Debian 12 and 13 as well as Ubuntu 22.04 and 24.04. Run the commands in this guide from an account with sudo rights.


Install rclone

With the official script

This is the recommended method. The script downloads the latest stable version and installs it.

# Install the latest stable version with the official script
curl -fsSL https://rclone.org/install.sh | sudo bash

# Check the installation
rclone version

The Debian and Ubuntu repositories also have an rclone package. According to the rclone install page, it is often several versions behind.

Manually, from the archive

This method gives you control over every file. The rclone-current address always points to the latest stable version. To pin a version, get its archive from downloads.rclone.org.

# Required tools
sudo apt update && sudo apt install -y curl unzip

# Architecture: amd64, or arm64 on an ARM processor
ARCH="amd64"

# Download and extract the latest stable version
cd /tmp
curl -LO "https://downloads.rclone.org/rclone-current-linux-${ARCH}.zip"
unzip rclone-current-linux-${ARCH}.zip
cd rclone-*-linux-${ARCH}

# Install the binary
sudo cp rclone /usr/local/bin/
sudo chmod 755 /usr/local/bin/rclone

# Install the man page
sudo mkdir -p /usr/local/share/man/man1
sudo cp rclone.1 /usr/local/share/man/man1/
sudo mandb

# Bash completion
rclone completion bash | sudo tee /etc/bash_completion.d/rclone > /dev/null

# Zsh completion
rclone completion zsh | sudo tee /usr/local/share/zsh/site-functions/_rclone > /dev/null

From source

You need git and Go 1.26 or newer. The Go package in the Debian repositories is too old to build rclone. Install Go from go.dev, then check its version.

# git, then Go 1.26 or newer installed from go.dev
sudo apt update && sudo apt install -y git
go version

# Clone and build
git clone https://github.com/rclone/rclone.git
cd rclone
go build -ldflags "-s -w" -o rclone

# Install
sudo mv rclone /usr/local/bin/

Prepare FUSE for mounting

To mount a remote as a folder, install the fuse3 package. The user_allow_other line in /etc/fuse.conf allows the --allow-other option for accounts other than root.

sudo apt update
sudo apt install -y fuse3

# Allow --allow-other for non-root accounts
sudo sed -i 's/#user_allow_other/user_allow_other/' /etc/fuse.conf

Configure your remotes

The configuration lives in ~/.config/rclone/rclone.conf. It is an INI file with one section per remote. The example below sets up Google Drive, Amazon S3, Cloudflare R2, Backblaze B2 and an SFTP server.

# ~/.config/rclone/rclone.conf

[gdrive]
type = drive
client_id = YOUR_CLIENT_ID.apps.googleusercontent.com
client_secret = YOUR_CLIENT_SECRET
scope = drive
token = {"access_token":"...","token_type":"Bearer","refresh_token":"...","expiry":"..."}
team_drive =

[s3-aws]
type = s3
provider = AWS
access_key_id = AKIAIOSFODNN7EXAMPLE
secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
region = eu-west-1
acl = private
storage_class = STANDARD_IA

[s3-r2]
type = s3
provider = Cloudflare
access_key_id = YOUR_R2_ACCESS_KEY
secret_access_key = YOUR_R2_SECRET_KEY
endpoint = https://YOUR_ACCOUNT_ID.r2.cloudflarestorage.com
acl = private

[b2]
type = b2
account = YOUR_APPLICATION_KEY_ID
key = YOUR_APPLICATION_KEY
hard_delete = true

[sftp-backup]
type = sftp
host = backup.example.com
user = backupuser
port = 22
key_file = ~/.ssh/backup_key
shell_type = unix
md5sum_command = md5sum
sha1sum_command = sha1sum

This file holds your access keys in plain text. Keep it readable by you only, or encrypt it as shown further down.

With the wizard

The rclone config command opens a wizard. It creates, renames, copies or deletes remotes for you, and can set a password on the configuration.

# Start the wizard
rclone config

# Main menu choices
# n) New remote
# d) Delete remote
# r) Rename remote
# c) Copy remote
# s) Set configuration password
# q) Quit config

Google Drive on a headless VPS

Google asks for authorisation in a web browser, and the VPS has none. Install rclone on your computer too, to get the token there.

  1. On your computer, run rclone authorize "drive". A Google page opens. Allow access.

  2. Copy the token shown in the terminal.

  3. On the VPS, run rclone config and answer as in the block below. When asked about browser authentication, answer n, then paste the token.

# On your computer, which has a browser
rclone authorize "drive"

# Then on the VPS, with the copied token
rclone config

# n) New remote
# name> gdrive
# Storage> drive
# client_id> (empty, or your own ID)
# client_secret> (empty, or your own)
# scope> drive
# service_account_file> (empty)
# Edit advanced config> n
# Use web browser to automatically authenticate> n
# config_token> paste the token from your computer

With a Google Workspace service account

A service account replaces the personal token. First, store its JSON file in a dedicated folder.

# Folder for the service account file
mkdir -p ~/.config/rclone/sa

# Put the service account JSON file there
# ~/.config/rclone/sa/service-account.json

Then declare the remote in rclone.conf, with the path to the file and the shared drive ID.

[gdrive-sa]
type = drive
scope = drive
service_account_file = /home/user/.config/rclone/sa/service-account.json
team_drive = 0ABCdefGHIjklMNOpqr

With S3-compatible storage (MinIO, Wasabi)

Any S3-compatible storage is declared with type = s3. Only the provider, the keys and the service address change.

[minio]
type = s3
provider = Minio
access_key_id = minioadmin
secret_access_key = minioadmin
endpoint = http://localhost:9000
acl = private

[wasabi]
type = s3
provider = Wasabi
access_key_id = YOUR_WASABI_KEY
secret_access_key = YOUR_WASABI_SECRET
region = eu-central-1
endpoint = s3.eu-central-1.wasabisys.com

Use the basic commands

Every command follows the same pattern. A remote is written as its name followed by a colon, for example gdrive:.

rclone [options] subcommand <source> [<destination>] [flags]

List and browse

ls already walks through every subfolder. The --recursive option is only for lsjson and lsf.

# List the configured remotes
rclone listremotes

# List a remote's content
rclone ls gdrive:
rclone ls gdrive:Documents/

# Detailed list, with size and date
rclone lsl gdrive:

# JSON list, for scripts
rclone lsjson gdrive: --recursive

# Directories only
rclone lsd gdrive:

# Tree, three levels deep
rclone tree gdrive:Projects/ --level 3

# Find files
rclone ls gdrive: --include "*.pdf"

Copy and move

copy never deletes anything at the destination. move deletes the source once the copy is done. Between two remotes, rclone copies server-side when the provider allows it.

# From the VPS to a remote
rclone copy /local/path gdrive:backup/ -P

# From a remote to the VPS
rclone copy gdrive:Documents/ /local/documents/ -P

# Between two remotes (server-side when possible)
rclone copy gdrive:source/ s3-aws:destination/ -P

# Move: copy, then delete the source
rclone move /local/temp/ gdrive:archive/ -P

# Copy a single file
rclone copyto /local/file.txt gdrive:backup/file.txt

Sync

rclone sync makes the destination identical to the source. Files missing from the source are deleted at the destination. Always test first with --dry-run.

# Dry run first
rclone sync /local/data/ gdrive:data/ --dry-run

# One-way sync (source to destination)
rclone sync /local/data/ gdrive:data/ -P

# Two-way sync, first run
rclone bisync /local/data/ gdrive:data/ --resync

# Later runs, without --resync
rclone bisync /local/data/ gdrive:data/

bisync syncs in both directions. The rclone documentation lists it as an advanced command, to be used with care. The --resync option is for the first run, after a settings change, or to recover from an error. Leave it out on later runs, or deleted files will come back.

Delete

# Delete a file
rclone deletefile gdrive:path/to/file.txt

# Delete a directory and its content
rclone purge gdrive:old-backup/

# Delete the files, keep the directories
rclone delete gdrive:temp/

# Remove empty directories
rclone rmdirs gdrive: --leave-root

Common options

OptionEffect
-P, --progressShows progress
-v, --verboseGives more detail
-n, --dry-runSimulates without changing anything
--transfers NNumber of parallel transfers
--checkers NNumber of parallel checks
--bwlimit RATELimits bandwidth
--exclude PATTERNExcludes files
--include PATTERNOnly takes these files
--min-size SIZEMinimum size
--max-size SIZEMaximum size
--min-age DURATIONMinimum age
--max-age DURATIONMaximum age

Filter and control transfers

Write a filter file

A filter file groups include rules (+) and exclude rules (-). Rclone applies the first rule that matches. The last line, - *, excludes everything not included above.

sudo mkdir -p /etc/rclone && sudo chown "$USER" /etc/rclone

cat > /etc/rclone/filters.txt << 'EOF'
# Includes
+ **.pdf
+ **.docx
+ Documents/**

# Excludes
- *.tmp
- *.log
- .git/**
- node_modules/**
- __pycache__/**
- .DS_Store
- Thumbs.db

# Exclude everything else
- *
EOF

# Use the filter file
rclone sync /data/ gdrive:backup/ --filter-from /etc/rclone/filters.txt -P

Copy server-side

A server-side copy avoids routing the data through the VPS. Between two remotes of the same provider but with different configurations, add --server-side-across-configs. backend features shows what the remote can do.

# Server-side copy between two configs of the same provider
rclone copy gdrive:source/ gdrive-sa:destination/ --server-side-across-configs

# Features supported by the remote
rclone backend features gdrive:

# Remove duplicates (Google Drive)
rclone dedupe gdrive:folder/ --dedupe-mode newest

Upload large files and check integrity

On S3, a large file is uploaded in chunks. You set their size and how many go up in parallel. rclone check then compares the source and the destination.

# Multipart upload of a large file to S3
rclone copy largefile.tar s3-aws:backup/ \
  --s3-chunk-size 100M \
  --s3-upload-concurrency 4

# Check integrity
rclone check /local/data/ gdrive:data/ --one-way
rclone hashsum MD5 gdrive:file.zip

Handle metadata and storage class

By default, rclone keeps each file's modification time. The --metadata option (or -M) also copies other metadata, such as the owner and permissions of a local file. settier changes the storage class on services that have one, such as S3, Azure Blob or Google Cloud Storage.

# Also copy metadata (owner, permissions, attributes)
rclone copy /local/ gdrive:backup/ --metadata

# Show metadata
rclone lsjson gdrive:file.txt --metadata

# Change the storage class (S3, Azure Blob, Google Cloud Storage)
rclone settier STANDARD_IA s3-aws:bucket/archive/

Mount cloud storage with FUSE

A mount makes a remote appear as a folder on the VPS. Your software reads and writes there as if it were on the disk.

Mount a remote

The --daemon option runs the mount in the background. Without it, the mount stays in the foreground in the terminal.

# Create the mount point
sudo mkdir -p /mnt/gdrive
sudo chown $USER:$USER /mnt/gdrive

# Simple mount
rclone mount gdrive: /mnt/gdrive --daemon

# Mount with advanced options
rclone mount gdrive: /mnt/gdrive \
  --daemon \
  --allow-other \
  --vfs-cache-mode full \
  --vfs-cache-max-size 10G \
  --vfs-cache-max-age 24h \
  --vfs-read-chunk-size 64M \
  --vfs-read-chunk-size-limit 1G \
  --buffer-size 256M \
  --dir-cache-time 72h \
  --poll-interval 15s \
  --log-file /var/log/rclone/gdrive.log \
  --log-level INFO

Choose the VFS cache mode

ModeBehaviourUse
offReads and writes go straight to the remote, with no disk cache. This is the default.Streaming
minimalLike off, but a file opened for both reading and writing goes through the disk.Simple uploads
writesRead-only files are read from the remote. Written files go through the disk first.Editing files
fullAll reads and writes go through the disk cache.Heavy use, applications

Tune the cache

The cache can live in a dedicated folder, with a maximum size and age. --vfs-write-back sets the delay before a modified file is sent to the remote.

rclone mount gdrive: /mnt/gdrive \
  --vfs-cache-mode full \
  --cache-dir /var/cache/rclone \
  --vfs-cache-max-size 50G \
  --vfs-cache-max-age 168h \
  --vfs-write-back 5s \
  --vfs-read-ahead 128M \
  --attr-timeout 1h \
  --daemon

Make the mount permanent with systemd

A systemd service mounts the remote again each time the VPS starts. It runs under a system account named rclone, with no login shell. Rclone tells systemd when the mount is ready, hence Type=notify.

  1. Create the service file.

  2. Create the rclone account and its folders, then copy your configuration for it.

  3. Enable and start the service, then check its status.

# 1. Create the service file
sudo tee /etc/systemd/system/rclone-gdrive.service << 'EOF'
[Unit]
Description=Rclone Mount - Google Drive
Documentation=https://rclone.org/docs/
After=network-online.target
Wants=network-online.target

[Service]
Type=notify
User=rclone
Group=rclone
ExecStartPre=/bin/mkdir -p /mnt/gdrive
ExecStart=/usr/local/bin/rclone mount gdrive: /mnt/gdrive \
  --config /home/rclone/.config/rclone/rclone.conf \
  --allow-other \
  --vfs-cache-mode full \
  --vfs-cache-max-size 20G \
  --vfs-cache-max-age 72h \
  --vfs-read-chunk-size 32M \
  --vfs-read-chunk-size-limit 256M \
  --buffer-size 128M \
  --dir-cache-time 48h \
  --poll-interval 30s \
  --log-level INFO \
  --log-file /var/log/rclone/gdrive.log \
  --cache-dir /var/cache/rclone/gdrive
ExecStop=/bin/fusermount3 -uz /mnt/gdrive
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target
EOF

# 2. Create the dedicated account, its folders and its config
sudo useradd -r -s /usr/sbin/nologin rclone
sudo mkdir -p /var/log/rclone /var/cache/rclone
sudo chown rclone:rclone /var/log/rclone /var/cache/rclone
sudo mkdir -p /mnt/gdrive /home/rclone/.config/rclone
sudo cp ~/.config/rclone/rclone.conf /home/rclone/.config/rclone/
sudo chown -R rclone:rclone /mnt/gdrive /home/rclone
sudo chmod 600 /home/rclone/.config/rclone/rclone.conf

# 3. Enable and start the service
sudo systemctl daemon-reload
sudo systemctl enable rclone-gdrive.service
sudo systemctl start rclone-gdrive.service

# Check the status
sudo systemctl status rclone-gdrive.service

Unmount

With FUSE 3, the unmount command is fusermount3. The old FUSE 2 package provides fusermount. Unmounting fails while a program is still using the folder.

# Clean unmount (FUSE 3)
fusermount3 -u /mnt/gdrive

# Forced unmount, if the folder is busy
fusermount3 -uz /mnt/gdrive

# With the old fuse package (FUSE 2)
fusermount -u /mnt/gdrive
fusermount -uz /mnt/gdrive

# Through systemd
sudo systemctl stop rclone-gdrive.service

Encrypt your data and configuration

Create an encrypted remote

The crypt remote encrypts files on the VPS before they are sent. It sits on top of an existing remote, here a Google Drive folder.

rclone config

# n) New remote
# name> gdrive-crypt
# Storage> crypt
# remote> gdrive:encrypted/
# filename_encryption> standard
# directory_name_encryption> true
# password> (generated or chosen)
# password2> (salt, optional but recommended)

Rclone then adds this section to rclone.conf. The passwords are stored obscured.

[gdrive-crypt]
type = crypt
remote = gdrive:encrypted/
password = ENCRYPTED_PASSWORD_HASH
password2 = ENCRYPTED_SALT_HASH
filename_encryption = standard
directory_name_encryption = true

Write both passwords down somewhere safe. Without them, your encrypted files are lost.

Encrypt file names too

ModeEffectExample
offNames stay readabledocument.pdf
standardNames are encryptedq4kp2q8fj3m2...
obfuscateNames are only scrambledyqkpzqFfj3m2...

Use the encrypted remote

You work with gdrive-crypt: like any other remote. On the storage side, only unreadable names show up.

# Commands work as usual
rclone copy /sensitive/data/ gdrive-crypt: -P

# On the storage, names are unreadable
rclone ls gdrive:encrypted/

# Through the crypt remote, the original names show again
rclone ls gdrive-crypt:

Protect the configuration file

rclone config encryption set encrypts the whole rclone.conf file with a password. Rclone then asks for it on every command, or reads it from the RCLONE_CONFIG_PASS variable.

# Encrypt the config file
rclone config encryption set

# Pass the password in an environment variable
export RCLONE_CONFIG_PASS="YOUR_STRONG_PASSWORD"

# Or read it from a secret file
export RCLONE_CONFIG_PASS=$(cat /run/secrets/rclone_pass)

Configure with environment variables

A remote can also be defined without a file, with RCLONE_CONFIG_<NAME>_<OPTION> variables. This is handy in a container or a service.

# Google Drive without a config file
export RCLONE_CONFIG_GDRIVE_TYPE=drive
export RCLONE_CONFIG_GDRIVE_TOKEN='{"access_token":"..."}'

# S3
export RCLONE_CONFIG_S3_TYPE=s3
export RCLONE_CONFIG_S3_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
export RCLONE_CONFIG_S3_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG

Automate your backups

Rclone sends a copy of your files to another provider. That copy complements the automatic VPS backup option, which is paid and added from the client area. The guide How to set up automatic VPS backups describes this option.

The backup script

This script sends /data to the encrypted remote, into a dated folder. It blocks a second run at the same time, keeps a log and deletes copies older than 30 days. It can also notify a Discord or Slack webhook. Save it as /usr/local/bin/rclone-backup.sh, then make it executable with chmod +x.

#!/usr/bin/env bash
#
# rclone-backup.sh
# Usage: ./rclone-backup.sh [daily|weekly|monthly]
#

set -euo pipefail
IFS=$'\n\t'

# Configuration
readonly SCRIPT_NAME=$(basename "$0")
readonly LOG_DIR="/var/log/rclone"
readonly LOG_FILE="${LOG_DIR}/backup-$(date +%Y%m%d-%H%M%S).log"
readonly LOCK_FILE="/run/lock/rclone-backup.lock"
readonly CONFIG_FILE="${HOME}/.config/rclone/rclone.conf"

# Settings
readonly LOCAL_SOURCE="/data"
readonly REMOTE_DEST="gdrive-crypt:backups"
readonly RETENTION_DAYS=30
readonly BANDWIDTH_LIMIT="50M"
readonly MAX_TRANSFERS=4

# Colours
readonly RED='\033[0;31m'
readonly GREEN='\033[0;32m'
readonly YELLOW='\033[1;33m'
readonly NC='\033[0m'

# Functions
log() {
    local level="$1"
    shift
    local message="$*"
    local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
    echo -e "${timestamp} [${level}] ${message}" | tee -a "${LOG_FILE}"
}

cleanup() {
    rm -f "${LOCK_FILE}"
    log "INFO" "Cleanup done, lock released"
}

check_dependencies() {
    local deps=("rclone" "flock")
    for dep in "${deps[@]}"; do
        if ! command -v "$dep" &> /dev/null; then
            log "ERROR" "Missing dependency: $dep"
            exit 1
        fi
    done
}

acquire_lock() {
    exec 200>"${LOCK_FILE}"
    if ! flock -n 200; then
        log "ERROR" "Another instance is already running"
        exit 1
    fi
}

perform_backup() {
    local backup_type="${1:-daily}"
    local timestamp=$(date +%Y%m%d-%H%M%S)
    local dest_path="${REMOTE_DEST}/${backup_type}/${timestamp}"
    local exit_code=0

    log "INFO" "Starting ${backup_type} backup to ${dest_path}"

    # "|| exit_code=$?" keeps the error code despite set -e
    rclone sync "${LOCAL_SOURCE}" "${dest_path}" \
        --config "${CONFIG_FILE}" \
        --transfers "${MAX_TRANSFERS}" \
        --checkers 8 \
        --bwlimit "${BANDWIDTH_LIMIT}" \
        --log-file "${LOG_FILE}" \
        --log-level INFO \
        --stats 1m \
        --stats-log-level NOTICE \
        --exclude-from /etc/rclone/exclude.txt \
        --backup-dir "${REMOTE_DEST}/.versions/${timestamp}" \
        --suffix ".bak" \
        --fast-list \
        --retries 3 \
        --retries-sleep 10s \
        --ignore-errors || exit_code=$?

    if [ $exit_code -eq 0 ]; then
        log "INFO" "${GREEN}${backup_type} backup completed${NC}"
    else
        log "ERROR" "${RED}${backup_type} backup failed (code: ${exit_code})${NC}"
    fi

    return $exit_code
}

cleanup_old_backups() {
    log "INFO" "Deleting backups older than ${RETENTION_DAYS} days"

    rclone delete "${REMOTE_DEST}" \
        --config "${CONFIG_FILE}" \
        --min-age "${RETENTION_DAYS}d" \
        --rmdirs \
        --log-file "${LOG_FILE}" \
        --log-level INFO

    log "INFO" "Cleanup finished"
}

send_notification() {
    local status="$1"
    local message="$2"

    # Discord or Slack webhook, if WEBHOOK_URL is set
    if [ -n "${WEBHOOK_URL:-}" ]; then
        curl -s -X POST "${WEBHOOK_URL}" \
            -H "Content-Type: application/json" \
            -d "{\"content\": \"[Rclone Backup] ${status}: ${message}\"}"
    fi
}

main() {
    local backup_type="${1:-daily}"

    # Initialisation
    mkdir -p "${LOG_DIR}"
    trap cleanup EXIT

    log "INFO" "=== Starting ${SCRIPT_NAME} (${backup_type}) ==="

    check_dependencies
    acquire_lock

    # Run
    if perform_backup "${backup_type}"; then
        cleanup_old_backups
        send_notification "SUCCESS" "${backup_type} backup completed"
    else
        send_notification "FAILURE" "${backup_type} backup failed"
        exit 1
    fi

    log "INFO" "=== End of ${SCRIPT_NAME} ==="
}

main "$@"

Each run creates a full dated copy. The /etc/rclone/exclude.txt file must exist, even if empty. To receive alerts, set the WEBHOOK_URL variable.

Schedule with cron

# Open the crontab
crontab -e

# Every day at 2:00
0 2 * * * /usr/local/bin/rclone-backup.sh daily >> /var/log/rclone/cron.log 2>&1

# On Sundays at 3:00
0 3 * * 0 /usr/local/bin/rclone-backup.sh weekly >> /var/log/rclone/cron.log 2>&1

# On the 1st of the month at 4:00
0 4 1 * * /usr/local/bin/rclone-backup.sh monthly >> /var/log/rclone/cron.log 2>&1

# Empty the remote's trash every day at 5:00
0 5 * * * /usr/local/bin/rclone cleanup gdrive: --config /home/user/.config/rclone/rclone.conf

Schedule with a systemd timer

A systemd timer can replace cron. Persistent=true catches up on a run missed while the VPS was off. RandomizedDelaySec shifts the start at random, by 5 minutes at most.

# Service
sudo tee /etc/systemd/system/rclone-backup.service << 'EOF'
[Unit]
Description=Rclone Backup Service
After=network-online.target

[Service]
Type=oneshot
User=rclone
ExecStart=/usr/local/bin/rclone-backup.sh daily
StandardOutput=journal
StandardError=journal
EOF

# Timer
sudo tee /etc/systemd/system/rclone-backup.timer << 'EOF'
[Unit]
Description=Run Rclone Backup Daily

[Timer]
OnCalendar=*-*-* 02:00:00
RandomizedDelaySec=300
Persistent=true

[Install]
WantedBy=timers.target
EOF

# Enable
sudo systemctl daemon-reload
sudo systemctl enable --now rclone-backup.timer

# Check
systemctl list-timers | grep rclone

Improve performance

Run transfers in parallel

--transfers sets how many files are sent at once, and --checkers how many checks run at once. --tpslimit caps the request rate to stay under the provider's quotas.

rclone sync /source/ remote:dest/ \
  --transfers 16 \
  --checkers 32 \
  --buffer-size 512M \
  --drive-chunk-size 256M \
  --fast-list \
  --tpslimit 10 \
  --tpslimit-burst 20 \
  -P

Tune each provider

Google Drive, S3 and Backblaze B2 each have their own chunking options.

# Google Drive
rclone copy /data/ gdrive:backup/ \
  --drive-chunk-size 256M \
  --drive-upload-cutoff 256M \
  --drive-acknowledge-abuse \
  --drive-keep-revision-forever=false \
  --fast-list \
  -P

# Amazon S3
rclone copy /data/ s3:bucket/path/ \
  --s3-chunk-size 100M \
  --s3-upload-cutoff 200M \
  --s3-upload-concurrency 8 \
  --s3-copy-cutoff 4G \
  --fast-list \
  -P

# Backblaze B2
rclone copy /data/ b2:bucket/path/ \
  --b2-chunk-size 96M \
  --b2-upload-cutoff 200M \
  --b2-hard-delete \
  --fast-list \
  -P

Measure throughput

rclone test makefile creates a test file. rclone test speed measures throughput to a remote. It creates its files in a temporary folder and removes it at the end.

# Create a 1 GB test file
rclone test makefile 1G /tmp/rclone_test_file

# Memory used to list a remote
rclone test memory remote:path/

# Measure throughput to the remote
rclone test speed remote:path/ -q

# Time a transfer
time rclone copy /tmp/rclone_test_file remote:test/ -P --stats 1s

Limit bandwidth

--bwlimit accepts a fixed value, one value for each direction (upload, then download) or a timetable.

# Fixed limit
--bwlimit 10M

# Limit by time of day
--bwlimit "08:00,512K 18:00,10M 23:00,off"

# Upload at 10M, download at 5M
--bwlimit "10M:5M"

Monitor rclone

Set up logging

# Log levels, from most to least verbose
--log-level DEBUG
--log-level INFO
--log-level NOTICE
--log-level ERROR

# Write to a file
--log-file /var/log/rclone/operation.log

# JSON format, for log tools
--use-json-log

Show statistics

rclone sync /source/ remote:dest/ \
  --stats 30s \
  --stats-file-name-length 0 \
  --stats-log-level NOTICE \
  --stats-one-line \
  -P

Publish metrics for Prometheus

The rclone remote control server publishes metrics in Prometheus format with --rc-enable-metrics. Keep the 127.0.0.1 address so they are not exposed to the Internet. The --metrics-addr option also publishes metrics, without the remote control server.

# Enable metrics, on the local address only
rclone serve restic remote:path/ \
  --rc \
  --rc-addr 127.0.0.1:5572 \
  --rc-enable-metrics

# Prometheus endpoint
curl http://localhost:5572/metrics

Check the remote and the mount

This script checks that the remote responds and that the mount point is active. Run it from cron to keep a record in /var/log/rclone/health.log.

#!/usr/bin/env bash
# rclone-health-check.sh

REMOTE="gdrive:"
LOG_FILE="/var/log/rclone/health.log"

check_remote() {
    if rclone lsd "${REMOTE}" --max-depth 1 &> /dev/null; then
        echo "$(date '+%Y-%m-%d %H:%M:%S') [OK] ${REMOTE} reachable" >> "${LOG_FILE}"
        return 0
    else
        echo "$(date '+%Y-%m-%d %H:%M:%S') [FAIL] ${REMOTE} unreachable" >> "${LOG_FILE}"
        return 1
    fi
}

check_mount() {
    local mount_point="/mnt/gdrive"
    if mountpoint -q "${mount_point}"; then
        echo "$(date '+%Y-%m-%d %H:%M:%S') [OK] ${mount_point} mounted" >> "${LOG_FILE}"
        return 0
    else
        echo "$(date '+%Y-%m-%d %H:%M:%S') [FAIL] ${mount_point} not mounted" >> "${LOG_FILE}"
        return 1
    fi
}

check_remote
check_mount

Rotate the logs

sudo tee /etc/logrotate.d/rclone << 'EOF'
/var/log/rclone/*.log {
    daily
    missingok
    rotate 14
    compress
    delaycompress
    notifempty
    create 0640 rclone rclone
    sharedscripts
    postrotate
        systemctl reload rclone-gdrive.service > /dev/null 2>&1 || true
    endscript
}
EOF

Fix common errors

Google Drive 403 error

Google limits the number of requests per account. Reduce parallelism, slow down the requests or create your own client ID.

# Message
ERROR : Failed to copy: googleapi: Error 403: User Rate Limit Exceeded

# 1. Reduce parallelism
--transfers 2 --checkers 4

# 2. Slow down requests
--tpslimit 2 --tpslimit-burst 0

# 3. Use your own client ID: client_id and client_secret in rclone config

Expired token

# Renew the token
rclone config reconnect gdrive:

# Or manually, on a computer with a browser
rclone authorize drive

Mount refused (Permission denied)

# Check /etc/fuse.conf
grep user_allow_other /etc/fuse.conf

# If the line is commented out, enable it
sudo sed -i 's/#user_allow_other/user_allow_other/' /etc/fuse.conf

# Mount with --allow-other
rclone mount remote: /mnt/point --allow-other

Files missing after a sync

# Always a dry run first
rclone sync source: dest: --dry-run

# Check what the filters keep
rclone ls source: --include "*.ext" -v

# Compare source and destination
rclone check source: dest: --one-way --combined report.txt

Debug in detail

--dump headers and --dump bodies log the request headers and content, tokens included. Do not share that log as it is.

# Full debug mode
rclone copy source: dest: -vv --dump headers --dump bodies

# Test the connection
rclone lsd remote: --timeout 30s

# Show a remote's configuration
rclone config show remote

# Remote features
rclone backend features remote:

# Measure throughput
rclone test speed remote: -q

Resume an interrupted transfer

Run the same command again. Rclone only sends files that are missing or changed. --retries and --low-level-retries add more attempts. --error-on-no-transfer makes rclone exit with code 9 when nothing was transferred, which a script can test.

# Run again with more retries
rclone copy source: dest: \
  --retries 10 \
  --retries-sleep 30s \
  --low-level-retries 20 \
  --ignore-errors

# Exit code 9 if nothing was transferred, log kept in transfer.log
rclone copy source: dest: \
  --error-on-no-transfer \
  2>&1 | tee transfer.log

# Review the errors of the last run
grep "ERROR" transfer.log

Production examples

Back up a web server

This script dumps the MySQL or MariaDB databases, archives /var/www and the configuration, then sends everything to Backblaze B2. It keeps 7 days locally and 30 days on B2.

#!/usr/bin/env bash
# backup-webserver.sh

# Variables
MYSQL_USER="backup"
MYSQL_PASS="secret"
BACKUP_DIR="/var/backups/web"
REMOTE="b2:webserver-backups"
DATE=$(date +%Y%m%d)

# Today's backup folder
mkdir -p "${BACKUP_DIR}/${DATE}"

# 1. MySQL or MariaDB databases
mysqldump -u${MYSQL_USER} -p${MYSQL_PASS} --all-databases \
    | gzip > "${BACKUP_DIR}/${DATE}/mysql-all.sql.gz"

# 2. Website files
tar -czf "${BACKUP_DIR}/${DATE}/www.tar.gz" -C /var/www .

# 3. Configuration
tar -czf "${BACKUP_DIR}/${DATE}/etc.tar.gz" \
    /etc/nginx /etc/php /etc/mysql /etc/letsencrypt

# 4. Upload to the cloud
rclone copy "${BACKUP_DIR}/${DATE}" "${REMOTE}/${DATE}/" \
    --transfers 4 \
    --b2-hard-delete \
    -P

# 5. Local cleanup: keep 7 days
find "${BACKUP_DIR}" -mindepth 1 -maxdepth 1 -type d -mtime +7 -exec rm -rf {} +

# 6. Remote cleanup: keep 30 days
rclone delete "${REMOTE}" --min-age 30d --rmdirs

To keep the database password out of the script, put it in a ~/.my.cnf file that only you can read.

Replicate to several providers

Each source is copied into its own folder in every destination. Without that separate folder, the second sync would erase the first.

#!/usr/bin/env bash
# multi-cloud-sync.sh

SOURCES=("gdrive:important" "s3:bucket/important")
DESTINATIONS=("b2:redundancy" "wasabi:redundancy")

for src in "${SOURCES[@]}"; do
    # One folder per source in each destination
    name="${src//[:\/]/_}"
    for dst in "${DESTINATIONS[@]}"; do
        echo "Syncing ${src} -> ${dst}/${name}"
        rclone sync "${src}" "${dst}/${name}" \
            --transfers 8 \
            --fast-list \
            --checksum \
            -P
    done
done

Feed a media server (Plex, Jellyfin)

The mount takes the UID and GID of the plex account. A large disk cache keeps playback smooth.

# Plex / Jellyfin
rclone mount gdrive:Media /mnt/media \
    --daemon \
    --allow-other \
    --uid $(id -u plex) \
    --gid $(id -g plex) \
    --umask 002 \
    --vfs-cache-mode full \
    --vfs-cache-max-size 100G \
    --vfs-cache-max-age 168h \
    --vfs-read-chunk-size 128M \
    --vfs-read-chunk-size-limit 1G \
    --buffer-size 512M \
    --dir-cache-time 168h \
    --poll-interval 1m \
    --log-file /var/log/rclone/media.log \
    --log-level NOTICE \
    --cache-dir /var/cache/rclone/media

Keep older versions

--backup-dir moves files that the sync replaces or deletes into a dated folder. With --suffix-keep-extension, file.txt becomes file.bak.txt there.

# Sync and keep replaced versions
rclone sync /data/ remote:current/ \
    --backup-dir remote:versions/$(date +%Y%m%d) \
    --suffix .bak \
    --suffix-keep-extension \
    -P

# Restore a version
rclone copyto remote:versions/20260115/file.bak.txt /restore/file.txt

Handy commands

# Space used
rclone size remote:path/

# Empty the remote's trash and temporary files
rclone cleanup remote:

# Web interface, on the local address with credentials
rclone rcd --rc-web-gui --rc-addr 127.0.0.1:5572 --rc-user admin --rc-pass 'YOUR_PASSWORD'

# From your computer, SSH tunnel to the interface
ssh -L 5572:127.0.0.1:5572 user@VPS_IP

# Export the configuration without secrets
rclone config dump | jq 'del(..|.token?, .password?, .secret_access_key?)'

The web interface only listens on the VPS. To open it from your computer, start the SSH tunnel, then go to http://localhost:5572. The rclone documentation covers every command and option. The official forum helps with special cases, and the code is on GitHub.


Need help?

Open a ticket from Tickets › Open a Ticket, or from the Contact support tile at the bottom of the VPS page. You can also ask your question on the OuiHeberg Discord.

Was this article helpful?

1,409 views
Share this article
Need a Linux VPS?

Root access, your choice of distribution and management from the OuiHeberg client area.

View plans →

Related Articles