1 系统信息
[root@rsync-30 elk]# cat /etc/redhat-release
CentOS release 6.8 (Final)
[root@rsync-30 elk]# uname -r
2.6.32-642.el6.x86_64
2 rsync 服务端daemon配置
#! /bin/bash
# function :rsync daemon config
function rsync_daemon_confing()
{
/usr/sbin/groupadd rsync
/usr/sbin/useradd rsync -s /sbin/nologin -M -g rsync
mkdir /soft/lnmp -p
mkdir /soft/elk -p
cat >/etc/rsyncd.conf <<EOF
##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
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
[lnmp]
path = /soft/lnmp
[elk]
path = /soft/elk
EOF
echo "rsync_backup:12356">/etc/rsync.password
chmod 600 /etc/rsync.password
rsync --daemon
}
3 rsync客户端配置
配置密码:
echo "123456">/etc/rsync.password
chmod 600 /etc/rsync.password
客户端拉文件:
rsync -avz rsync_backup@10.0.0.30::lnmp /data --password-file=/etc/rsync.password
推整个文件夹
rsync -avz /data rsync_backup@10.0.0.30::lnmp --password-file=/etc/rsync.password
推/data文件夹的内容
rsync -avz /data/ rsync_backup@10.0.0.30::lnmp --password-file=/etc/rsync.password