#rpm -qa |grep rsync 卸载rsync(系统一般会默认安装rsync)
#rpm -e rsync-2.6.8-3.1================================================================================
#yum -y install gcc================================================================================
#wget -c http://rsync.samba.org/ftp/rsync/src/rsync-3.0.7.tar.gz参数说明:--prefix 指定rsync要安装的目录.
#tar zxvf rsync-3.0.7.tar.gz
#cd rsync-3.0.7
#./configure --prefix=/usr/local/rsync
#make$make install
#vi /ect/rsyncd.conf写入以下内容
uid = root================================================================================
gid = root
use chroot = no # 不使用chroot
max connections = 4 # 最大连接数为4
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
[wwwroot] # 这里是认证的模块名,在client端需要指定
path = /home/wwwroot/ # 需要做镜像的目录
ignore errors # 可以忽略一些无关的IO错误
read only = true # 只读
list = false # 不允许列文件
hosts allow = 184.82.253.30 # 只允许备份服务器IP连接,支持184.82.253.30/55
hosts deny = * # 禁止连接IP
auth users = shimenren # 认证的用户名,如果没有这行,则表明是匿名
secrets file = /etc/backshimenren.pas # 认证文件名,密码文件
#vi /ect/backshimenren.pas写入
shimenren:1234格式为:用户名:密码
#chown root.root backshimenren.pas至止rsync 主服务器设定完成。
#chmod 600 backshimenren.pas
#rsync --daemon=================================================================================
或
#/usr/local/rsync/bin/rsync --daemon
#netstat -na|grep 873查看rsync 进程
#ps -ef | grep rsync进入备份服务器
#/usr/local/rsync/bin/rsync -vzrtopg --delete --exclude "dz.189k.net/config/" --exclude "dz.189k.net/uc_server/data/config.inc.*/" --progress shimenren@184.82.228.22::wwwroot /home/wwwroot/上面这个命令行中--vzrtopg里的v是代表Verbose(详细);z是代表Zip(压缩);r是代表Recursive(递归);Topg都是保
#/usr/local/rsync/bin/rsync -vuzrtopg --progress shimenren@113.107.101.119::wwwroot /home/wwwroot/ --password-file=/etc/backshimenren.pawdss
#/usr/local/rsync/bin/rsync -vuzrtopg --progress shimenren@113.107.101.119::nginx /usr/local/nginx/conf --password-file=/etc/backshimenren.pawdss
将rsync --daemon加入到/etc/rc.d/rc.local文件中设置为开机自动启动=================================================================================
#vi /ect/backshimenren.pawdss#1234 之前主服务器设置的密码
#cd /ect=================================================================================
#chmod 600 backshimenren.pas
#/usr/local/rsync/bin/rsync -vzrtopg --delete --exclude "logs/" --exclude "conf/ssl.*/" --progress shimenren@184.82.228.22::wwwroot /home/wwwroot/ --password-file=/etc/backserver.pas
"#! /bin/Bash"
RSYNC="/usr/local/rsync/bin/rsync"
para="-vzrtopg --delete"
pwdfile="--password-file=/etc/backserver.pas"
user="shimenren"
server="184.82.228.22" #主服务器IP
block="wwwroot" #主服务器认证的模块名
$RSYNC $para --exclude "logs/" --exclude "conf/ssl.*/" --progress $user@$server:block /home/wwwroot/
#crontab -u root -e保存
0 5 * * * /root/bk.sh
#/etc/init.d/crond restart注:这里执行备份的时间可以自行设置,设置成一分钟,嘿嘿就差不多是同步镜像备份了!
| 欢迎光临 VPS侦探论坛 (https://bbs.lnmp.com/) | Powered by Discuz! X3.4 |