1、服务端
查看(系统基本都有安装)
rpm -qa rsync
安装软件
yum -y install rsync
配置rsync配置文件
cat >/etc/rsyncd.conf<<EOF 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 ignore errors read only = false list = false hosts allow = 192.168.1.0/24 hosts deny = 0.0.0.0/32 auth users = rsync_backup secrets file = /etc/rsync.password [backup] #comment = "backup dir by oldboy" path = /root/backup EOF
创建用户组,创建接受文件目录,授权,启动,加入开机自启动
useradd -s /sbin/nologin -M rsync mkdir -p /root/backup chown -R rsync.rsync /root/backup echo "rsync_backup:oldboy123" >/etc/rsync.password chmod 600 /etc/rsync.password rsync --daemon echo "rsync --daemon" >>/etc/rc.local
2、客户端
echo "oldboy123" >/etc/rsync.password chmod 600 /etc/rsync.password
3、客户端推送至服务端
rsync azvP /data rsync_backup@192.168.1.81::backup --password-file=/etc/rsync.password
4、客户端向服务端拉取操作
rsync azvP rsync_backup@192.168.1.80::backup /data/ --password-file=/etc/rsync.password