技术改变生活

博客园 首页 新随笔 联系 订阅 管理

rsync是由xinetd服务管理,需要安装xinetd

[root@x112 ~]# yum install -y xinetd

[root@x112 ~]# ps -ef| grep xin
root       1269   1157  0 10:02 pts/0    00:00:00 grep --color=auto xin
[root@x112 ~]# 
[root@x112 ~]# systemctl start xinetd
[root@x112 ~]# ps -ef| grep xin
root       1277      1  0 10:02 ?        00:00:00 /usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid
root       1279   1157  0 10:02 pts/0    00:00:00 grep --color=auto xin

[root@x112 ~]# netstat -antup | grep 873
[root@x112 ~]# netstat -antup | grep xin
[root@x112 ~]# 

[root@x112 ~]# rsync --daemon
[root@x112 ~]# netstat -antup | grep 873
tcp        0      0 0.0.0.0:873             0.0.0.0:*               LISTEN      1290/rsync         
tcp6       0      0 :::873                  :::*                    LISTEN      1290/rsync         
[root@x112 ~]# vim /etc/rsyncd.conf
[root@x112 ~]# rsync --version
rsync  version 3.1.2  protocol version 31
Copyright (C) 1996-2015 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:

 rsync使用系统账号传送文件

[root@x112 ~]# rsync -avz --delete /var/www/html  get1@192.168.0.170:/web1

 

 

rsync使用非系统账号传送文件:,需要编辑/etc/rsyncd.conf文件

/etc/rsyncd.conf文件,在启动rsync --daemon后就会自动生成。

 

 

使用rsync借助ssh无口令登陆远程备份到rsync服务器指定目录

[root@x111 software]# ssh-keygen -t rsa
[root@x111 software]# ssh-copy-id  -i .ssh/id_rsa.pub 192.168.0.112
[root@x112 software]# rsync -e ssh -avz nginx-1.14.2 192.168.0.101:/home/webserver
[root@x112 software]# rsync -e ssh -avz Discuz_7.2_FULL_SC_UTF8.zip root@192.168.0.101:/home/webserver

  

rsync后台传输文件

[root@x112 ~]# nohup  rsync  -avzP  /var/www/html/   user1@192.168.0.111:/backup/
[root@x112 ~]# 
输入完密码后,ctrl+z,然后再bg后台启动即可。

  

 

  

posted on 2020-07-21 10:51  小阿峰  阅读(165)  评论(0编辑  收藏  举报