sent 279 bytes received 111 bytes 780.00 bytes/sec total size is 0 speedup is 0.00 [root@116v85v26v24 tmp]# ls /tmp/dir1/ file1 file2 file3 file4 file5 [root@116v85v26v24 tmp]# ls /tmp/dir2/ dir1 [root@116v85v26v24 tmp]# ls /tmp/dir2/dir1/ file1 file2 file3 file4 file5 [root@116v85v26v24 tmp]# rsync -va dir1/ dir2/ sending incremental file list ./ file1 file2 file3 file4 file5
sent 266 bytes received 110 bytes 752.00 bytes/sec total size is 0 speedup is 0.00 [root@116v85v26v24 tmp]# ls /tmp/dir2/ dir1 file1 file2 file3 file4 file5
[root@116v85v26v24 ~]# rsync -av /root/dir1 root@59.110.85.64:/root/dir/ //同步的命令 The authenticity of host '59.110.85.64 (59.110.85.64)' can't be establis RSA key fingerprint is 24:36:34:69:1f:6e:b7:60:b0:2a:ae:90:46:aa:86:c5. Are you sure you want to continue connecting (yes/no)? yes //key授权 Warning: Permanently added '59.110.85.64' (RSA) to the list of known hosts. root@59.110.85.64's password: //远端用户密码 sending incremental file list dir1/ dir1/file1 dir1/file2 dir1/file3 dir1/file4 dir1/file5
sent 279 bytes received 111 bytes 26.90 bytes/sec total size is 0 speedup is 0.00 [root@116v85v26v24 ~]#
sent 300 bytes received 115 bytes 26.77 bytes/sec total size is 0 speedup is 0.00
主机59.110.85.64
[root@59v110v85v64 ~]# pwd /root [root@59v110v85v64 ~]# ls anaconda-ks.cfg install.log software dir install.log.syslog testdir [root@59v110v85v64 ~]# cd dir [root@59v110v85v64 dir]# ls dir1 [root@59v110v85v64 dir]# //同步成功
sent 114 bytes received 305 bytes 25.39 bytes/sec total size is 0 speedup is 0.00 [root@116v85v26v24 ~]# ls /root anaconda-ks.cfg dir dir1 [root@116v85v26v24 ~]# //同步成功!
sent 110 bytes received 287 bytes 27.38 bytes/sec total size is 0 speedup is 0.00 [root@116v85v26v24 ~]# ls anaconda-ks.cfg install.log install.log.syslog testdir [root@116v85v26v24 ~]# cd testdir/ [root@116v85v26v24 testdir]# ls file1 file2 file3 file4 file5
//远端删除file1-file3 [root@59v110v85v64 testdir]# ls file1 file2 file3 file4 file5 [root@59v110v85v64 testdir]# rm file{2..4} rm: remove regular empty file `file2'? y rm: remove regular empty file `file3'? y rm: remove regular empty file `file4'? y [root@59v110v85v64 testdir]# ls file1 file5 //本地同步 [root@116v85v26v24 testdir]# rsync -avR --delete root@59.110.85.64:testdir /root/ root@59.110.85.64's password: receiving incremental file list deleting testdir/file4 deleting testdir/file3 deleting testdir/file2 testdir/
sent 15 bytes received 75 bytes 3.16 bytes/sec total size is 0 speedup is 0.00 [root@116v85v26v24 testdir]# ls file1 file5 [root@review1 testdir]# //加上--delete参数,源文件删除,本地也删除