RSYNC的功能很强大:
不但能够增量同步文件和目录,而且还有很灵活的filter过滤功能;
man rsync 可以查看到相关的帮助文档:
FILTER RULES
exclude, - specifies an exclude pattern.
include, + specifies an include pattern.
merge, . specifies a merge-file to read for more rules.
dir-merge, : specifies a per-directory merge-file.
hide, H specifies a pattern for hiding files from the transfer.
show, S files that match the pattern are not hidden.
protect, P specifies a pattern for protecting files from deletion.
risk, R files that match the pattern are not protected.
clear, ! clears the current include/exclude list (takes no arg)
When rules are being read from a file, empty lines are ignored, as are comment lines that start with a "#".
在工作中我遇到了如下的情况:
公司服务器是放在外网/开发服务器是在公司的内部(svn服务器,开发测试环境等等)
公司内部带宽6M/adsl,下行速率是6M很爽/但是每次更新将源程序打包之后有10M左右/从内部上行的网速做大也只有60KB/s,一次更新需要10多分钟/很纠结
后来考虑到用rsync的增量更新的功能:
程序管理都是使用svn来保管源代码,每个svn的目录下面都有一个.svn的文件非常占用空间,
据说着rsync有强大的过滤功能,特意查看下rsync的手册:果然发现它默认可以过滤cvs
-C, --cvs-exclude auto-ignore files in the same way CVS does
那如何过滤.svn目录呢?
filter很强大,功能繁多,但是下面着一条能够完全满足我的需求了
--exclude='.svn/'
在内网执行如下命令:既可以增量更新文件。
rsync -avz --exclude='.svn/' --delete /home/web/development/www_dct Rsync_User@$121.121.121.121::Data_www --password-file=
/etc/rsyncd.pass
远程服务器上面运行rsync daemon,,
[Data_www]
uid = www-data
gid = www-data
path = /data/www/
use chroot = yes
read only = false
list = yes
auth users = Rsync_User
secrets file = /etc/rsyncd.ps
strict modes = yes
hosts allow = x.x.x.x
阅读(5559) | 评论(0) | 转发(1) |