db / 未分类 · 2012年7月28日

rsync远程备份

第一 如果备份机没有www 就useradd www
vim /etc/rsyncd.conf
port 873
uid = nobody
gid = nobody
log file = /data/log/rsyncd.log
pid file = /var/run/rsyncd.pid
use chroot = yes
read only = ture
timeout = 999999
#lock file = /var/run/rsync.lock
list=yes
[frgdb]
path = /data/frgdb
comment = frgdb bakcup server
uid = www
gid = www
read only = false
secrets file = /usr/local/rsyncd/etc/passwd
auth users = frg
max connections = 50

第二
vim /etc/rsyncd.conf
###这个是启动文件
vim /etc/init.d/rsyncd
#!/bin/bash
# chkconfig: 2345 94 12
# description:Rsync Server
#RSYNC_HOME=/usr/bin/rsyncd
#RSYNC_HOME=/usr/local/rsyncd
RSYNC_BIN=/usr/bin/rsync
#RSYNC_BIN=$RSYNC_HOME/bin/rsync
RSYNC_CONF=/etc/rsyncd.conf
#RSYNC_CONF=$RSYNC_HOME/etc/rsyncd.conf
MAXFD=65535
APP_NAME="rsync"
. /etc/rc.d/init.d/functions
if [ ! -f $RSYNC_BIN ]
then
echo "$APP_NAME startup: $RSYNC_BIN not exists! "
exit
fi
start() {
ulimit -HSn $MAXFD
$RSYNC_BIN --daemon --config=$RSYNC_CONF
ret=$?
if [ $ret -eq 0 ]; then
action $"Starting $APP_NAME: " /bin/true
else
action $"Starting $APP_NAME: " /bin/false
fi
}
stop() {
[ ! -f /var/run/rsyncd.pid ] && echo " /var/run/rsyncd.pid not exists!" && exit 255
kill `cat /var/run/rsyncd.pid`
ret=$?
if [ $ret -eq 0 ]; then
action $"Stopping $APP_NAME: " /bin/true
else
action $"Stopping $APP_NAME: " /bin/false
fi
}
restart() {
stop
sleep 2
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac

第三 这里会自动 create /var/run/rsyncd.pid
/etc/init.d/rsyncd start
/data/frgdb/mysqlbk_cron/gamelabs/ ;chown -R www.www /data/frgdb/
############# 下面是测试 及一些解决 的解决方法
[root@frgdb_gamelabs 20120704]# /usr/bin/rsync -rvlHpogDtS –progress –password-file=/data/tmp/evan/passwd /data/dv_mon/data/frgbak_cron/mysqlbk_3306/20120704/20120704_gamedb_s1_3306.tgz frg@176.9.93.201::frgdb
password file must not be other-accessible
chmod 600 /data/tmp/evan/passwd 搞定
::frgdb 由于 /etc/rsyncd.conf决定的
[root@frgdb_gamelabs 20120704]# /usr/bin/rsync -rvlHpogDtS –progress –password-file=/data/tmp/evan/passwd /data/dv_mon/data/frgbak_cron/mysqlbk_3306/20120704/20120704_gamedb_s1_3306.tgz frg@176.9.93.201::/data/tmp/evan/
ERROR: The remote path must start with a module name not a /