rclone 云存储同步速查表 - rclone 文件同步命令大全
rclone 把 S3、OSS、Google Drive、S3 兼容存储与本地目录收进同一套命令,配置阶段用 config 建 remote 命名,之后所有操作都写成 remote:path 的形式。真正需要判断的是动作语义:copy 只复制不删除,sync 会让目标端与源端一致并删掉目标端多余文件,move 则本地也会消失。用错 sync 的代价往往不可逆,所以正式执行前务必 --dry-run 看清单,再加 -v 或 --stats 观察传输进度。表里按配置连接、浏览列表、同步复制、过滤规则、挂载服务、加密校验分组,另外 mount 依赖 fuse 实现,大文件读写记得带 --vfs-cache-mode full 或 writes 避免随机写出错。
典型使用场景
面向在本地目录与对象存储(S3、网盘、各类远程)之间搬运数据的运维与数据工程人员。本表把 rclone 的动作分成四层:配置层(config / crypt create / config show)、查看层(lsd / ls / tree / size / check / dedupe / hashsum)、搬运层(sync / copy / move / copyto / bisync 与各类 include/exclude/filter)、暴露层(mount / serve http / serve sftp / serve webdav / rcd)。适合迁移备份、云盘挂载、以及在真正执行前用 --dry-run 反复验证同步范围。
配置与连接 6
rclone configrclone config showrclone listremotesrclone config show remote:rclone config create remote: s3rclone config delete remote:浏览与列表 5
rclone lsd remote:rclone ls remote:pathrclone lsl remote:pathrclone tree remote:pathrclone size remote:bucket同步与复制 6
rclone sync /local remote:bucketrclone copy /local remote:bucketrclone move /local remote:bucketrclone sync remote:bucket /local --dry-runrclone bisync /local remote:bucketrclone copyto src.txt remote:dst.txt过滤与规则 6
rclone sync /local remote:bucket --include "*.txt"rclone sync /local remote:bucket --exclude "*.log"rclone sync /local remote:bucket --exclude-from rules.txtrclone sync /local remote:bucket --filter-from filter.txtrclone sync /local remote:bucket --max-size 10Mrclone sync /local remote:bucket --ignore-size挂载与服务 6
rclone mount remote:bucket /mnt/cloud --vfs-cache-mode fullrclone mount remote:bucket /mnt/cloud --daemonrclone serve http remote:bucket --addr :8080rclone serve sftp remote:bucket --addr :2022rclone serve webdav remote:bucket --addr :8080rclone rcd --rc加密与校验 6
rclone crypt create remote:encrypted remote:plainrclone crypt check remote:encrypted remote:plainrclone check /local remote:bucketrclone dedupe remote:bucketrclone hashsum md5 remote:bucketrclone cleanup remote:bucket参数矩阵
| 参数 | 作用 | 示例 |
|---|---|---|
sync vs copy vs move | sync 双向对齐且会删除目标多余文件;copy 只新增;move 传输后删源,语义差别很大 | rclone sync /local remote:bucket |
--include / --exclude / --filter-from | 控制同步范围:include 白名单、exclude 黑名单、filter-from 从文件读含排除两类规则 | rclone sync /local remote:bucket --exclude-from rules.txt |
--vfs-cache-mode full | mount 时把远程文件缓存到本地再读写,代价是占磁盘、延迟增加 | rclone mount remote:bucket /mnt/cloud --vfs-cache-mode full |
--dry-run | 只打印将要执行的操作不实际传输,是任何批量搬运前的必做步骤 | rclone sync remote:bucket /local --dry-run |
易错点与避坑指南
现象执行 sync 之后目标目录里原有的文件消失了。
原因sync 是单向对齐语义,会删除目标端存在而源端没有的文件。
处置先跑 rclone sync remote:bucket /local --dry-run 看清单;只想新增就用 copy,删除要显式确认。
现象反复同步时大量文件被重复传输,远比预期慢。
原因修改时间或大小元数据不一致,rclone 认为文件已改变(常见于跨传输方式或元数据缺失的远程)。
处置加 --ignore-size 只比时间,或先 rclone check /local remote:bucket 判断哪些文件真的不一致。
现象mount 后读写卡顿、本地磁盘被迅速占满。
原因vfs 缓存模式决定是否把远程内容全量落到本地;full 模式缓存最激进。
处置改用 --vfs-cache-mode writes 等更轻的模式,并给缓存目录设上限,再用 rclone cleanup remote:bucket 清残留。
现象报鉴权失败 / 找不到 remote 名称。
原因remote 路径写法不对(必须是 remote:path 冒号形式),或当前用户没读到那份 rclone 配置。
处置用 rclone listremotes 确认名称,再 rclone config show remote: 查看该远程配置是否落在当前用户下。
排障路径
1搬运前先看清将要发生的操作
rclone sync remote:bucket /local --dry-rundry-run 只打印计划不执行,确认清单里没有误删项再摘掉该参数。
2确认两端文件是否真的一致
rclone check /local remote:bucket不一致的会列出来,据此判断是否需要 --ignore-size 或重新传输。
3排查重复文件与残留对象
rclone dedupe remote:bucket交互式列出疑似重复项由你选择保留;残留对象用 rclone cleanup remote:bucket 清理。
提示
- sync 是单向同步,会删除目标端多余文件;copy 只复制不删除,更安全。
- mount 需要 fuse 支持,macOS 用 macFUSE,Linux 用 fuse3,建议加 --vfs-cache-mode full。
- rclone 支持断点续传,大文件传输中断后重新运行即可继续。
- --progress 参数可以显示实时传输进度和速度,--verbose 显示详细日志。
- --transfers N 控制并发文件数,--transfers 4 表示同时传输 4 个文件。
- --bwlimit 1M 限制传输带宽,避免占满网络。
- rclone size remote:path 递归统计各后缀占用量,找出大文件;--dry-run 配合 size 可预估同步规模。
- --exclude 规则按 glob 匹配,--exclude-if-present .nobackup 可跳过带标记文件的目录,比 --filter 直观。
- crypt 后端加密数据但仍走 copy/sync 语义,先 rclone cryptdecode 校验数据无误再删除原始密文目录。
由 巧匠 维护
公开更新于 2026年7月21日,内容持续校对官方文档。