安装和配置rsync
http://rsync.samba.org/bash
安装:tcp
tar -zxvf rsync-3.1.1.tar.gzcode
cd rsync-3.1.1
./configure --prefix=/usr/local/rsync --disable-ipv6
make
make installserver
ln -s /usr/local/rsync/bin/rsync /usr/bin/rsynccrontab
server端配置ip
pid file = /var/run/rsyncd.pid
port = 873
pid = root
gid = root
use chroot = no
max connections = 200
timeout 600
lock file = /var/run/rsyncd.lock
log file = /var/run/rsyncd.log
secrets file = /usr/local/rsync/rsyncd.passwd
motd file = /etc/rsyncd.motdrem
[test]
path = /test/
ignore errors
read only = true
list = false
hosts allow = *get
auth users = rsync #该用户系统中存在且对后面指定的备份目录拥有权限
comment = rsync from qklin同步
++++++++++++++++++++++++++++++++++++
Wlecome to qklin rsync services
++++++++++++++++++++++++++++++++++++io
--指定rsync访问的密码,密码不须要和系统帐号密码相同
rsync:rsyncpass
ln -s /usr/local/rsync/rsyncd.conf /etc/rsyncd.conf
ln -s /usr/local/rsync/rsyncd.motd /etc/rsyncd.motd
ln -s /usr/local/rsync/rsyncd.passwd /etc/rsyncd.passwd
chmod 600 /usr/local/rsync/rsyncd.passwd
chown root:root /usr/local/rsync/rsyncd.passwd
启动rsync
加入开机启动
检查是否加入成功开机启动
/usr/bin/rsync --daemon
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 10689/rsync
tcp 0 0 :::873 :::* LISTEN 10689/rsync
客户端配置
(1).新建客户端密码文件(客户端不带用户名)
rsyncpass
rsync -vzrtopg --progress --delete root@192.168.5.189::test /ocpyang/ --password-file=/etc/rsyncd.passwd
(3).新建同步脚本
#!/bin/bash rsync -vzrtopg --progress --delete root@192.168.5.189::test /testbak/ --password-file=/etc/rsyncd.passwd
(4).手动同步文件
(5).自动同步:每隔五分钟同步一次
0,5 /rsync.sh