rsync具体同步参数的使用介绍

简介:

rsync具体参数的使用

4.1Rsync指定同步文件和目录进行同步

测试演示:

1指定多个文件和目录进行同步

参数:--files-from

--files-from="/tmp/list.txt"

[root@zabbix-server mh.com]# cat /tmp/list.txt

scripts

plus

e/action/

以上都是目录

[root@zabbix-server mh.com]# /usr/bin/rsync -avrz--files-from="/tmp/list.txt" /home/wwwroot/mh.com/  tongbu_user@10.0.0.11::mhttongbu3--password-file=/etc/passwd.txt

sending incremental file list

e/

e/action/

e/action/2.php

e/action/23.php

e/action/3.php

plus/

plus/4.php

plus/5.php

scripts/

scripts/.js

scripts/1.js

scripts/2.js

scripts/3.js

scripts/4.js

scripts/5.js

sent 753 bytes received 233 bytes  1972.00bytes/sec

total size is 59 speedup is 0.06

 

文件和目录同时写入文件列表进行同步

[root@zabbix-server mh.com]# cat/tmp/list.txt

scripts

plus

e/action/

21.html

230.html

c.html

提示:文件列表不支持*.html格式的文件名

[root@zabbix-server mh.com]# /usr/bin/rsync -avrz--files-from="/tmp/list.txt" /home/wwwroot/mh.com/  tongbu_user@10.0.0.11::mhttongbu3--password-file=/etc/passwd.txt

 

sending incremental file list

21.html

230.html

c.html

e/

e/action/

e/action/2.php

e/action/23.php

e/action/3.php

plus/

plus/4.php

plus/5.php

scripts/

scripts/.js

scripts/1.js

scripts/2.js

scripts/3.js

scripts/4.js

scripts/5.js

 

sent 931 bytes received 290 bytes  814.00bytes/sec

total size is 65 speedup is 0.05

 

4.2rsync使用--include参数与--exclude参数来实现同步指定目录,并且--exclude目录放在后面。

演示:

参数:--include 结合参数exclude

只想同步plus 和scripts这两个目录,其他的不同步。

[root@zabbix-server mh.com]#/usr/bin/rsync -avrz --include "plus/" --include "scripts"--exclude "/*" /home/wwwroot/mh.com/ tongbu_user@10.0.0.11::mhttongbu3 --password-file=/etc/passwd.txt

sending incremental file list

./

plus/

plus/4.php

plus/5.php

scripts/

scripts/.js

scripts/1.js

scripts/2.js

scripts/3.js

scripts/4.js

scripts/5.js

sent 533 bytes received 171 bytes  469.33bytes/sec

total size is 38 speedup is 0.05

解释:

include plus/include scripts/include “”包含了你要同步的目录exclude包含了其他不同步的目录用“/*”指定。

--exclude /* 除了--include同步的目录外,排除其他的目录

/home/wwwroot/mh.com/ 指本地要同步的目录,

tongbu_user@10.0.0.11::mhttongbu3指远程服务器上指定的目录

把本地的目录同步到远程服务器指定的目录下

mhttongbu3 为模块名称 tongbu_user同步的用户

 

4.3参数--exclude-from

--exclude-from指不同步那些目录

演示:

/usr/bin/rsync -avrz--exclude-from="/tmp/list.txt1" /home/wwwroot/mh.com/  tongbu_user@10.0.0.11::mhttongbu3--password-file=/etc/passwd.txt

sending incremental file list

./

21.html

230.html

30.html

c.html

lsd.html

q.html

test00001.html

test001

1/

13/

a34325/

adnc/

e/

 

[root@zabbix-server mh.com]# cat /tmp/list.txt1

plus

e/action

scripts

 

4.4参数--delete --exclude={a..f}.txt

客户端:rsync -avz --delete --exclude={a..f}.txt /tmp/rsync_backup@172.16.1.41::backup --password-file=/etc/rsync.password指定密码文件,这样界面就不提示数码了。可以自动完成操作。同时--exclude={a..f}.txt是选择性排除保留服务端的内容,防止客户端数据把服务端数据全替换掉。

 

5.rsync参数介绍

http://blog.csdn.net/stevenprime/article/details/7601261



 本文转自 wjw555 51CTO博客,原文链接:http://blog.51cto.com/wujianwei/1962468

相关文章
|
8月前
|
网络安全
rsync同步
rsync同步
|
算法 安全 Unix
|
监控 安全 数据安全/隐私保护
|
安全
Rsync远程同步配置
# rsync服务端配置 # 安装rsync软件包 yum -y install rsync # 生成rsyncd.
868 0
|
Web App开发 前端开发 JavaScript
|
监控 Shell 关系型数据库
|
网络安全 开发工具 vr&ar
|
网络安全 Shell 数据安全/隐私保护