What it is
rclone is a command-line program to manage files on cloud storage. It’s like rsync for cloud storage, supporting a vast array of providers.
Installation
Linux:
curl https://rclone.org/install.sh | sudo bash
macOS:
brew install rclone
Windows:
Download the executable from the rclone downloads page and add it to your system’s PATH.
Core Concepts
- Remotes:
rcloneinteracts with cloud storage providers through "remotes." A remote is essentially a configuration that stores your credentials and the type of cloud storage you’re connecting to (e.g., "myS3" for an Amazon S3 bucket, "myGDrive" for Google Drive). You set these up usingrclone config. - Paths: Paths within
rcloneare specified asremoteName:path/to/file_or_directory. For example,myGDrive:Documents/Reportsrefers to the 'Reports' directory within the 'Documents' folder on your configured Google Drive remote.
Commands / Usage
Configuration
rclone config: Interactive tool to set up new remotes. You’ll be prompted to name your remote, choose the storage type, and enter your authentication credentials.rclone config show: Displays the current rclone configuration file.rclone config dump: Dumps the configuration to stdout in JSON format.rclone config create <remote_name> <storage_type>: Non-interactive creation of a remote.
Listing and Inspecting
-
rclone lsd <remote>:<path>: List directories on a remote.rclone lsd myS3:backups/dailyLists directories in the
backups/dailypath on themyS3remote. -
rclone ls <remote>:<path>: List files on a remote.rclone ls myDropbox:photos/2023Lists files in the
photos/2023path on themyDropboxremote. -
rclone lcc <remote>:<path>: List common directories.rclone lcc myGDrive:Lists common directories in the root of your Google Drive.
-
rclone size <remote>:<path>: Show the total size of files on a remote.rclone size myOneDrive:DocumentsDisplays the total size of files in the
Documentsfolder onmyOneDrive. -
rclone about <remote>:<path>: Display storage space usage.rclone about myBackblaze:Shows free and used space for your Backblaze B2 bucket.
-
rclone check <remote1>:<path1> <remote2>:<path2>: Check if files in two locations match.rclone check /home/user/data myGDrive:data_backupCompares local
/home/user/datawithmyGDrive:data_backup. -
rclone cryptcheck <remote>:<path> <remote>:<path>: Check encrypted files against their cleartext counterparts.rclone cryptcheck /home/user/encrypted_data myGDrive:encrypted_backupChecks if the encrypted files on
myGDrivematch the local unencrypted files.
Copying and Moving
-
rclone copy <source> <destination>: Copy files from source to destination.rclone copy /home/user/photos myGDrive:photos_backup --progressCopies local
photosdirectory tomyGDrive:photos_backupand shows progress. -
rclone move <source> <destination>: Move files from source to destination.rclone move /home/user/temp_files myS3:archive/old_filesMoves local
temp_filestomyS3:archive/old_files. -
rclone sync <source> <destination>: Sync source to destination, making destination identical to source.rclone sync /home/user/website_files myFTP:public_html --dry-runSimulates syncing local
website_filestomyFTP:public_html.
Deleting
-
rclone delete <remote>:<path>: Delete files on a remote.rclone delete myGDrive:temp_uploads --min-age 7dDeletes files in
myGDrive:temp_uploadsolder than 7 days. -
rclone purge <remote>:<path>: Delete a directory and its contents on a remote.rclone purge myS3:old_backupsDeletes the entire
old_backupsdirectory onmyS3.
Downloading and Uploading
-
rclone copy <remote>:<path> <local_path>: Download files from a remote.rclone copy myDropbox:documents /home/user/downloaded_docsDownloads
documentsfrommyDropboxto the local/home/user/downloaded_docsdirectory. -
rclone copy <local_path> <remote>:<path>: Upload files to a remote.rclone copy /home/user/projects/my_app myGDrive:apps/my_appUploads the local
my_appdirectory tomyGDrive:apps/my_app.
Filtering
-
--include <pattern>: Include files matching the pattern.rclone copy /data myGDrive:data --include "*.jpg"Copies only JPG files from
/datatomyGDrive:data. -
--exclude <pattern>: Exclude files matching the pattern.rclone copy /data myGDrive:data --exclude "*.tmp"Copies all files except
.tmpfiles from/datatomyGDrive:data. -
--filter <rule_file>: Use a file containing filtering rules.rclone copy /data myGDrive:data --filter "filter_rules.txt"Applies rules from
filter_rules.txt. -
--files-from <file>: Read file list from the given file.rclone copy /data myGDrive:data --files-from /home/user/file_list.txtCopies only the files listed in
file_list.txtfrom/data.
Transfer Options
-
--progress: Show progress during transfer.rclone copy /large/files myS3:backup --progress -
--dry-run: Simulate operations without making changes.rclone sync /local/data myGDrive:data_sync --dry-run -
--backup-dir <remote>:<path>: Move files that would be overwritten to another directory.rclone sync /local/data myGDrive:data --backup-dir myGDrive:data_archive/$(date +%Y-%m-%d)Syncs
/local/datatomyGDrive:data, moving any overwritten files to a dated archive directory. -
--ignore-existing: Skip files that already exist on the destination.rclone copy /new_data myGDrive:data --ignore-existingCopies only new files from
/new_datatomyGDrive:data. -
--update: Skip files that are newer on the destination.rclone copy /local/data myGDrive:data --updateCopies files only if they are older on the destination.
-
--transfers <number>: Number of parallel transfers.rclone copy /big/data myS3:backup --transfers 16 -
--checkers <number>: Number of checkers to use.rclone copy /big/data myS3:backup --checkers 16 -
--bwlimit <rate>: Bandwidth limit (e.g.,10Mfor 10 MiB/s).rclone copy /local/files myGDrive:backup --bwlimit 5M -
--create-empty-src-dirs: Create empty directories on the destination.rclone copy /local/data myGDrive:data --create-empty-src-dirs -
--fast-list: Use faster listing methods if available.rclone sync /local/data myGDrive:data --fast-list
Encryption
-
rclone obscure <password>: Obscure a password for use in config.rclone obscure mysecretpassword -
rclone crypt check <remote>:<path> <remote>:<path>: Check encrypted files against their cleartext counterparts.rclone cryptcheck myGDrive:encrypted_files myGDrive:plain_files -
rclone cryptsetup: Interactive tool to set up encrypted remotes.
Other
-
rclone mount <remote>:<path> <mountpoint>: Mount a remote as a file system.rclone mount myGDrive:Documents /mnt/gdrive_docs --daemonMounts Google Drive’s
Documentsfolder at/mnt/gdrive_docsand runs in the background. -
rclone serve <remote>:<path>: Serve files over various protocols (HTTP, FTP, WebDAV, SFTP, DLNA).rclone serve http myS3:public_filesServes files from
myS3:public_filesvia HTTP. -
rclone rmd <remote>:<path>: Remove a directory.rclone rmd myGDrive:old_stuff -
rclone rmdir <remote>:<path>: Remove an empty directory.rclone rmdir myGDrive:empty_folder
Common Patterns
-
Backup local directory to cloud:
rclone sync /home/user/documents myGDrive:backups/documents --backup-dir myGDrive:backups/archive/$(date +%Y-%m-%d) --progressSyncs local documents to Google Drive, moving old versions to a dated archive.
-
Download specific file types from cloud:
rclone copy myS3:photos/2023 myGDrive:photos_archive_2023 --include "*.jpg" --exclude "*.png" --progressCopies only JPG files from
myS3:photos/2023tomyGDrive:photos_archive_2023, excluding PNGs. -
Clean up old files on cloud storage:
rclone delete myDropbox:temp_files --min-age 30d --dry-runFinds and lists files in
myDropbox:temp_filesolder than 30 days without deleting them. Remove--dry-runto perform the deletion. -
Mirror a local directory to cloud storage:
rclone sync /var/www/html myFTP:public_html --bwlimit 2MKeeps
myFTP:public_htmlidentical to/var/www/htmlwith a 2 MiB/s bandwidth limit. -
Copy files between two cloud providers:
rclone copy myGDrive:photos/2023 myS3:archive/photos_2023 --transfers 8 --checkers 8Copies photos from Google Drive to Amazon S3 using 8 parallel transfers and checkers.
-
Find large files on cloud storage:
rclone ls myS3:backups --max-size 10G | sort -rh -k1,1Lists files larger than 10GiB in
myS3:backupsand sorts them by size. (Note:rclone lsitself doesn’t have--max-size, this is a common shell-based filtering). A more directrcloneway isrclone lslwhich shows sizes and then sort.rclone lsl myS3:backups | awk '$1 > 10737418240 { print }' | sort -rh -k1,1Lists files larger than 10GB and sorts them by size.
Gotchas
syncvscopy:rclone syncmakes the destination exactly match the source. If you delete a file locally,rclone syncwill delete it from the destination.rclone copyonly adds or updates files; it never deletes from the destination.--dry-runis your friend: Always use--dry-runwithsync,delete, orpurgecommands until you are absolutely sure they will do what you expect.- Case sensitivity: Cloud storage providers vary in case sensitivity.
rclonetries to abstract this, but be aware of potential differences. - File name restrictions: Some cloud providers have stricter rules for file names (e.g., disallowing certain characters).
rclonecan often handle these by renaming, but it’s good to be aware. - Rate limits: Cloud providers impose API rate limits. If you hit these,
rclonewill typically pause and retry, but aggressive operations can lead to temporary blocks. Use--transfersand--checkersjudiciously. rclone mountand performance: Mounting a remote as a filesystem can be convenient but may not offer the same performance as directrcloneoperations for large transfers or many small files.- Encryption layer:
rclone cryptencrypts files before they are uploaded. The remote configured forcryptstores encrypted data. You need a separate, unencrypted remote configuration to pointrclone cryptto the actual cloud storage location.