rsync+ssh同步

查看远程主机192.168.1.102的 / 目录下有哪些子目录
[root@1 ~]# rsync root@192.168.1.102:/
root@192.168.1.102’s password:
dr-xr-xr-x 267 2018/08/26 18:39:19 .
-rw——- 118 2018/08/26 18:38:45 .bash_history
lrwxrwxrwx 7 2018/08/24 19:32:50 bin
lrwxrwxrwx 7 2018/08/24 19:32:50 lib
lrwxrwxrwx 9 2018/08/24 19:32:50 lib64
lrwxrwxrwx 8 2018/08/24 19:32:50 sbin
dr-xr-xr-x 4096 2018/08/24 19:38:46 boot
drwxr-xr-x 3220 2018/09/16 11:57:38 dev
drwxr-xr-x 6 2018/08/26 10:30:58 dvd
drwxr-xr-x 8192 2018/09/16 13:58:39 etc
drwxr-xr-x 6 2016/11/05 11:38:36 home
drwxr-xr-x 6 2016/11/05 11:38:36 media
drwxr-xr-x 17 2018/08/26 17:21:59 mnt
drwxr-xr-x 6 2016/11/05 11:38:36 opt
dr-xr-xr-x 0 2018/09/16 11:57:23 proc
dr-xr-x— 159 2018/08/28 18:25:41 root
drwxr-xr-x 740 2018/09/16 13:58:40 run
drwxr-xr-x 6 2016/11/05 11:38:36 srv
dr-xr-xr-x 0 2018/09/16 11:57:26 sys
drwxrwxrwt 4096 2018/09/16 13:58:40 tmp
drwxr-xr-x 155 2018/08/24 19:32:50 usr
drwxr-xr-x 278 2018/08/26 11:06:29 var
drwxr-xr-x 220 2018/08/26 10:39:26 yum

从远程主机下载/etc/passwd文件到当前目录
[root@1 ~]# ls
anaconda-ks.cfg a.txt b.txt c.txt nssw.txt test.txt

[root@1 ~]# rsync root@192.168.1.102:/etc/passwd ./
root@192.168.1.102’s password:

[root@1 ~]# ls
anaconda-ks.cfg a.txt b.txt c.txt nssw.txt passwd test.txt

将远程主机的/boot/目录同步为本地的/fromssh

查看远程主机/boot/目录下的内容
[root@1 ~]# rsync root@192.168.1.102:/boot/
root@192.168.1.102’s password:
dr-xr-xr-x 4096 2018/08/24 19:38:46 .
-rw-r–r– 166 2017/08/22 17:21:49 .vmlinuz-3.10.0-693.el7.x86_64.hmac
-rw——- 3228420 2017/08/22 17:21:47 System.map-3.10.0-693.el7.x86_64
-rw-r–r– 140894 2017/08/22 17:21:47 config-3.10.0-693.el7.x86_64
-rw——- 51370325 2018/08/24 19:36:50 initramfs-0-rescue-da6c331196374622b7777fc819774ae2.img
-rw——- 20930142 2018/08/24 19:38:46 initramfs-3.10.0-693.el7.x86_64.img
-rw-r–r– 611509 2018/08/24 19:34:13 initrd-plymouth.img
-rw-r–r– 293027 2017/08/22 17:24:03 symvers-3.10.0-693.el7.x86_64.gz
-rwxr-xr-x 5877760 2018/08/24 19:36:51 vmlinuz-0-rescue-da6c331196374622b7777fc819774ae2
-rwxr-xr-x 5877760 2017/08/22 17:21:49 vmlinuz-3.10.0-693.el7.x86_64
drwxr-xr-x 17 2018/08/24 19:32:49 efi
drwxr-xr-x 27 2018/08/24 19:33:20 grub
drwx—— 97 2018/08/24 19:38:46 grub2

没有/formssh目录
[root@1 ~]# ls /formssh
ls: cannot access /fromssh: No such file or directory

[root@1 ~]# rsync -a root@192.168.1.102:/boot/ /formssh/
root@192.168.1.102’s password:

[root@1 ~]# ls /fromssh
ls: cannot access /fromssh: No such file or directory

已经同步过来了
[root@1 ~]# ls /formssh
config-3.10.0-693.el7.x86_64
efi
grub
grub2
initramfs-0-rescue-da6c331196374622b7777fc819774ae2.img
initramfs-3.10.0-693.el7.x86_64.img
initrd-plymouth.img
symvers-3.10.0-693.el7.x86_64.gz
System.map-3.10.0-693.el7.x86_64
vmlinuz-0-rescue-da6c331196374622b7777fc819774ae2
vmlinuz-3.10.0-693.el7.x86_64

将本机的/etc目录同步到远程主机svr7的/opt/下

查看远程主机/opt/目录下的内容
[root@1 ~]# rsync root@192.168.1.102:/opt/
root@192.168.1.102’s password:
drwxr-xr-x 6 2016/11/05 11:38:36 .

查看本机/etc/目录的大小
[root@1 ~]# du -sh /etc/
34M /etc/

[root@1 ~]# rsync -a /etc/ root@192.168.1.102:/opt/
root@192.168.1.102’s password:

远程到192.168.1.102
[root@1 ~]# ssh root@192.168.1.102
root@192.168.1.102’s password:
Last login: Sun Sep 16 12:02:02 2018 from 192.168.1.254

查看192.168.1.102主机下/opt/目录大小
[root@2 ~]# du -sh /opt/
34M /opt/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值