您的位置:首页 > 其它

Rsync的其他几个常见参数

2016-09-10 19:18 183 查看
                                                                     问题:Rsync的其他几个常见参数

1

-z        –compress              compress file data during the transfer

--compress-level=NUM    explicitly set compression level

--skip-compress=LIST    skip compressing files with suffix in LIST

压缩传输,如果网络带宽不够,那么应该压缩以后传输,消耗的当然是机器资源,但是如果内网传输的话,文件数量不是很多的话,这个参数不必要的。

2

--password-file=FILE

前面说过了,只有远端机器是rsync服务器,才能用这个参数

如果你以为个FILE写的是ssh 登陆的密码,那就大错特错了,不少人犯了这个错误。

3

–stats: Adds a little more output regarding the file transfer status.

4

–progress: shows the progress of each file transfer. Can be useful to know if you have large files being backup up.

                                                                        rsync后面跟着的参数

1.编写/root/shell/test.include文件

 代码如下复制代码
# cat /root/shell/test.include

js

css

2.rsync同步指定文件,目录

 代码如下复制代码
# rsync -nrv  --include-from=/root/shell/test.include --exclude=/* /var/www/test/public/ /tmp/test/public

-n, --dry-run               perform a trial run with no changes made  //干跑,光显示哪些文件目录会被rsync而不运行,用于测试非常方便

-r, --recursive             recurse into directories  //详细模式输出

-v, --verbose               increase verbosity  //对子目录以递归模式处理

参照网上写的,rsync -nrv --include-from=/root/shell/test.include --exclude=* /var/www/test/public/ /tmp/test/public,发现任何文件都没有同步。原来--exlucde=*是不行的,需要指定--exclude=/*。估计意思是指当前目录/var/www/test/public/下的所有文件目录。--exclude=*/则是指定当前目录/var/www/test/public/下的所有目录。

这里要注意/var/www/test/public/需要添加最后的/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: