Files
Linux/存储/NFS/Rsync常用参数解释.md
offends cee91802b3
Some checks failed
continuous-integration/drone Build is failing
synchronization
2025-08-25 15:57:40 +08:00

53 lines
5.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

> 本文作者:丁辉
# Rsync常用参数解释
## Rsync 常用参数解释
-avz这是一组选项分别代表
- `-a`:表示"归档"模式,用于保留文件的所有属性,包括权限、所有者、组、时间戳等等。
- `-v`:表示"详细"模式,用于在执行时显示更多详细信息。
- `-z`:表示启用压缩传输,将文件在传输过程中进行压缩,以减少网络带宽的使用。
- -P这是 --partial --progress 的缩写,启用了两个有用的选项:
- `--partial`:如果传输被中断,保留部分传输的文件,以便下次传输时可以继续。
- `--progress`:在终端显示传输进度信息,包括已传输的数据量和估计剩余时间。
- `-r`:递归复制子目录和文件。
- `--delete`:这个选项表示在目标目录中删除那些在源目录中不存在的文件。这意味着目标目录将与源目录保持同步,不会有多余的文件留在目标目录中。
## Rsync 配置文件参数
全局参数
| 参数 | 含义 | 写法 |
| :----------------: | :----------------------------------------------------------: | :--------------------------------------------------------: |
| uid | 指定Rsync进程中使用的用户的用户标识 | uid = nobody |
| gid | 指定Rsync进程中使用的用户组的组标识 | gid = nobody |
| timeout | 定义客户指定的 IP 超时时间 | timeout = 600 |
| transfer logging | 启用传输日志记录 | transfer logging = yes |
| ignore nonreadable | 告诉 Rsync 忽略无法读取的文件 | ignore nonreadable = yes |
| dont compress | 指定不需要进行压缩的文件类型列表 | dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2 |
| port | 指定守护进程监听的端口号 | port = 873 |
| log file | 指定守护进程的日志文件 | log file = /var/log/rsyncd.log |
| pid file | 指定 PID 写入文件路径和名称 | pid file = /var/run/rsyncd.pid |
| lock file | 指定锁文件的路径和名称 | lock file = /var/run/rsyncd.lock |
| max connections | 定义了可以同时处理的最大连接数 | max connections = 4 |
| list | 这个参数用于控制是否允许列出Rsync服务器上的文件和目录 | list = false |
| fake super | 当启用时Rsync会在备份文件的目标位置创建一个特殊的目录通常是`.rsync`),用于存储元数据和权限信息。这可以确保备份数据的权限等信息得以保留,即使目标位置的用户没有足够的权限 | fake super = yes |
| use | 控制是否启用chrootChange Root机制 | use chroot = no |
| ignore errors | 忽略错误 | ignore errors |
模块参数
| 参数 | 含义 | 写法 |
| :----------: | :---------------------------------------------------: | :----------------------------------: |
| path | Rsync服务器要同步的目录的路径 | path=/data |
| comment | 描述信息 | comment = backup data |
| hosts deny | 指定了一个IP地址范围不允许访问Rsync服务器的主机的IP地 | hosts deny = 192.168.1.0/24 |
| hosts allow | 指定了一个特定的IP地址允许访问Rsync服务器的主机的IP地 | hosts allow = 192.168.1.0/24 |
| auth users | 指定了哪个用户可以通过Rsync进行身份验证并访问服务器 | auth users = rsync |
| secrets file | Rsync服务器将使用这个文件来验证用户的身份 | secrets file = /etc/rsync_salve.pass |
| read only | 设置Rsync服务器的只读权限 | read only = no |
| exclude | 排除(不同步)的文件或文件夹的名称 | exclude=demo |