Rsync远程同步配置

一,LinuxRsync設置

主服務端:192.168.1.1 linux

 

1.安裝Rsync服務端

Rpm –ivh rsync-2.6.8-3.1.rpm

2.修改rsync文件

Vi /etc/xined.d/rsync

service rsync

{

       disable = no  //需要修改的地方

        socket_type     = stream

        wait            = no

        user            = root

        server          = /usr/bin/rsync

        server_args     = --daemon

        log_on_failure  += USERID

}

3.添加配置文件rsyncd.conf

[root@server ~]# more /etc/rsyncd.conf

uid = nobody

gid = nobody

use chroot = no

max connections = 8

syslog facility = local5

pid file = /var/run/rsyncd.pid

hosts deny = 0.0.0.0/0.0.0.0

 

[ETC]    //模塊名稱

        hosts allow = 192.168.1.68 192.168.1.67 //設置訪問權限

        uid = root

        gid = root

        path = /backup/etc //模塊實際路徑

4.啟動Rsync服務

  /etc/init.d/xinetd  start

 

備份服務端:192.168.1.68Linux

1.編寫備份腳本

backup_etc 腳本如下:

#!/bin/bash

PATH="/bin:/usr/bin:/sbin"

ADMIN_USER="it_backup"

NOW=`date +%Y%m%d%t%T`

BACKUP_DATE="`date +%Y%m%d` - `date +%a`"

CURRENT_TIME=`date +%F-%H%M%S`

#TARGET_DOW=`date +%w`

TMP_LOG_FILE="/var/log/.backup_daily-${CURRENT_TIME}.log"

LOG_FILE="/var/log/backup_daily.log"

OPT=""

echo "" >  $TMP_LOG_FILE

echo "==================================================================="  >> $TMP_LOG_FILE

echo "Bash Script: " ${0}          >> $TMP_LOG_FILE

echo "Host.......: " ${HOSTNAME}   >> $TMP_LOG_FILE

 

SOURCE_DIR="rsync://192.168.1.1/ETC/"     //源路徑

TARGET_DIR="${1}/etc/"           //目的路徑

 

echo "Source Dir.: " ${SOURCE_DIR} >> $TMP_LOG_FILE

echo "Target Dir.: " ${TARGET_DIR} >> $TMP_LOG_FILE

echo "" >> $TMP_LOG_FILE

 

until rsync -avr --delete $OPT $SOURCE_DIR $TARGET_DIR >> $TMP_LOG_FILE

do

   echo "Another Try:  `date +%Y%m%d%t%T`" >> $TMP_LOG_FILE

   sleep 1m

done

 

echo "" >> $TMP_LOG_FILE

echo "Start......:  ${NOW}" >> $TMP_LOG_FILE

echo "End........:  `date +%Y%m%d%t%T`" >> $TMP_LOG_FILE

echo "==================================================================="  >> $TMP_LOG_FILE

 

mail -s "$0 - ${HOSTNAME} - ${BACKUP_DATE}" $ADMIN_USER < $TMP_LOG_FILE

 

#--- accumulate the log file

cat $LOG_FILE >> $TMP_LOG_FILE

cp -f $TMP_LOG_FILE $LOG_FILE  && rm -f $TMP_LOG_FILE

 

2.添加任務計劃

    #source: etc (192.168.1.1 /etc)

    00 23 * * *   /usr/local/script/backup_etc  /backup02/ > /dev/null

二,WindowsRsync設置

主服務端:192.168.1.15windows xp

1.安裝cwRsyncServer

2.配置rsyncd.conf

uid = 0

gid = 0

use chroot = false

strict modes = false

hosts allow = 192.168.1.68 //設置訪問權限

log file = rsyncd.log

# Module definitions

# Remember cygwin naming conventions : c:/work becomes /cygwin/c/work

#

[BAK]

path = /cygdrive/d/BakACM/BAK

read only = true

transfer logging = yes

 

備份服務器:192.168.1.68linux

 

同上,編寫執行計劃腳本,並修改相應源路徑和目的路徑即可。

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值