rsync命令
//Rsync的命令格式常用的有以下三种:
rsync [OPTION]… SRC DEST
rsync [OPTION]… SRC [USER@]HOST:DEST
rsync [OPTION]… [USER@]HOST:SRC DEST
//对应于以上三种命令格式,rsync有三种不同的工作模式:
1)拷贝本地文件。当SRC和DES路径信息都不包含有单个冒号":"分隔符时就启动这种工作模式。如:
[root@localhost ~]# ls
anaconda-ks.cfg nfs.sh
[root@localhost ~]# rsync -a nfs.sh a.sh
[root@localhost ~]# ll
total 12
-rw-------. 1 root root 1453 Jun 13 19:27 anaconda-ks.cfg
-rwxr-xr-x 1 root root 1041 Aug 8 18:14 a.sh
-rwxr-xr-x 1 root root 1041 Aug 8 18:14 nfs.sh
[root@localhost ~]# ll -i
total 12
33574978 -rw-------. 1 root root 1453 Jun 13 19:27 anaconda-ks.cfg
33574979 -rwxr-xr-x 1 root root 1041 Aug 8 18:14 a.sh
33574990 -rwxr-xr-x 1 root root 1041 Aug 8 18:14 nfs.sh
2)使用一个远程shell程序(如rsh、ssh)来实现将本地机器的内容拷贝到远程机器。当DST路径地址包
含单个冒号":"分隔符时启动该模式。如:
[root@localhost ~]# rsync -avz nfs.sh root@172.16.12.129:/root/b.sh
sending incremental file list
nfs.sh
sent 643 bytes received 35 bytes 1,356.00 bytes/sec
total size is 1,041 speedup is 1.54
[root@localhost ~]# ssh root@172.16.12.129 ‘ls -l /root’
total 8
-rw-------. 1 root root 1454 Aug 6 04:39 anaconda-ks.cfg
-rwxr-xr-x 1 root root 1041 Aug 8 2018 b.sh
3)使用一个远程shell程序(如rsh、ssh)来实现将远程机器的内容拷贝到本地机器。当SRC地址路径
包含单个冒号":"分隔符时启动该模式。如:
[root@localhost ~]# ls
anaconda-ks.cfg a.sh nfs.sh
[root@localhost ~]# rsync -avz root@172.16.1