rsync

https://www.cnblogs.com/f-ck-need-u/p/7220009.html#auto_id_8

Local:  rsync [OPTION...] SRC... [DEST]
 
Access via remote shell:
  Pull: rsync [OPTION...] [USER@]HOST:SRC... [DEST]
  Push: rsync [OPTION...] SRC... [USER@]HOST:DEST
 
Access via rsync daemon:
  Pull: rsync [OPTION...] [USER@]HOST::SRC... [DEST]
        rsync [OPTION...] rsync://[USER@]HOST[:PORT]/SRC... [DEST]
  Push: rsync [OPTION...] SRC... [USER@]HOST::DEST
        rsync [OPTION...] SRC... rsync://[USER@]HOST[:PORT]/DEST

rsync daemon是"rsync --daemon"或再加上其他一些选项启动的,它会读取配置文件,默认是/etc/rsyncd.conf,并默认监听在873端口上,当外界有客户端对此端口发起连接请求,通过这个网络套接字就可以完成连接,以后与该客户端通信的所有数据都通过该网络套接字传输。

CentOS7启动 systemctl start rsyncd

#######################################################################
[root@xuexi ~]# cat /etc/rsyncd.conf
# /etc/rsyncd: configuration file for rsync daemon mode
 
# See rsyncd.conf man page for more options.
 
# configuration example:
 
# uid = nobody
# gid = nobody
# use chroot = yes
# max connections = 4
# pid file = /var/run/rsyncd.pid
# exclude = lost+found/
# transfer logging = yes
# timeout = 900
# ignore nonreadable = yes
# dont compress   = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2
 
# [ftp1]
#        path = /home/ftp
#        comment = ftp export area
####################################################################



rsync 10.41.15.187::dpool_data/machine-init/deploy_ssh_key.sh .
/data2/dpool_data
rsync -avz 10.41.15.187::dpool_data/tmp .


rsync -r /etc 172.16.10.5:/tmp

–delete

--delete    delete extraneous files from dest dirs

[root@as4k xtest]# ls test1/
hello.txt
[root@as4k xtest]# ls test2/
1.txt  2.txt  3.txt  4.txt  5.txt  hello.txt
[root@as4k xtest]# rsync -va --delete test1/ test2/
sending incremental file list
deleting 5.txt
deleting 4.txt
deleting 3.txt
deleting 2.txt
deleting 1.txt
./
hello.txt

sent 121 bytes  received 83 bytes  408.00 bytes/sec
total size is 7  speedup is 0.03
[root@as4k xtest]# ls test1
hello.txt
[root@as4k xtest]# ls test2
hello.txt