1.
安装rsync,如果要讲1.1.1.1的数据备份到2.2.2.2上,则在1.1.1.1上配置如下:
/etc/rsyncd.conf
uid = nobody
gid = nobody
use chroot = no
max connections = 40
syslog facility = local5
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
[www] 模块名
path = /tw/www #要备份的目录的绝对路径
comment = www #简介
uid = root
read only = yes #不备份客户端数据
ignore errors = yes
hosts allow = 2.2.2.2
[mysqldump]
path = /usr/local/mysql/data
comment = mysql
uid = root
read only = yes
ignore errors = yes
hosts allow = 2.2.2.2
启动服务:
rsync --daemon --config=/etc/rsyncd.conf
二、在备份机2.2.2.2上执行脚本或命令如下:
#! /bin/sh
MONTH=`date +%m`
WEEK=`date +%w`
DATE=`date +%d`
HOUR=`date +%d%H`
cat /dev/null >/data/log/web_1.1.1.1.$WEEK
#cat /dev/null >/data/log/rsync_slx_add_f.$WEEK
#cat /dev/null >/data/log/rsync_slx_add_l.$WEEK
/usr/local/bin/rsync -avuz --ignore-errors --delete --progress [email protected]::www
www是模块名
/backup/backup1/web_1.1.1.1/www \ #存放目录
--password-file=/etc/bin/rsync.scrt >>/data/log/rsync_1.1.1.1.$WEEK
/usr/local/bin/rsync -avuz --ignore-errors --delete --progress [email protected]::mysqldump \
/backup/backup1/web_1.1.1.1/mysqldump --password-file=/etc/bin/rsync.scrt >>/data/log/rsync_1.1.1.1.$WEEK