欲存放的server:192.168.0.52
欲存放目錄:home/willlu/temp/

被備份server:192.168.0.51
被備份目錄:

一.查看873port是否在LIST的狀態
# netstat -tnlp | grep 873

二.若無,開873port
# vi /etc/sysconfig/iptables
加入以下兩行:
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 873 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 873 -j ACCEPT

三.安裝rsync
1.使用yum
# yum install rsync
2.使用rpm
# rpm -ivh rsync*.rpm
3.使用configue
到rsync.samba.org下載
# ./configure && make && make install

四.設定 rsync server(192.168.0.52)
1.rsync設定
# vi /etc/xinetd.d/rsync
範本如下:
# default: off
# description: The rsync server is a good addition to am ftp server, as it \
# allows crc checksumming etc.
service rsync
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/local/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
2.使設定生效
# service xinetd restart, 使上述設定生效

3.設定被備份目錄
# vi /etc/rsyncd.conf
範例如下:
pid file = /var/run/rsyncd.pid
use chroot = no
#read only = yes
hosts allow=192.168.0.51
max connections = 5
motd file = /etc/rsyncd.motd
log file = /var/log/rsyncd.log
log format = %t %a %m %f %b
syslog facility = local3
timeout = 300
[test] <--識別名稱
path = /home/admin/temp/ <--欲存放目錄
auth users = admin <--驗證帳號
secrets file = /etc/rsyncd.secrets <--驗證密碼存放位置
read only = no
comment = rsync test <--註解
uid = root
gid = root

4.設定驗證密碼文件
# vi /etc/rsyncd.secrets
admin:admin <--帳號:對應密碼

5.儲存後設定密碼文件的讀取權限
# chown root.root /etc/rsyncd.secrets
# chmod 600 /etc/rsyncd.secrets

五.設定 rsync client(192.168.0.51)
1.設定驗證文件
# vi /root/rsyncd.secrets
admin <--對應server端rsync的test服務的密碼

2.儲存後設定密碼文件的讀取權限
# chown root.root /root/rsyncd.secrets
# chmod 600 /root/rsyncd.secrets

六.執行備份(此指令是將/home/admin/Content/下的所有檔案傳至server的/home/admin/temp/ )
格式:/usr/bin/rsync -rvlHpogDtS --password-file=(密碼檔存放位置) (欲備份的目錄) (rsync驗證帳號)@(欲存放的server位址)::(rsync的名稱)
範例:/usr/bin/rsync -rvlHpogDtS --password-file=/root/rsyncd.secrets /home/admin/Content/ admin@192.168.0.52::test

arrow
arrow
    全站熱搜

    Will(小威) 發表在 痞客邦 留言(0) 人氣()