> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.bitiful.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.bitiful.com/_mcp/server.

# 将 S4 对象存储与 Rclone 结合使用

> 配置 Rclone 连接缤纷云 S4，完成上传、同步、定时备份、跨云迁移、校验、客户端加密、挂载与 WebDAV。

Rclone 是命令行同步工具，支持 Windows、macOS 和 Linux，适合批量上传、备份、跨云迁移和挂载。

## 前置条件

- 已 [创建存储桶](https://docs.bitiful.com/bitiful-s4/handbook/buckets.md)。子账户不能创建桶，`rclone mkdir` 新桶会返回 403；
- 已 [创建子账户与 AccessKey](https://docs.bitiful.com/bitiful-s4/handbook/access-keys.md)，并 [授予](https://docs.bitiful.com/bitiful-s4/handbook/permissions.md) 该桶的读、写、列表权限。

## 安装

**Windows**

```powershell
winget install Rclone.Rclone
```

**macOS**

```bash
brew install rclone
```

**Linux**

```bash
curl https://rclone.org/install.sh | sudo bash
```

Windows 的命令请在 PowerShell 里运行，示例里的 `D:\` 换成自己的目录。

> **Note**
>
> macOS 上用 Homebrew 安装的版本不能挂载，需要 [挂载](https://docs.bitiful.com/bitiful-s4/intro.md#挂载为本地目录) 时请从 [Rclone 官网](https://rclone.org/downloads/) 下载。

## 配置

运行 `rclone config file` 查看配置文件位置，写入以下内容：

```ini title="rclone.conf"
[s4]
type = s3
provider = Other
env_auth = false
access_key_id = 你的 AccessKey
secret_access_key = 你的 SecretKey
endpoint = https://s3.bitiful.net
region = cn-east-1
list_version = 2
no_check_bucket = true
```

| 配置项                      | 说明                         |
| :----------------------- | -------------------------- |
| `endpoint`、`region`      | 固定为上面的值                    |
| `list_version = 2`       | 使用 ListObjectsV2           |
| `no_check_bucket = true` | 上传前不检查、不创建桶。子账户没有建桶权限，必须设置 |

或者用一条命令创建：

**Windows**

```powershell title="PowerShell"
rclone.exe config create s4 s3 provider=Other env_auth=false access_key_id="你的 AccessKey" secret_access_key="你的 SecretKey" endpoint=https://s3.bitiful.net region=cn-east-1 list_version=2 no_check_bucket=true
```

**macOS**

```bash
rclone config create s4 s3 provider=Other env_auth=false access_key_id="你的 AccessKey" secret_access_key="你的 SecretKey" endpoint=https://s3.bitiful.net region=cn-east-1 list_version=2 no_check_bucket=true
```

**Linux**

```bash
rclone config create s4 s3 provider=Other env_auth=false access_key_id="你的 AccessKey" secret_access_key="你的 SecretKey" endpoint=https://s3.bitiful.net region=cn-east-1 list_version=2 no_check_bucket=true
```

验证配置，列出桶里的内容：

**Windows**

```powershell title="PowerShell"
rclone.exe lsf s4:my-bucket
```

**macOS**

```bash
rclone lsf s4:my-bucket
```

**Linux**

```bash
rclone lsf s4:my-bucket
```

配置文件里的密钥没有加密。多人使用的机器上，用 `rclone config` 设置配置密码，或改用环境变量 `RCLONE_CONFIG_S4_ACCESS_KEY_ID`、`RCLONE_CONFIG_S4_SECRET_ACCESS_KEY`。

## 上传与下载

**Windows**

```powershell title="PowerShell"
# 上传单个文件到目录
rclone.exe copy D:\logo.png s4:my-bucket/images/

# 上传目录，显示进度
rclone.exe copy D:\documents s4:my-bucket/documents -P

# 指定浏览器缓存时间
rclone.exe copy D:\assets s4:my-bucket/assets --header-upload "Cache-Control: max-age=31536000"

# 备份数据库并上传
mysqldump.exe mydb --result-file=D:\backup\mydb.sql
rclone.exe copy D:\backup\mydb.sql s4:my-bucket/backup/

# 下载
rclone.exe copy s4:my-bucket/images/logo.png D:\
```

**macOS**

```bash
# 上传单个文件到目录
rclone copy ./logo.png s4:my-bucket/images/

# 上传目录，显示进度
rclone copy ./documents s4:my-bucket/documents -P

# 指定浏览器缓存时间
rclone copy ./assets s4:my-bucket/assets --header-upload "Cache-Control: max-age=31536000"

# 把命令输出直接写成对象
mysqldump mydb | gzip | rclone rcat s4:my-bucket/backup/mydb.sql.gz

# 下载
rclone copy s4:my-bucket/images/logo.png ./
```

**Linux**

```bash
# 上传单个文件到目录
rclone copy ./logo.png s4:my-bucket/images/

# 上传目录，显示进度
rclone copy ./documents s4:my-bucket/documents -P

# 指定浏览器缓存时间
rclone copy ./assets s4:my-bucket/assets --header-upload "Cache-Control: max-age=31536000"

# 把命令输出直接写成对象
mysqldump mydb | gzip | rclone rcat s4:my-bucket/backup/mydb.sql.gz

# 下载
rclone copy s4:my-bucket/images/logo.png ./
```

`copy` 只传新增和有变化的文件，可以反复执行。

## 查看与管理

**Windows**

```powershell title="PowerShell"
rclone.exe lsf s4:my-bucket/images               # 列出文件名
rclone.exe lsl s4:my-bucket/images               # 列出大小和时间
rclone.exe tree s4:my-bucket/images              # 树状显示
rclone.exe size s4:my-bucket/documents           # 统计数量与容量
rclone.exe cat s4:my-bucket/notes/todo.txt       # 查看内容

rclone.exe moveto s4:my-bucket/a.txt s4:my-bucket/b.txt   # 改名
rclone.exe delete s4:my-bucket/tmp --min-age 30d          # 删除 30 天前的文件
rclone.exe purge s4:my-bucket/tmp                         # 删除整个目录，无法恢复

rclone.exe link s4:my-bucket/images/logo.png --expire 1h  # 临时下载链接，最长 7 天
```

**macOS**

```bash
rclone lsf s4:my-bucket/images               # 列出文件名
rclone lsl s4:my-bucket/images               # 列出大小和时间
rclone tree s4:my-bucket/images              # 树状显示
rclone size s4:my-bucket/documents           # 统计数量与容量
rclone cat s4:my-bucket/notes/todo.txt       # 查看内容

rclone moveto s4:my-bucket/a.txt s4:my-bucket/b.txt   # 改名
rclone delete s4:my-bucket/tmp --min-age 30d          # 删除 30 天前的文件
rclone purge s4:my-bucket/tmp                         # 删除整个目录，无法恢复

rclone link s4:my-bucket/images/logo.png --expire 1h  # 临时下载链接，最长 7 天
```

**Linux**

```bash
rclone lsf s4:my-bucket/images               # 列出文件名
rclone lsl s4:my-bucket/images               # 列出大小和时间
rclone tree s4:my-bucket/images              # 树状显示
rclone size s4:my-bucket/documents           # 统计数量与容量
rclone cat s4:my-bucket/notes/todo.txt       # 查看内容

rclone moveto s4:my-bucket/a.txt s4:my-bucket/b.txt   # 改名
rclone delete s4:my-bucket/tmp --min-age 30d          # 删除 30 天前的文件
rclone purge s4:my-bucket/tmp                         # 删除整个目录，无法恢复

rclone link s4:my-bucket/images/logo.png --expire 1h  # 临时下载链接，最长 7 天
```

`moveto` 会先复制再删除。大文件请用 S4 的 [原生移动](https://docs.bitiful.com/bitiful-s4/features/move-object.md)。

## 同步

**Windows**

```powershell title="PowerShell"
# 先预演，不做任何改动
rclone.exe sync D:\site s4:my-bucket/site --dry-run

# 让目标与源完全一致，会删除目标里多余的文件
rclone.exe sync D:\site s4:my-bucket/site -P
```

**macOS**

```bash
# 先预演，不做任何改动
rclone sync ./site s4:my-bucket/site --dry-run

# 让目标与源完全一致，会删除目标里多余的文件
rclone sync ./site s4:my-bucket/site -P
```

**Linux**

```bash
# 先预演，不做任何改动
rclone sync ./site s4:my-bucket/site --dry-run

# 让目标与源完全一致，会删除目标里多余的文件
rclone sync ./site s4:my-bucket/site -P
```

> **Warning**
>
> `sync` 会删除目标中源没有的文件，S4 没有回收站。不确定时用 `copy`，或先加 `--dry-run`。

给删除和覆盖的文件留一份备份：

**Windows**

```powershell title="PowerShell"
rclone.exe sync D:\site s4:my-bucket/site --backup-dir s4:my-bucket/site-old/2026-11-25
```

**macOS**

```bash
rclone sync ./site s4:my-bucket/site --backup-dir s4:my-bucket/site-old/2026-11-25
```

**Linux**

```bash
rclone sync ./site s4:my-bucket/site --backup-dir s4:my-bucket/site-old/2026-11-25
```

排除部分文件：

**Windows**

```powershell title="PowerShell"
rclone.exe sync D:\project s4:my-bucket/project --exclude "node_modules/**" --exclude "*.tmp"
```

**macOS**

```bash
rclone sync ./project s4:my-bucket/project --exclude "node_modules/**" --exclude "*.tmp"
```

**Linux**

```bash
rclone sync ./project s4:my-bucket/project --exclude "node_modules/**" --exclude "*.tmp"
```

## 定时备份

每天 3 点增量备份。上一次还没结束时，不要重复启动。

**Windows**

用 **任务计划程序** 新建任务：触发器选 **每天** 3:00，操作选 **启动程序**，程序填 `rclone.exe` 的完整路径（用 `where.exe rclone` 查看），参数填：

```text
copy D:\data s4:my-bucket/backup --log-file=D:\rclone-backup.log --log-level INFO
```

在任务的 **设置** 里，**如果此任务已经运行** 选 **请勿启动新实例**。

**macOS**

```bash
crontab -e
```

```text
0 3 * * * /opt/homebrew/bin/rclone copy /Users/用户名/data s4:my-bucket/backup --log-file=/Users/用户名/rclone-backup.log --log-level INFO
```

Rclone 的路径用 `which rclone` 查看。备份文稿、桌面等目录，需要在系统设置里给 cron 完全磁盘访问权限。

**Linux**

```bash
crontab -e
```

```text
0 3 * * * /usr/bin/rclone copy /data s4:my-bucket/backup --log-file=/var/log/rclone-backup.log --log-level INFO
```

可以用 `flock` 包一层，避免重复启动。

## 校验

**Windows**

```powershell title="PowerShell"
# 比对大小和校验值
rclone.exe check D:\documents s4:my-bucket/documents

# 下载内容逐字节比对，会产生下载流量
rclone.exe check D:\documents s4:my-bucket/documents --download
```

**macOS**

```bash
# 比对大小和校验值
rclone check ./documents s4:my-bucket/documents

# 下载内容逐字节比对，会产生下载流量
rclone check ./documents s4:my-bucket/documents --download
```

**Linux**

```bash
# 比对大小和校验值
rclone check ./documents s4:my-bucket/documents

# 下载内容逐字节比对，会产生下载流量
rclone check ./documents s4:my-bucket/documents --download
```

## 大量文件与大文件

**Windows**

```powershell title="PowerShell"
# 大量小文件：提高并发
rclone.exe copy D:\data s4:my-bucket/data -P --transfers 32 --checkers 32 --fast-list

# 大文件：加大分片和单文件并发
rclone.exe copy D:\video.mp4 s4:my-bucket/videos/ -P --s3-chunk-size 64M --s3-upload-concurrency 8
```

**macOS**

```bash
# 大量小文件：提高并发
rclone copy ./data s4:my-bucket/data -P --transfers 32 --checkers 32 --fast-list

# 大文件：加大分片和单文件并发
rclone copy ./video.mp4 s4:my-bucket/videos/ -P --s3-chunk-size 64M --s3-upload-concurrency 8
```

**Linux**

```bash
# 大量小文件：提高并发
rclone copy ./data s4:my-bucket/data -P --transfers 32 --checkers 32 --fast-list

# 大文件：加大分片和单文件并发
rclone copy ./video.mp4 s4:my-bucket/videos/ -P --s3-chunk-size 64M --s3-upload-concurrency 8
```

内存占用约为 `--transfers` × `--s3-upload-concurrency` × `--s3-chunk-size`。并发过高会触发 [QPS 限制](https://docs.bitiful.com/bitiful-s4/limits.md)，出现 429 时降低 `--transfers`，或加 `--tpslimit 100`。

中断的分片上传会占用空间，清理 24 小时以前的：

**Windows**

```powershell title="PowerShell"
rclone.exe backend list-multipart-uploads s4:my-bucket
rclone.exe cleanup s4:my-bucket
```

**macOS**

```bash
rclone backend list-multipart-uploads s4:my-bucket
rclone cleanup s4:my-bucket
```

**Linux**

```bash
rclone backend list-multipart-uploads s4:my-bucket
rclone cleanup s4:my-bucket
```

## 从其他云迁移

在配置文件里再加一个源，例如阿里云 OSS：

```ini
[oss]
type = s3
provider = Alibaba
access_key_id = 源的 AccessKey
secret_access_key = 源的 SecretKey
endpoint = oss-cn-hangzhou.aliyuncs.com
```

然后直接在两个云之间复制，完成后校验：

**Windows**

```powershell title="PowerShell"
rclone.exe copy oss:old-bucket s4:my-bucket -P --transfers 16
rclone.exe check oss:old-bucket s4:my-bucket --size-only
```

**macOS**

```bash
rclone copy oss:old-bucket s4:my-bucket -P --transfers 16
rclone check oss:old-bucket s4:my-bucket --size-only
```

**Linux**

```bash
rclone copy oss:old-bucket s4:my-bucket -P --transfers 16
rclone check oss:old-bucket s4:my-bucket --size-only
```

数据会经过运行 Rclone 的机器，源站可能收取外网流量费。文件多时建议在云服务器上运行。想不停业务迁移，可以配合 [镜像回源](https://docs.bitiful.com/bitiful-s4/handbook/mirror.md)。

## 客户端加密

上传前在本地加密文件名和内容，S4 上只保存密文：

**Windows**

```powershell title="PowerShell"
rclone.exe config create s4crypt crypt remote=s4:my-bucket/encrypted password=$(rclone.exe obscure "你的加密密码")
rclone.exe copy D:\private s4crypt:
rclone.exe lsf s4crypt:
```

**macOS**

```bash
rclone config create s4crypt crypt remote=s4:my-bucket/encrypted password=$(rclone obscure "你的加密密码")
rclone copy ./private s4crypt:
rclone lsf s4crypt:
```

**Linux**

```bash
rclone config create s4crypt crypt remote=s4:my-bucket/encrypted password=$(rclone obscure "你的加密密码")
rclone copy ./private s4crypt:
rclone lsf s4crypt:
```

直接看 `s4:my-bucket/encrypted`，文件名和内容都是乱码。

> **Warning**
>
> 密码丢失后数据无法恢复。加密后的文件不能在控制台预览，也不能使用图片处理和 CDN 直接访问。

## 挂载为本地目录

Linux 需要安装 fuse3，macOS 需要 [macFUSE](https://github.com/macfuse/macfuse/releases)，Windows 需要 [WinFsp](https://github.com/winfsp/winfsp/releases)。

**Windows**

```powershell
rclone.exe mount s4:my-bucket S: --vfs-cache-mode full --vfs-cache-max-size 10G --vfs-cache-max-age 24h --vfs-read-chunk-size 16M --vfs-read-chunk-size-limit 256M --dir-cache-time 1m
```

程序在前台运行，不要关闭窗口。卸载时在窗口按 `Ctrl+C`。

**macOS**

```bash
mkdir -p ~/s4
rclone mount s4:my-bucket ~/s4 \
  --daemon \
  --vfs-cache-mode full \
  --vfs-cache-max-size 10G \
  --vfs-cache-max-age 24h \
  --vfs-read-chunk-size 16M \
  --vfs-read-chunk-size-limit 256M \
  --dir-cache-time 1m \
  --log-file ~/rclone.log
```

卸载：

```bash
umount ~/s4
```

**Linux**

```bash
mkdir -p ~/s4
rclone mount s4:my-bucket ~/s4 \
  --daemon \
  --vfs-cache-mode full \
  --vfs-cache-max-size 10G \
  --vfs-cache-max-age 24h \
  --vfs-read-chunk-size 16M \
  --vfs-read-chunk-size-limit 256M \
  --dir-cache-time 1m \
  --log-file ~/rclone.log
```

卸载：

```bash
fusermount3 -u ~/s4
```

挂载适合浏览和顺序读写，不适合数据库等需要随机写、文件锁的程序。写入先进入本地缓存，再后台上传，关机前请确认上传完成。缤纷云官方的挂载工具见 [Bitifs](https://docs.bitiful.com/clients/bitifs/intro.md)。

## 提供 WebDAV 服务

让只支持 WebDAV 的软件（笔记、影音、NAS 同步等）使用 S4：

**Windows**

```powershell title="PowerShell"
rclone.exe serve webdav s4:my-bucket --addr 127.0.0.1:8080 --user demo --pass 你的密码 --vfs-cache-mode writes
```

**macOS**

```bash
rclone serve webdav s4:my-bucket --addr 127.0.0.1:8080 --user demo --pass 你的密码 --vfs-cache-mode writes
```

**Linux**

```bash
rclone serve webdav s4:my-bucket --addr 127.0.0.1:8080 --user demo --pass 你的密码 --vfs-cache-mode writes
```

对外提供服务时，请放在 HTTPS 反向代理后面。

## 常见问题

<details>
<summary>403 AccessDenied</summary>

检查子账户授权。只授权了目录时，路径要写到授权目录，例如 `s4:my-bucket/images`，不要操作桶根目录。

</details>

<details>
<summary>上传时报没有权限创建桶</summary>

配置里缺少 `no_check_bucket = true`。

</details>

<details>
<summary>修改时间变了，内容没变，为什么还有请求</summary>

Rclone 会更新对象里保存的修改时间，不会重新上传内容。不需要保留修改时间时，加 `--checksum` 按大小和校验值比较，或用 `--size-only` 只比较大小，也可以加 `--no-update-modtime`。

</details>

<details>
<summary>rclone about 报不支持</summary>

对象存储没有总容量的概念。查看已用容量用 `rclone size`，或在控制台的 [用量统计](https://docs.bitiful.com/bitiful-s4/handbook/statistics.md) 查看。

</details>

<details>
<summary>下载速度不高</summary>

单个连接有默认限速，见 [约束限制](https://docs.bitiful.com/bitiful-s4/limits.md)。用 `--multi-thread-streams` 多线程下载，或用 [CDN](https://docs.bitiful.com/cdn/intro.md) 分发。

</details>

## 相关阅读

1. [官方 Rclone 文档](https://rclone.org/s3/)
2. [Ugediao: Debian 服务器通过 rclone 挂载缤纷云](https://ugediao.com/debian-rclone-bitiful.html)
