Linux rsync 命令使用

来源:互联网 发布:java工程师学历要求 编辑:程序博客网 时间:2024/05/29 02:34
rsync命令是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件。rsync使用所谓的“rsync算法”来使本地和远程两个主机之间的文件达到同步,这个算法只传送两个文件的不同部分,而不是每次都整份传送,因此速度相当快。 rsync是一个功能非常强大的工具,其命令也有很多功能特色选项,我们下面就对它的选项一一进行分析说明。

具体的命令参数可以参看 http://man.linuxde.net/rsync 或者man rsync 

这里我们结合实际使用来看几个命令

rsync -av -f"+ */" -f"- *" /root/temp/nfs /root/temp/mybackup 是只备份 source /root/temp/nfs 下的目录。

rsync -av /root/temp/nfs /root/temp/mybackup 是备份 source /root/temp/nfs 下的所有文件。

    -f 后面跟的是过滤规则

           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  dele-
              tion.
              risk, R files that match the pattern are not protected.
              clear, ! clears the current include/exclude list (takes no arg)

 

原创粉丝点击