介绍展开目录
Rclone 是一款的命令行工具,支持在不同对象存储、网盘间同步、上传、下载数据。
- 官网网址:https://rclone.org
- Github 项目:GitHub - rclone/rclone: "rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Yandex Files
- 相关文档及参数介绍:rclone mount
安装展开目录
安装 EPEL 源:
yum -y install epel-release
安装一些基本组件和依赖:
yum -y install wget unzip screen fuse fuse-devel
下载 Rclone (amd64) 解压然后进入目录(方法 1):
wget https://downloads.rclone.org/rclone-current-linux-amd64.zip
unzip rclone-current-linux-amd64.zip
chmod 0755 ./rclone-*/rclone
cp ./rclone-*/rclone /usr/bin/
rm -rf ./rclone-*
下载 Rclone (amd64) 解压然后进入目录(方法 2):
curl -O http://downloads.rclone.org/rclone-current-linux-amd64.zip
unzip rclone-current-linux-amd64.zip
cd rclone-*-linux-amd64
cp rclone /usr/sbin/
chown root:root /usr/sbin/rclone
chmod 0755 /usr/sbin/rclone
运行 Rclone 开始配置:
./rclone config
第一步选择 n,然后回车输入一个 name,建议这个 name 设置的简单好记一点,然后直接按提示填写即可。(也可以跳过配置步骤,直接再rclone配置文件目录进行配置:vim ~/.config/rclone/rclone.conf)
首都在线对象存储config如下:
[remote2]
type = s3
provider = Other
env_auth = false
access_key_id = c056b4adfxxxxx
secret_access_key = 0e45067d189xxxx
region = other-v2-signature
endpoint = http://oss-cnbj01.cdsgss.com
acl = private
bucket_acl = private
#chunk_size = 5M
#upload_concurrency = 500
v2_auth = true
force_path_style = true
步骤2:创建本地需要挂载的文件夹
mkdir /home/test3/
步骤3:挂载对象存储桶至本地文件夹
rclone mount remote2:bucket-full /home/test3/ --allow-other --allow-non-empty --vfs-cache-mode writes --transfers=50 --progres
参数说明:
-- transfers=50 最大执行的线程数
-- progres 输出消息
其他参数描述:
--allow-non-empty Allow mounting over a non-empty directory. Not supported on Windows.
--allow-other Allow access to other users. Not supported on Windows.
--allow-root Allow access to root user. Not supported on Windows.
--async-read Use asynchronous reads. Not supported on Windows. (default true)
--attr-timeout duration Time for which file/directory attributes are cached. (default 1s)
--daemon Run mount as a daemon (background mode). Not supported on Windows.
--daemon-timeout duration Time limit for rclone to respond to kernel. Not supported on Windows.
--debug-fuse Debug the FUSE internals - needs -v.
--default-permissions Makes kernel enforce access control based on the file mode. Not supported on Windows.
--dir-cache-time duration Time to cache directory entries for. (default 5m0s)
--dir-perms FileMode Directory permissions (default 0777)
--file-perms FileMode File permissions (default 0666)
--fuse-flag stringArray Flags or arguments to be passed direct to libfuse/WinFsp. Repeat if required.
--gid uint32 Override the gid field set by the filesystem. Not supported on Windows.
-h, --help help for mount
--max-read-ahead SizeSuffix The number of bytes that can be prefetched for sequential reads. Not supported on Windows. (default 128k)
--network-mode Mount as remote network drive, instead of fixed disk drive. Supported on Windows only
--no-checksum Don't compare checksums on up/download.
--no-modtime Don't read/write the modification time (can speed things up).
--no-seek Don't allow seeking in files.
--noappledouble Ignore Apple Double (._) and .DS_Store files. Supported on OSX only. (default true)
--noapplexattr Ignore all "com.apple.*" extended attributes. Supported on OSX only.
-o, --option stringArray Option for libfuse/WinFsp. Repeat if required.
--poll-interval duration Time to wait between polling for changes. Must be smaller than dir-cache-time. Only on supported remotes. Set to 0 to disable. (default 1m0s)
--read-only Mount read-only.
--uid uint32 Override the uid field set by the filesystem. Not supported on Windows.
--umask int Override the permission bits set by the filesystem. Not supported on Windows.
--vfs-cache-max-age duration Max age of objects in the cache. (default 1h0m0s)
--vfs-cache-max-size SizeSuffix Max total size of objects in the cache. (default off)
--vfs-cache-mode CacheMode Cache mode off|minimal|writes|full (default off)
--vfs-cache-poll-interval duration Interval to poll the cache for stale objects. (default 1m0s)
--vfs-case-insensitive If a file name not found, find a case insensitive match.
--vfs-read-ahead SizeSuffix Extra read ahead over --buffer-size when using cache-mode full.
--vfs-read-chunk-size SizeSuffix Read the source objects in chunks. (default 128M)
--vfs-read-chunk-size-limit SizeSuffix If greater than --vfs-read-chunk-size, double the chunk size after each chunk read, until the limit is reached. 'off' is unlimited. (default off)
--vfs-read-wait duration Time to wait for in-sequence read before seeking. (default 20ms)
--vfs-used-is-size rclone size Use the rclone size algorithm for Used size.
--vfs-write-back duration Time to writeback files after last use when using cache. (default 5s)
--vfs-write-wait duration Time to wait for in-sequence write before giving error. (default 1s)
--volname string Set the volume name. Supported on Windows and OSX only.
--write-back-cache Makes kernel buffer writes before sending them to rclone. Without this, writethrough caching is used. Not supported on Windows.
步骤4:查看文件是否挂载成功
df -h
验证测试:
vim /home/test.txt
cp /home/test.txt /home/test3/
其他常用命令:
rclone size remote2:bucket-full/test //查看文件夹数量及大小
rclone ls remote2:bucket-full/test //查看文件夹目录
rclone copyto /home/test3 remote2:bucket-full/test --transfers=50 --progres //上传本地文件夹至对象存储桶文件夹
以systemctl服务方式启动:
1,新建一个 rclone.service
文件:
vi /usr/lib/systemd/system/rclone.service
2,写入以下内容
[Unit]
Description=rclone
[Service]
User=root
ExecStart=/usr/bin/rclone rclone mount remote2:bucket-full /home/test3/ --allow-other --allow-non-empty --vfs-cache-mode writes --transfers=50 --progress
Restart=on-abort
[Install]
WantedBy=multi-user.target
重载 daemon
,让新的服务文件生效:
systemctl daemon-reload
现在就可以用 systemctl来启动 rclone了:
systemctl start rclone
设置开机启动项:
systemctl enable rclone
停止、查看状态可以用:
操作命令展开目录
rclone
命令的语法格式
Syntax: [options] subcommand <parameters> <parameters...>
常用的 rclone
命令有:
rclone config - 以控制会话的形式添加rclone的配置,配置保存在.rclone.conf文件中。
rclone copy - 将文件从源复制到目的地址,跳过已复制完成的。
rclone sync - 将源数据同步到目的地址,只更新目的地址的数据。
rclone move - 将源数据移动到目的地址。
rclone delete - 删除指定路径下的文件内容。
rclone purge - 清空指定路径下所有文件数据。
rclone mkdir - 创建一个新目录。
rclone rmdir - 删除空目录。
rclone check - 检查源和目的地址数据是否匹配。
rclone ls - 列出指定路径下所有的文件以及文件大小和路径。
rclone lsd - 列出指定路径下所有的目录/容器/桶。
rclone lsl - 列出指定路径下所有文件以及修改时间、文件大小和路径。
rclone md5sum - 为指定路径下的所有文件产生一个md5sum文件。
rclone sha1sum - 为指定路径下的所有文件产生一个sha1sum文件。
rclone size - 获取指定路径下,文件内容的总大小。.
rclone version - 查看当前版本。
rclone cleanup - 清空remote。
rclone dedupe - 交互式查找重复文件,进行删除/重命名操作
rclone config展开目录
开启一个交互式的配置会话。命令格式如下:
rclone config
rclone copy
将文件从源复制到目的地址,跳过已复制完成的。命令格式如下:
rclone copy source:sourcepath dest:destpsth
rclone sync
-
同步数据时,可能会删除目的地址的数据;建议先使用–dry-run 标志来检查要复制、删除的数据。
-
同步数据出错时,不会删除任何目的地址的数据。
-
rclone sync 同步的始终是 path 目录下的数据,而不是 path 目录。(空目录将不会被同步)
-
rclone sync source:path dest:path
rclone delete展开目录
删除指定目录的内容。命令格式如下:
-
rclone delete remote:path
-
更多 rclone 命令,详见 Commands 。