配置
#vi /etc/rsyncd.conf # mkdir /etc/rsyncd # touch /etc/rsyncd/rsyncd.conf # ln -s /etc/rsyncd/rsyncd.conf /etc/rsyncd.conf # Minimal configuration file for rsync daemon # See rsync(1) and rsyncd.conf(5) man pages for help # This line is required by the /etc/init.d/rsyncd script # GLOBAL OPTIONS uid = root gid = root use chroot = no read only = yes #limit access to private LANs hosts allow=192.168.1.0/255.255.255.0 192.168.31.0/255.255.255.0 hosts deny=* max connections = 5 pid file = /var/run/rsyncd.pid secrets file = /etc/rsyncd/rsyncd.secrets #lock file = /var/run/rsync.lock motd file = /etc/rsyncd/rsyncd.motd #This will give you a separate log file log file = /var/log/rsync.log #This will log every file transferred - up to 85,000+ per user, per sync transfer logging = yes log format = %t %a %m %f %b syslog facility = local3 timeout = 300 # MODULE OPTIONS [mysql_databack] path = /opt/db-backup/ list=yes ignore errors auth users = mysql comment = mysql_databack
欢迎信息
#/etc/rsyncd/rsyncd.motd +++++++++++++++++++++++++++ + mysql databackp + +++++++++++++++++++++++++++
密码文件
#/etc/rsyncd/rsyncd.secrets #用户名:密码 mysql:databackup
添加为开机启动
echo "rsync --daemon " >> /etc/rc.local
客户端配置
定时同步文件
vi /etc/crontab 10 2 * * * rsync rsync -avzP --delete --password-file=/home/rsync/rsync.password [email protected]::mysql_databack /opt/mysql
#/home/rsync/rsync.password #只写密码 databackup