Linux---shell rsync

版权声明:本文虽为博主原创文章,但是,如果能有帮助的话,允许大家转载 https://blog.csdn.net/xinyuanqianxun1987/article/details/52850570

1. rsync Description:

DESCRIPTION
       rsync is a program that behaves in much the same way that rcp does, but
       has many more options and uses  the  rsync  remote-update  protocol  to
       greatly  speed  up  file  transfers  when the destination file is being
       updated.


       The rsync remote-update protocol allows rsync to transfer just the dif-
       ferences between two sets of files across the network connection, using
       an efficient  checksum-search  algorithm  described  in  the  technical
       report that accompanies this package.


2. use it

SYNOPSIS
       rsync [OPTION]... SRC [SRC]... DEST


       rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST


       rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST


       rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST


       rsync [OPTION]... SRC


       rsync [OPTION]... [USER@]HOST:SRC [DEST]


       rsync [OPTION]... [USER@]HOST::SRC [DEST]


       rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]

转自(http://www.jb51.net/LINUXjishu/66859.html)

1)拷贝本地文件。当SRC和DES路径信息都不包含有单个冒号":"分隔符时就启动这种工作模式。如:rsync -a /data /backup
  2)使用一个远程shell程序(如rsh、ssh)来实现将本地机器的内容拷贝到远程机器。当DST路径地址包含单个冒号":"分隔符时启动该模式。如:rsync -avz *.c foo:src
  3)使用一个远程shell程序(如rsh、ssh)来实现将远程机器的内容拷贝到本地机器。当SRC地址路径包含单个冒号":"分隔符时启动该模式。如:rsync -avz foo:src/bar /data
  4)从远程rsync服务器中拷贝文件到本地机。当SRC路径信息包含"::"分隔符时启动该模式。如:rsync -av [email protected]::www /databack
  5)从本地机器拷贝文件到远程rsync服务器中。当DST路径信息包含"::"分隔符时启动该模式。如:rsync -av /databack [email protected]::www
  6)列远程机的文件列表。这类似于rsync传输,不过只要在命令中省略掉本地机信息即可。如:rsync -v rsync://172.16.78.192/www 


example: rsync --rsh="$SSHOPTIONS" -zqrlHKpogt $rsyncBW --del --timeout=$rsyncTimeout $des_ip:$rsync_dir/ $rsync_dir

3. start up this process

转自:http://www.2cto.com/os/201109/104734.html

需要注意的是必须在服务器A和B上都安装rsync,其中A服务器上是以服务器模式运行rsync,而B上则以客户端方式运行rsync。这样在web服务器A上运行rsync守护进程,在B上定时运行客户程序来备份web服务器A上需要备份的内容。
   服务器端启动:
       usr/bin/rsync --daemon --config=/etc/rsyncd/rsyncd.conf
 
可能需要root权限运行.
 
/etc/rsyncd/rsyncd.conf 是你刚才编辑的rsyncd.conf的位置.
 
也可以在/etc/rc.d/rc.local里加入让系统自动启动等.
 
 客户端启动:
    rsync [OPTION] SRC [SRC] [USER@]HOST:DEST
  option:
  -a 参数,相当于-rlptgoD,-r 是递归 -l 是链接文件,意思是拷贝链接文件;-p 表示保持文件原有权限;-t 保持文件原有时间;-g 保持文件原有用户组;-o 保持文件原有属主;-D 相当于块设备文件;
 
-z 传输时压缩
 
-P 传输进度;
 
-v 传输时的进度等信息,和-P有点关系,自己试试。可以看文档;




猜你喜欢

转载自blog.csdn.net/xinyuanqianxun1987/article/details/52850570