外观
使用Rclone挂载FTP同步本地文件到服务器
提示
提前打开服务器20
、21
和39000-40000
端口
参考资料
参考文章:备份同步神器 Rclone 使用教程
参考文字:使用rclone挂载FTP目录到Minio_rclone从ftp服务器上下载文件并传输到minio
安装 Rclone
Windows安装直接下载后解压:Rclone downloads
Linux安装请参考:rclone-cos
Rclone 配置
使用命令配置
- 将 Rclone 添加到环境变量,使用如下命令
rclone config
- 未将 Rclone 添加到环境变量,首先到 Rclone 所在文件夹,在目录栏输入
cmd
。


使用如下命令
rclone.exe config
输出
# No remotes found, make a new one?
# n) New remote
# s) Set configuration password
# q) Quit config
n/s/q> n
# Enter name for new remote.
name> Set your own name
# Option Storage.
# Type of storage to configure.
# Choose a number from below, or type in your own value.
# ...
# 15 / FTP
# \ (ftp)
# ...
# 此步注意不一定为 15
Storage> 15
# Option host.
# FTP host to connect to.
# E.g. "ftp.example.com".
# Enter a value.
host> Your ip/host
# Option user.
# FTP username.
# Enter a value of type string. Press Enter for the default (xxxx\xxxx).
user> Your user
# Option port.
# FTP port number.
# Enter a signed integer. Press Enter for the default (21).
port> 21
# Option pass.
# FTP password.
# Choose an alternative below. Press Enter for the default (n).
# y) Yes, type in my own password
# g) Generate random password
# n) No, leave this optional password blank (default)
# 输入 y 后会让输入密码,输入密码时不会显示出来,输入就好了。
y/g/n> y
# Option tls.
# Use Implicit FTPS (FTP over TLS).
# When using implicit FTP over TLS the client connects using TLS
# right from the start which breaks compatibility with
# non-TLS-aware servers. This is usually served over port 990 rather
# than port 21. Cannot be used in combination with explicit FTPS.
# Enter a boolean value (true or false). Press Enter for the default (false).
tls> Enter(直接回车)
# Option explicit_tls.
# Use Explicit FTPS (FTP over TLS).
# When using explicit FTP over TLS the client explicitly requests
# security from the server in order to upgrade a plain text connection
# to an encrypted one. Cannot be used in combination with implicit FTPS.
# Enter a boolean value (true or false). Press Enter for the default (false).
explicit_tls> Enter(直接回车)
# Edit advanced config?
# y) Yes
# n) No (default)
y/n> n
# Configuration complete.
# Options:
# - type: ftp
# - host: Your ip/host
# - user: Your user
# - pass: *** ENCRYPTED ***
# Keep this "Set your own name" remote?
# y) Yes this is OK (default)
# e) Edit this remote
# d) Delete this remote
y/e/d> y
# Current remotes:
# Name Type
# ==== ====
# Set your own name ftp
# e) Edit existing remote
# n) New remote
# d) Delete remote
# r) Rename remote
# c) Copy remote
# s) Set configuration password
# q) Quit config
e/n/d/r/c/s/q> q
编写rclone.conf
文件
配置文件在C:\Users\Administrator\AppData\Roaming\rclone\rclone.conf
,但是添加FTP
好像不适用,Rclone 应该会对密码进行加密。
使用sync
同步文件
sync
:将源文件同步到目标文件夹,仅修改目标文件夹。不会传输源和目标中相同的文件,比较标准为文件大小、修改时间或 MD5SUM。目标文件夹会被更新以匹配源文件夹,包括必要时删除文件(但不包括重复对象)。
同步命令
- 加入环境变量
rclone sync "C:\Users\xxxx" Set your own name: --progress --log-level INFO --log-file "C:\Users\rclone\cache\rclone.log"
rclone sync
:sync
表示同步操作,即将源和目标位置的内容对齐,目标位置将被更新以匹配源位置的文件(包括删除目标文件中没有在源文件夹中的内容)。"C:\Users\xxxx"
: 源目录,表示你要从这个目录同步文件。C:\Users\xxxx
是你本地计算机上的文件夹路径,其中xxxx
是一个示例,你应该根据自己的系统和用户替换成正确的路径。Set your own name:
: 目标位置的路径或云存储配置名称,其中的Set your own name
是设置的名字,:
不可省略。--progress
: 在命令执行时显示实时的进度条,帮助你看到同步过程中的详细信息,如传输的文件数、速度等。--log-level INFO
: 该参数设置日志的详细级别为INFO
,表示输出的信息将包括同步过程中的关键信息、警告和操作日志等。日志级别可以设置为不同的级别(例如DEBUG
、ERROR
、CRITICAL
等)。--log-file "C:\Users\rclone\cache\rclone.log"
: 指定日志文件的存储路径。日志会被写入到指定的文件中(在这个例子中是C:\Users\rclone\cache\rclone.log
),这样可以随时查看同步过程中的详细信息。
- 未加入环境变量
首先到 Rclone 所在文件夹,在目录栏输入cmd
,然后使用如下命令
rclone.exe sync "C:\Users\xxxx" Set your own name: --progress --log-level INFO --log-file "C:\Users\rclone\cache\rclone.log"
创建 sync.bat
文件
@echo off
rclone.exe sync "C:\Users\xxxx" Set your own name: --progress --log-level INFO --log-file "C:\Users\rclone\cache\rclone.log"
pause
@echo off
:关闭命令回显,使得命令窗口看起来更干净。pause
:在命令执行完成后,命令行窗口不会立即关闭,它会显示“按任意键继续”,这样你可以查看同步过程中的日志输出,直到按下任意键窗口才会关闭。