rclone is “rsync for cloud storage”. One command-line tool talks to more than 70 storage providers: Amazon S3 and S3-compatible services (Backblaze B2, Wasabi, Cloudflare R2, MinIO), Google Drive, Dropbox, OneDrive, SFTP servers and many more. On a VPS, it’s the easiest way to push backups off-site, or sync files between servers and cloud storage.

Install

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

(Distribution packages exist too, but are often older.)

Configure a remote

Interactive setup:

rclone config

Choose n (new remote), give it a name (for example b2), pick the storage type, and enter credentials. The config is saved in ~/.config/rclone/rclone.conf. Protect it (chmod 600), because it contains your keys.

Example result for S3-compatible storage:

[s3backup]
type = s3
provider = Other
access_key_id = …
secret_access_key = …
endpoint = https://s3.example-provider.com
region = us-east-1

For Google Drive, Dropbox and OneDrive, the OAuth step needs a browser. Run rclone authorize "drive" on your own computer, and paste the token into the server’s config.

Basic commands

rclone lsd s3backup:                       # list buckets/top-level directories
rclone ls s3backup:my-bucket/path          # list files
rclone copy /var/backups s3backup:my-bucket/web1 --progress
rclone sync /var/www/uploads s3backup:my-bucket/uploads --progress
rclone check /var/backups s3backup:my-bucket/web1
Command Effect
copy Copy new/changed files to the destination; never deletes
sync Make the destination identical, deleting extra files there
move Copy, then delete from the source
check Compare source and destination

Careful with sync: a mistake in the source path can delete your remote data. Always test with --dry-run first:

rclone sync /var/www/uploads s3backup:my-bucket/uploads --dry-run

Use --backup-dir s3backup:my-bucket/deleted/$(date +%F) to keep files that sync would delete or overwrite.

Encrypt before uploading: crypt

The crypt remote wraps another remote, and encrypts file contents (and optionally names) client-side:

rclone config      # new remote → type "crypt" → remote = s3backup:my-bucket/encrypted
rclone copy /var/backups secret:web1

The provider only ever sees encrypted data. Keep the crypt passwords safe, because without them the data is unrecoverable.

Useful options

--transfers 8              # parallel transfers
--bwlimit 20M              # limit bandwidth (e.g. during business hours: "08:00,10M 20:00,off")
--exclude "*.tmp" --exclude "cache/**"
--min-age 1h               # skip files still being written
--log-file /var/log/rclone.log --log-level INFO

Scheduled backups

# /etc/cron.d/rclone-backup
30 3 * * * root /usr/bin/rclone copy /var/backups s3backup:my-bucket/web1 --min-age 10m --log-file /var/log/rclone.log --log-level INFO

Combine with local database dumps first. For versioned, deduplicated backups, use restic (which can use rclone as a backend). See restic backup, crontab, and WordPress backup without a plugin.

Mount cloud storage

sudo apt install fuse3
rclone mount s3backup:my-bucket /mnt/bucket --vfs-cache-mode writes --daemon

That’s handy for browsing, or for apps that need file access. But cloud storage behind a mount is slower than local disk, and not suited to databases.

Server-to-server

rclone also works between remotes, or with SFTP:

rclone copy sftp-old:/var/www/site /var/www/site --progress

For Linux-to-Linux copies, rsync is usually simpler. See rsync examples.

Quick reference

Task Command
Configure rclone config
Copy (no deletes) rclone copy src remote:path
Mirror (deletes!) rclone sync src remote:path --dry-run
Verify rclone check src remote:path
Encrypt crypt remote
Mount rclone mount remote:path /mnt/x

Related: VPS as a backup server and MinIO object storage.

  • Backup
  • Cloud Storage
  • Linux