rsync服务搭建

服务器端配置

[root@localhost ~]# yum install -y rsync
[root@localhost ~]# rpm -qa rsync
[root@localhost ~]# vim /etc/rsyncd.conf
#rsyncd.conf start
uid = rsync
gid = rsync
use chroot = no
max connections = 200
timeout = 300
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
[Meo]               # 用组来区别不同的备份配置
path = /back        # 文件备份的位置
ignore errors
read only = false
list = false
hosts allow = 10.0.0.0/24
hosts deny = 0.0.0.0/32
auth users = rsync_backup#虚拟用户
secrets file = /etc/rsync.password
#rsync_config_______________end

[root@localhost ~]# useradd rsync -s /sbin/nologin -M
[root@localhost ~]# chown -R rsync.rsync /back          # /back文件的所属组和所属者改为rsync
[root@localhost ~]# chmod 755 /back
[root@localhost ~]# echo "rsync_backup:123457.ii" > /etc/rsync.password
[root@localhost ~]# chmod 600 /etc/rsync.password
[root@localhost ~]# systemctl start rsyncd

客户端配置

[root@localhost ~]# yum install -y rsync
[root@localhost ~]# rpm -qa rsync
[root@localhost ~]# echo "123457.ii">/etc/rsync.password

使用

免密下载pull:

​ 将配置块Meo指定路径下的文件同步到客户端

rsync -avz --password-file=/etc/rsyncd.secrets [email protected]::Meo /home

免密上传push:

​ 将etc下的hosts文件上传到配置块Meo指定的路径下

rsync -avz --password-file=/etc/rsyncd.secrets /etc/hosts \ [email protected]::Meo

你可能感兴趣的:(rsync服务搭建)