将test1中目录下所有文件同步到test2中
[root@DL580 tmp]# ls
test1 test2
[root@DL580 tmp]# cd test2
[root@DL580 test2]# ls
[root@DL580 test2]# touch 2
[root@DL580 test2]# cd ..
[root@DL580 tmp]# rsync -avz test1/ test2
sending incremental file list
./
1
sent 75 bytes received 34 bytes 218.00 bytes/sec
total size is 0 speedup is 0.00
[root@DL580 tmp]# cd test2
[root@DL580 test2]# ll
total 0
-rw-r--r-- 1 root root 0 Mar 20 16:13 1
-rw-r--r-- 1 root root 0 Mar 20 16:13 2
[root@DL580 test2]# cd ../test1
[root@DL580 test1]# ls
1
[root@DL580 test1]# ll
total 0
-rw-r--r-- 1 root root 0 Mar 20 16:13 1
将test1直接同步到test2
[root@DL580 tmp]# rsync -avz test1 test2
sending incremental file list
test1/
test1/1
sent 89 bytes received 35 bytes 248.00 bytes/sec
total size is 0 speedup is 0.00
[root@DL580 tmp]# cd test2
[root@DL580 test2]# ll
total 0
-rw-r--r-- 1 root root 0 Mar 20 16:13 1
-rw-r--r-- 1 root root 0 Mar 20 16:13 2
drwxr-xr-x 2 root root 14 Mar 20 16:13 test1
参数
-a选项是rsync里比较霸道的一个选项,因为你使用-a选项,就相当于使用了-rlptgoD这一坨选项
l软链接保留
p权限保留
r递归
g文件属组信息保留
o文件属主信息保留
D文件设备信息保留
t文件时间信息保留
v同步信息详细输出
z对备份的文件在传输时进行压缩处理