rsync --exclude files and folders http://articles.slicehost.com/2007/10/10/rsync-exclude-files-and-folders 很常见的情况:我想同步/下的 /usr /boot/ , 但是不想复制/proc /tmp 这些文件夹 如果想避开某个路径 直接添加--exclude 即可 比如--exclude “proc” --exclude ‘sources' Note: the directory path is relative to the folder you are backing up. 注意:这个路径必须是一个相对路径,不能是绝对路径
例子:源服务器/home/yjwan/bashshell有一个checkout文件夹 [root@CentOS5-4 bashshell]# ls -dl checkout drwxr-xr-x 2 root root 4096 Aug 21 09:14 checkou 现在想要完全避开复制这个文件夹内容怎么办? 目标服务器执行 rsync -av --exclude “checkout” yjwan@172.16.251.241:/home/yjwan/bashshell /tmp 将不会复制这个文件夹 [root@free /tmp/bashshell]# ls -d /tmp/bashshell/checkout ls: /tmp/bashshell/checkout: No such file or directory
问题: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.
关于这个参数:
I frequently find myself adding the -P option for large transfers. It preserves partial transfers in case of interuption, and gives a progress report on each file as it's being uploaded. I move large media files back and forth on my servers, so knowing how long the transfer has remaining is very useful. •Previous Entry: nginx 每天定时切割Nginx日志的脚本 •Next Entry: 如何开启MySQL的远程帐号