Linux rsync 远程同步工具

标签: none

rsync 是一个常用的 Linux 应用程序, 用于文件同步。

它可以在本地计算机与远程计算机之间, 或者两个本地目录之间同步文件 (但不支持两台远程计算机之间的同步) 。它也可以当作文件复制工具, 替代 cpmv 命令。

它名称里面的 r 指的是 remote, rsync 其实就是"远程同步" (remote sync) 的意思。与其他文件传输工具 (如 FTP 或 scp) 不同, rsync 的最大特点是会检查发送方和接收方已有的文件, 仅传输有变动的部分 (默认规则是文件大小或修改时间有变动) 。

rsync 基本特点

  • 可以镜像保存整个目录树和文件系统
  • 可以很容易做到保持原来文件的权限、时间、软硬链接等
  • 无须特殊权限即可安装
  • 优化的流程, 文件传输效率高
  • 可以使用 rcp、ssh 等方式来传输文件, 当然也可以通过直接的 socket 连接
  • 支持匿名传输

安装

注意, 传输的双方都必须安装 rsync。

# Debian
sudo apt-get install rsync

# Red Hat
sudo yum install rsync

# Arch Linux
sudo pacman -S rsync

配置文件

mkdir -p ~/.config/rsync
touch ~/.config/rsync/rsyncd.conf
touch ~/.config/rsync/rsyncd.passwd
chmod 600 ~/.config/rsync/rsyncd.passwd

vim ~/.config/rsync/rsyncd.conf

rsyncd.conf 服务端

此配置适用 root 用户运行

# /etc/rsyncd: configuration file for rsync daemon mode
# See rsyncd.conf man page for more options.
# configuration example:

uid=root                                    #以指定的UID传输文件
gid=root                                    #以指定的GID传输文件
#use chroot=yes                              
#max connections=10                          #允许的最大连接数
pid file=/var/run/rsyncd.pid                #指定pid文件路径
lock file=/var/run/rsync.lock               #指定进程锁文件
log file=/home/user/.config/rsync/rsyncd.log     #指定日志路径
# exclude = lost+found/
# transfer logging = yes
timeout=600                                 #连接超时时间
# ignore nonreadable = yes
# dont compress   = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2
#hosts allow=10.50.53.100                   #允许指定主机访问
#hosts deny=0.0.0.0/32                      #阻止指定主机访问
port=5000                                   #指定tcp端口

[backup] //模块名称(客户端访问指定)
path=/data //模块目录
comment=rsync files //描述信息, 可以任意填写
read only=no

list=yes
auth users=root //认证的用户, 服务器必须存在这个系统用户
secrets file=/home/user/.config/rsync/rsyncd.passwd

普通用户快速启动

普通用户需要将 uidgid 删除, 否则会报错 setgroups failed: Operation not permitted
use chroot 必须设置为 no, 否则会报错 rsync: chroot /path failed: Operation not permitted (1)

$ vim ~/.config/rsync/rsyncd.conf
use chroot=no
max connections=640
lock file=/home/user/.config/rsync/rsync.lock
log file=/home/user/.config/rsync/rsyncd.log
timeout=600
port=5000

[user]
path=/home/user/data/
comment=rsync files
read only=no
list=yes

普通用户启动服务端

$ rsync --daemon --config=/home/user/.config/rsync/rsyncd.conf

普通客户端命令

# 列出目录列表
$ rsync --list-only --port=5000 sub.example.com::user

# 客户端数据和服务器端数据保持一致
$ rsync -avzP --delete --port=5000 sub.example.com::user .

$ rsync -av --progress user@sub.example.com:/home/user/ /home/user/

root 客户端命令

# 设置 (文件夹 770) 和 (文件 660) 权限, 并且设置所有者为 qaq. 文件权限要 -p 参数, 所有者要 -go 参数
# rsync -rptgo --chmod=Du=rwx,Dg=rwx,Do=,Fu=rw,Fg=rw,Fo= --chown=qaq:qaq --progress user@sub.example.com:data/directory/ ./directory/

rsyncd.passwd 服务端

用户名: root
密码: 51522zzwlwlbb (已加入字典)

[root@centos7 ~]#  vim ~/.config/rsync/rsyncd.passwd
root:51522zzwlwlbb

启动 rsync 服务端

rsync --daemon --config=/home/user/.config/rsync/rsyncd.conf

rsync 客户端配置

# 修改密码配置
vim ~/.config/rsync/rsyncd.passwd
输入用户密码

# 修改权限
chmod 600 ~/.config/rsync/rsyncd.passwd

rsync 客户端同步

# 把服务 10.121.215.48 中 root 文件夹中数据同步当前目录中
rsync -avzP root@10.121.215.48::backup .

# 客户端数据和服务器端数据保持一致
rsync -avzP --delete root@10.121.215.48::backup .

# 服务器端和客户端数据保持一致
rsync -avzP --delete . root@10.121.215.48::backup .

# 指定传输时候的密码文件, 密码文件权限 600
rsync -avzP --delete --password-file=/etc/rsyncd.pass  root@10.121.215.48::backup .

基本用法

-r 参数

本机使用 rsync 命令时, 可以作为 cpmv 命令的替代方法, 将源目录同步到目标目录。

rsync -r source destination

上面命令中, -r 表示递归, 即包含子目录。注意, -r 是必须的, 否则 rsync 运行不会成功。source 目录表示源目录, destination 表示目标目录。

如果有多个文件或目录需要同步, 可以写成下面这样。

rsync -r source1 source2 destination

上面命令中, source1source2 都会被同步到 destination 目录。

-a 参数

-a 参数可以替代 -r, 除了可以递归同步以外, 还可以同步元信息 (比如修改时间、权限等) 。由于 rsync 默认使用文件大小和修改时间决定文件是否需要更新, 所以 -a-r 更有用。下面的用法才是常见的写法。

rsync -a source destination

目标目录 destination 如果不存在, rsync 会自动创建。执行上面的命令后, 源目录 source 被完整地复制到了目标目录 destination 下面, 即形成了 destination/source 的目录结构。

如果只想同步源目录 source 里面的内容到目标目录 destination , 则需要在源目录后面加上斜杠。

rsync -a source/ destination

上面命令执行后, source 目录里面的内容, 就都被复制到了 destination 目录里面, 并不会在 destination 下面创建一个 source 子目录。

3.3 -n 参数

如果不确定 rsync 执行后会产生什么结果, 可以先用 -n--dry-run 参数模拟执行的结果。

rsync -anv source/ destination

上面命令中, -n 参数模拟命令执行的结果, 并不真的执行命令。-v 参数则是将结果输出到终端, 这样就可以看到哪些内容会被同步。

3.4 --delete 参数

默认情况下, rsync 只确保源目录的所有内容 (明确排除的文件除外) 都复制到目标目录。它不会使两个目录保持相同, 并且不会删除文件。如果要使得目标目录成为源目录的镜像副本, 则必须使用 --delete 参数, 这将删除只存在于目标目录、不存在于源目录的文件。

rsync -av --delete source/ destination

上面命令中, --delete 参数会使得 destination 成为 source 的一个镜像。

四、排除文件

4.1 --exclude 参数

有时, 我们希望同步时排除某些文件或目录, 这时可以用 --exclude 参数指定排除模式。

rsync -av --exclude='*.txt' source/ destination
# 或者
rsync -av --exclude '*.txt' source/ destination

上面命令排除了所有 TXT 文件。

注意, rsync 会同步以"点"开头的隐藏文件, 如果要排除隐藏文件, 可以这样写 --exclude=".*"

如果要排除某个目录里面的所有文件, 但不希望排除目录本身, 可以写成下面这样。

rsync -av --exclude 'dir1/*' source/ destination

多个排除模式, 可以用多个 --exclude 参数。

rsync -av --exclude 'file1.txt' --exclude 'dir1/*' source/ destination

多个排除模式也可以利用 Bash 的大扩号的扩展功能, 只用一个 --exclude 参数。

rsync -av --exclude={'file1.txt','dir1/*'} source/ destination

如果排除模式很多, 可以将它们写入一个文件, 每个模式一行, 然后用 --exclude-from 参数指定这个文件。

rsync -av --exclude-from='exclude-file.txt' source/ destination

4.2 --include 参数

--include 参数用来指定必须同步的文件模式, 往往与 --exclude 结合使用。

rsync -av --include='*.txt' --include='*/' --exclude='*' source/ destination

rsync -avzP --include='*.txt' --include='data/' --exclude='*' user@sub.example.com:/home/user/data .

rsync -avzP --include='source*' --exclude='*' user@sub.example.com:/home/user/data/ . --list-only

上面命令指定同步时, 排除所有文件, 但是会包括 TXT 文件。

五、远程同步

5.1 SSH 协议

rsync 除了支持本地两个目录之间的同步, 也支持远程同步。它可以将本地内容, 同步到远程服务器。

rsync -av source/ username@remote_host:destination

也可以将远程内容同步到本地。

rsync -av username@remote_host:source/ destination

rsync 默认使用 SSH 进行远程登录和数据传输。

由于早期 rsync 不使用 SSH 协议, 需要用 -e 参数指定协议, 后来才改的。所以, 下面 -e ssh 可以省略。

rsync -av -e ssh source/ user@remote_host:/destination

但是, 如果 ssh 命令有附加的参数, 则必须使用 -e 参数指定所要执行的 SSH 命令。

rsync -av -e 'ssh -p 2234' source/ user@remote_host:/destination

上面命令中, -e 参数指定 SSH 使用2234端口。

5.2 rsync 协议

除了使用 SSH, 如果另一台服务器安装并运行了 rsync 守护程序, 则也可以用 rsync:// 协议 (默认端口87) 进行传输。具体写法是服务器与目标目录之间使用双冒号分隔 ::

rsync -av source/ 192.168.122.32::module/destination

注意, 上面地址中的 module 并不是实际路径名, 而是 rsync 守护程序指定的一个资源名, 由管理员分配。

如果想知道 rsync 守护程序分配的所有 module 列表, 可以执行下面命令。

rsync rsync://192.168.122.32

rsync 协议除了使用双冒号, 也可以直接用 rsync:// 协议指定地址。

rsync -av source/ rsync://192.168.122.32/module/destination

六、增量备份

rsync 的最大特点就是它可以完成增量备份, 也就是默认只复制有变动的文件。

除了源目录与目标目录直接比较, rsync 还支持使用基准目录, 即将源目录与基准目录之间变动的部分, 同步到目标目录。

具体做法是, 第一次同步是全量备份, 所有文件在基准目录里面同步一份。以后每一次同步都是增量备份, 只同步源目录与基准目录之间有变动的部分, 将这部分保存在一个新的目标目录。这个新的目标目录之中, 也是包含所有文件, 但实际上, 只有那些变动过的文件是存在于该目录, 其他没有变动的文件都是指向基准目录文件的硬链接。

--link-dest 参数用来指定同步时的基准目录。

rsync -a --delete --link-dest /compare/path /source/path /target/path

上面命令中, --link-dest参数指定基准目录 /compare/path , 然后源目录 /source/path 跟基准目录进行比较, 找出变动的文件, 将它们拷贝到目标目录 /target/path 。那些没变动的文件则会生成硬链接。这个命令的第一次备份时是全量备份, 后面就都是增量备份了。

下面是一个脚本示例, 备份用户的主目录。

#!/bin/bash

# A script to perform incremental backups using rsync

set -o errexit
set -o nounset
set -o pipefail

readonly SOURCE_DIR="${HOME}"
readonly BACKUP_DIR="/mnt/data/backups"
readonly DATETIME="$(date '+%Y-%m-%d_%H:%M:%S')"
readonly BACKUP_PATH="${BACKUP_DIR}/${DATETIME}"
readonly LATEST_LINK="${BACKUP_DIR}/latest"

mkdir -p "${BACKUP_DIR}"

rsync -av --delete \
  "${SOURCE_DIR}/" \
  --link-dest "${LATEST_LINK}" \
  --exclude=".cache" \
  "${BACKUP_PATH}"

rm -rf "${LATEST_LINK}"
ln -s "${BACKUP_PATH}" "${LATEST_LINK}"

上面脚本中,每一次同步都会生成一个新目录 ${BACKUP_DIR}/${DATETIME} ,并将软链接 ${BACKUP_DIR}/latest 指向这个目录。下一次备份时,就将 ${BACKUP_DIR}/latest 作为基准目录,生成新的备份目录。最后,再将软链接 ${BACKUP_DIR}/latest 指向新的备份目录。

七、配置项

-v, --verbose                           详细模式输出, -vv表示输出更详细的信息, -vvv表示输出最详细的信息。
-q, --quiet                             精简输出模式
-c, --checksum                          改变rsync的校验方式。默认情况下, rsync 只检查文件的大小和最后修改日期是否发生变化, 如果发生变化, 就重新传输; 使用这个参数以后, 则通过判断文件内容的校验和, 决定是否重新传输。
-a, --archive                           归档模式, 保存所有的元数据, 比如修改时间、权限、所有者等, 并且软链接也会同步过去, 等于-rlptgoD
--append                                文件接着上次中断的地方, 继续传输。
--append-verify                         跟 --append 参数类似, 但会对传输完成后的文件进行一次校验。如果校验失败, 将重新发送整个文件。
-r, --recursive                         对子目录以递归模式处理, 即包含子目录。
-R, --relative                          使用相对路径信息
-b, --backup                            创建备份, 也就是对于目的已经存在有同样的文件名时, 将老的文件重新命名为 ~filename。更名规则是添加由--suffix 选项来指定不同的备份文件前缀, 默认是 ~
--backup-dir                            指定文件备份时存放的目录 比如 /path/to/backups/~filename 存放在在目录下。
--suffix=SUFFIX                         指定文件名备份时, 对文件名添加的后缀, 默认是 ~
-u, --update                            同步时跳过目标目录上修改时间较新的文件
-l, --links                             保留软链结
--link-dest                             指定增量备份的基准目录
-L, --copy-links                        想对待常规文件一样处理软链结
--copy-unsafe-links                     仅仅拷贝指向SRC路径目录树以外的链结
--safe-links                            忽略指向SRC路径目录树以外的链结
-H, --hard-links                        保留硬链结
-p, --perms                             保持文件权限
-o, --owner                             保持文件属主信息
-g, --group                             保持文件属组信息
-D, --devices                           保持设备文件信息
-t, --times                             保持文件时间信息
-S, --sparse                            对稀疏文件进行特殊处理以节省DST的空间
-n, --dry-run                           模拟将要执行的操作, 而并不真的执行。配合 -v 参数使用, 可以看到哪些内容会被同步过去
-W, --whole-file                        拷贝文件, 不进行增量检测
-x, --one-file-system                   不要跨越文件系统边界
-B, --block-size=SIZE                   检验算法使用的块尺寸, 默认是700字节
-e, --rsh=COMMAND                       指定使用rsh、ssh 协议传输数据
--rsync-path=PATH                       指定远程服务器上的rsync命令所在路径信息
-C, --cvs-exclude                       使用和CVS一样的方法自动忽略文件, 用来排除那些不希望传输的文件
--existing, --ignore-non-existing       仅已经存在于目标目录的文件, 不同步目标目录中不存在的文件和目录
--delete                                删除只存在于目标目录、不存在于源目标的文件, 保证目标目录是源目标的镜像。
--delete-excluded                       同样删除接收端那些被该选项指定排除的文件
--delete-after                          传输结束以后再删除
--ignore-errors                         及时出现IO错误也进行删除
--ignore-existing                       只要该文件在目标目录中已经存在, 就跳过去, 不再同步这些文件。
-m                                      不同步空目录
--max-size                              参数设置传输的最大文件的大小限制, 比如不超过200KB (--max-size='200k')
--min-size                              参数设置传输的最小文件的大小限制, 比如不小于10KB (--min-size=10k)
--max-delete=NUM                        最多删除NUM个文件
--partial                               允许恢复中断的传输。不使用该参数时, rsync会删除传输到一半被打断的文件, 使用该参数后, 传输到一半的文件也会同步到目标目录, 下次同步时再恢复中断的传输。一般需要与 --append 或 --append-verify 配合使用
--partial-dir                           指定将传输到一半的文件保存到一个临时目录, 比如 --partial-dir=.rsync-partial。一般需要与 --append 或 --append-verify 配合使用
--progress                              在传输时显示传输过程
-P                                      是 --progress 和 --partial 这两个参数的结合
--force                                 强制删除目录, 即使不为空
--numeric-ids                           不将数字的用户和组ID匹配为用户名和组名
--timeout=TIME                          IP超时时间, 单位为秒
-I, --ignore-times                      不跳过那些有同样的时间和长度的文件
-i                                      输出源目录与目标目录之间文件差异的详细情况
--size-only                             表示只同步大小有变化的文件, 不考虑文件修改时间的差异。
--modify-window=NUM                     决定文件是否时间相同时使用的时间戳窗口, 默认为0
-T --temp-dir=DIR                       在DIR中创建临时文件
--compare-dest=DIR                      同样比较DIR中的文件来决定是否需要备份
-z, --compress                          对备份的文件在传输时进行压缩处理
--exclude=PATTERN                       排除不进行同步的文件, 比如--exclude="*.iso"。
--include=PATTERN                       同步时要包括的文件, 一般与--exclude结合使用
--exclude-from=FILE                     指定一个本地文件, 里面是需要排除的文件模式, 每个模式一行。
--include-from=FILE                     不排除FILE指定模式匹配的文件
--version                               打印版本信息
--address                               绑定到特定的地址
--config=FILE                           指定其他的配置文件, 不使用默认的rsyncd.conf文件
--port=PORT                             指定其他的rsync服务端口
--blocking-io                           对远程shell使用阻塞IO
-stats                                  给出某些文件的传输状态
--log-format=formAT                     指定日志文件格式
--password-file=FILE                    从FILE中得到密码
--bwlimit=KBPS                          带宽限制, 默认单位是 KB/s, 比如 --bwlimit=100。
--remove-source-files                   传输成功后, 删除发送方的文件。
-h, --human-readable                    以人类可读的格式输出
-h, --help                              显示帮助信息 (-h 单独使用时显示帮助)
[root@centos7 ~]# rsync -h
rsync  version 3.1.2  protocol version 31
Copyright (C) 1996-2015 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
    socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
    append, ACLs, xattrs, iconv, symtimes, prealloc

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.

rsync is a file transfer program capable of efficient remote update
via a fast differencing algorithm.

Usage: rsync [OPTION]... SRC [SRC]... DEST
  or   rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST
  or   rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST
  or   rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST
  or   rsync [OPTION]... [USER@]HOST:SRC [DEST]
  or   rsync [OPTION]... [USER@]HOST::SRC [DEST]
  or   rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]
The ':' usages connect via remote shell, while '::' & 'rsync://' usages connect
to an rsync daemon, and require SRC or DEST to start with a module name.

Options
 -v, --verbose               increase verbosity
     --info=FLAGS            fine-grained informational verbosity
     --debug=FLAGS           fine-grained debug verbosity
     --msgs2stderr           special output handling for debugging
 -q, --quiet                 suppress non-error messages
     --no-motd               suppress daemon-mode MOTD (see manpage caveat)
 -c, --checksum              skip based on checksum, not mod-time & size
 -a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)
     --no-OPTION             turn off an implied OPTION (e.g. --no-D)
 -r, --recursive             recurse into directories
 -R, --relative              use relative path names
     --no-implied-dirs       don't send implied dirs with --relative
 -b, --backup                make backups (see --suffix & --backup-dir)
     --backup-dir=DIR        make backups into hierarchy based in DIR
     --suffix=SUFFIX         set backup suffix (default ~ w/o --backup-dir)
 -u, --update                skip files that are newer on the receiver
     --inplace               update destination files in-place (SEE MAN PAGE)
     --append                append data onto shorter files
     --append-verify         like --append, but with old data in file checksum
 -d, --dirs                  transfer directories without recursing
 -l, --links                 copy symlinks as symlinks
 -L, --copy-links            transform symlink into referent file/dir
     --copy-unsafe-links     only "unsafe" symlinks are transformed
     --safe-links            ignore symlinks that point outside the source tree
     --munge-links           munge symlinks to make them safer (but unusable)
 -k, --copy-dirlinks         transform symlink to a dir into referent dir
 -K, --keep-dirlinks         treat symlinked dir on receiver as dir
 -H, --hard-links            preserve hard links
 -p, --perms                 preserve permissions
 -E, --executability         preserve the file's executability
     --chmod=CHMOD           affect file and/or directory permissions
 -A, --acls                  preserve ACLs (implies --perms)
 -X, --xattrs                preserve extended attributes
 -o, --owner                 preserve owner (super-user only)
 -g, --group                 preserve group
     --devices               preserve device files (super-user only)
     --copy-devices          copy device contents as regular file
     --specials              preserve special files
 -D                          same as --devices --specials
 -t, --times                 preserve modification times
 -O, --omit-dir-times        omit directories from --times
 -J, --omit-link-times       omit symlinks from --times
     --super                 receiver attempts super-user activities
     --fake-super            store/recover privileged attrs using xattrs
 -S, --sparse                handle sparse files efficiently
     --preallocate           allocate dest files before writing them
 -n, --dry-run               perform a trial run with no changes made
 -W, --whole-file            copy files whole (without delta-xfer algorithm)
 -x, --one-file-system       don't cross filesystem boundaries
 -B, --block-size=SIZE       force a fixed checksum block-size
 -e, --rsh=COMMAND           specify the remote shell to use
     --rsync-path=PROGRAM    specify the rsync to run on the remote machine
     --existing              skip creating new files on receiver
     --ignore-existing       skip updating files that already exist on receiver
     --remove-source-files   sender removes synchronized files (non-dirs)
     --del                   an alias for --delete-during
     --delete                delete extraneous files from destination dirs
     --delete-before         receiver deletes before transfer, not during
     --delete-during         receiver deletes during the transfer
     --delete-delay          find deletions during, delete after
     --delete-after          receiver deletes after transfer, not during
     --delete-excluded       also delete excluded files from destination dirs
     --ignore-missing-args   ignore missing source args without error
     --delete-missing-args   delete missing source args from destination
     --ignore-errors         delete even if there are I/O errors
     --force                 force deletion of directories even if not empty
     --max-delete=NUM        don't delete more than NUM files
     --max-size=SIZE         don't transfer any file larger than SIZE
     --min-size=SIZE         don't transfer any file smaller than SIZE
     --partial               keep partially transferred files
     --partial-dir=DIR       put a partially transferred file into DIR
     --delay-updates         put all updated files into place at transfer's end
 -m, --prune-empty-dirs      prune empty directory chains from the file-list
     --numeric-ids           don't map uid/gid values by user/group name
     --usermap=STRING        custom username mapping
     --groupmap=STRING       custom groupname mapping
     --chown=USER:GROUP      simple username/groupname mapping
     --timeout=SECONDS       set I/O timeout in seconds
     --contimeout=SECONDS    set daemon connection timeout in seconds
 -I, --ignore-times          don't skip files that match in size and mod-time
 -M, --remote-option=OPTION  send OPTION to the remote side only
     --size-only             skip files that match in size
     --modify-window=NUM     compare mod-times with reduced accuracy
 -T, --temp-dir=DIR          create temporary files in directory DIR
 -y, --fuzzy                 find similar file for basis if no dest file
     --compare-dest=DIR      also compare destination files relative to DIR
     --copy-dest=DIR         ... and include copies of unchanged files
     --link-dest=DIR         hardlink to files in DIR when unchanged
 -z, --compress              compress file data during the transfer
     --compress-level=NUM    explicitly set compression level
     --skip-compress=LIST    skip compressing files with a suffix in LIST
 -C, --cvs-exclude           auto-ignore files the same way CVS does
 -f, --filter=RULE           add a file-filtering RULE
 -F                          same as --filter='dir-merge /.rsync-filter'
                             repeated: --filter='- .rsync-filter'
     --exclude=PATTERN       exclude files matching PATTERN
     --exclude-from=FILE     read exclude patterns from FILE
     --include=PATTERN       don't exclude files matching PATTERN
     --include-from=FILE     read include patterns from FILE
     --files-from=FILE       read list of source-file names from FILE
 -0, --from0                 all *-from/filter files are delimited by 0s
 -s, --protect-args          no space-splitting; only wildcard special-chars
     --address=ADDRESS       bind address for outgoing socket to daemon
     --port=PORT             specify double-colon alternate port number
     --sockopts=OPTIONS      specify custom TCP options
     --blocking-io           use blocking I/O for the remote shell
     --stats                 give some file-transfer stats
 -8, --8-bit-output          leave high-bit chars unescaped in output
 -h, --human-readable        output numbers in a human-readable format
     --progress              show progress during transfer
 -P                          same as --partial --progress
 -i, --itemize-changes       output a change-summary for all updates
     --out-format=FORMAT     output updates using the specified FORMAT
     --log-file=FILE         log what we're doing to the specified FILE
     --log-file-format=FMT   log updates using the specified FMT
     --password-file=FILE    read daemon-access password from FILE
     --list-only             list the files instead of copying them
     --bwlimit=RATE          limit socket I/O bandwidth
     --outbuf=N|L|B          set output buffering to None, Line, or Block
     --write-batch=FILE      write a batched update to FILE
     --only-write-batch=FILE like --write-batch but w/o updating destination
     --read-batch=FILE       read a batched update from FILE
     --protocol=NUM          force an older protocol version to be used
     --iconv=CONVERT_SPEC    request charset conversion of filenames
     --checksum-seed=NUM     set block/file checksum seed (advanced)
 -4, --ipv4                  prefer IPv4
 -6, --ipv6                  prefer IPv6
     --version               print version number
(-h) --help                  show this help (-h is --help only if used alone)

Use "rsync --daemon --help" to see the daemon-mode command-line options.
Please see the rsync(1) and rsyncd.conf(5) man pages for full documentation.
See http://rsync.samba.org/ for updates, bug reports, and answers

rsync 用法教程
Rsync command issues, owner and group permissions doesn´t change
How to change the owner for a rsync
How to set file/folder permissions using Rsync from Windows to Linux


扫描二维码,在手机上阅读!

添加新评论