安裝和配置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