Rsync+sersync数据备份
2018-01-19 16:20
190 查看
一、全网数据备份方案
1、需要备份的文件目录有(原则上,只要运维人员写入或更改的数据都需要备份)。/data,/etc/rc.local,/var/spool/cron/root等,根据不同都服务器做不同的调整
2、为了规范化,每台服务器进行本地备份时都备份到/backup目录下
3、每台WEB服务器进行本地备份时,都备份到/backup目录下以本机IP地址命名的目录中
4、打的tar包中需要包含当天的日期
5、统一存储数据备份的服务器统一采用Rsync daemon 方式提供存储备份数据都目录/backup
6、由于WEB服务器本地存储空间有限,需要将超过7天的备份数据删除
7、为了方便知道每次备份是否成功,我们需要做如下操作:
(1、在每台服务器上检查备份是否成功
(2、在存储备份数据的服务器上检查备份数据是否推送成功,并发送邮件到管理员邮箱
8、因为备份服务器空间有限,需要删除超过180天的备份数据,但每周六备份的数据要永久保留
做备份服务需要的基本步骤有:
1、 在Rsync备份服务器上安装,配置Rsync服务,实现推送
2、 在客户端服务器上,实现打包,推送,删除,定时任务推送
3、 在Rsync备份服务器上,做检查,发邮件给管理员
二、搭建Rsync备份服务端
安装seRsync
<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5">
<host hostip="10.0.0.121" port="8008"></host> //本地IP地址
<debug start="false"/>
<fileSystem xfs="false"/>
<filter start="false">
<exclude expression="(.).svn"></exclude>
<exclude expression="(.).gz"></exclude>
<exclude expression="^info/"></exclude>
<exclude expression="^static/"></exclude>
</filter>
<inotify>
<delete start="true"/>
<createFolder start="true"/>
<createFile start="false"/>
<closeWrite start="true"/>
<moveFrom start="true"/>
<moveTo start="true"/>
<attrib start="false"/>
<modify start="false"/>
</inotify>
</head>
1、需要备份的文件目录有(原则上,只要运维人员写入或更改的数据都需要备份)。/data,/etc/rc.local,/var/spool/cron/root等,根据不同都服务器做不同的调整
2、为了规范化,每台服务器进行本地备份时都备份到/backup目录下
3、每台WEB服务器进行本地备份时,都备份到/backup目录下以本机IP地址命名的目录中
4、打的tar包中需要包含当天的日期
5、统一存储数据备份的服务器统一采用Rsync daemon 方式提供存储备份数据都目录/backup
6、由于WEB服务器本地存储空间有限,需要将超过7天的备份数据删除
7、为了方便知道每次备份是否成功,我们需要做如下操作:
(1、在每台服务器上检查备份是否成功
(2、在存储备份数据的服务器上检查备份数据是否推送成功,并发送邮件到管理员邮箱
8、因为备份服务器空间有限,需要删除超过180天的备份数据,但每周六备份的数据要永久保留
做备份服务需要的基本步骤有:
1、 在Rsync备份服务器上安装,配置Rsync服务,实现推送
2、 在客户端服务器上,实现打包,推送,删除,定时任务推送
3、 在Rsync备份服务器上,做检查,发邮件给管理员
二、搭建Rsync备份服务端
rpm -qa rsync //查看服务是否存在
# yum install -y rsync //安装服务 # yum install -y xinetd //rsync依赖xinetd来管理 # rpm -qf `which rsync` //检查服务是否正常安装 /////修改配置文件 # cp /etc/rsyncd.conf /etc/rsyncd.conf.bak # > /etc/rsyncd.conf # vim /etc/rsyncd.conf //配置文件内容如下 uid = rsync gid = rsync address =172.16.1.15 port =873 hosts allow =172.16.1.0/24 use chroot = no max connections = 50 pid file =/var/run/rsyncd.pid lock file =/var/run/rsync.lock log file =/var/log/rsyncd.log motd file =/etc/rsyncd.motd [backup] path =/backup comment = used for web-data root read only = false list = yes auth users = rsyncuser secrets file =/etc/rsyncd.passwd
echo "Welcome to Backup Server" >/etc/rsyncd.motd //写入一个提示文件
vim /etc/rsyncd.passwd //添加用户和密码
rsyncuser:password
chmod 600 /etc/rsyncd.passwd //给于最小权限
useradd rsync -s /sbin/nologin –M //创建备份用户
rsync --daemon --config=/etc/rsyncd.conf //Rsync以daemon形式运行
netstat -anptu | grep 873 //查看端口是否存在
tcp 0 0 172.16.1.15:873 0.0.0.0:* LISTEN 7115/rsync
mkdir /backup //存放共享文件目录
chown rsync.rsync /backup/
三、搭建Rsync备份客户端(其他客户端做类似都操作)rpm -qa rsync //查看服务是否存在
# yum install -y rsync //安装服务 # yum install -y xinetd //rsync依赖xinetd来管理 # rpm -qf `which rsync` //检查服务是否正常安装 # echo "password" > /etc/rsyncd.passwd //创建密码文件 # chmod 600 /etc/rsyncd.passwd # mkdir /backup //创建要备份都目录,所有备份文件都放在这个目录下 //////rsync命令测试成功 # rsync -avz /backup/ rsyncuser@172.16.1.15::backup --password-file=/etc/rsyncd.passwd
安装seRsync
wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/sersync/sersync2.5.4_64bit_binary_stable_final.tar.gz
tar xf sersync2.5.4_64bit_binary_stable_final.tar.gz
mkdir /usr/local/sersync
mkdir /usr/local/sersync/conf
mkdir /usr/local/sersync/logs
mkdir /usr/local/sersync/bin
mv GNU-Linux-x86/sersync2 /usr/local/sersync/bin/
mv GNU-Linux-x86/confxml.xml /usr/local/sersync/conf/
vim conf/confxml.xml
/usr/local/sersync/bin/sersync2 -d -r -o /usr/local/sersync/conf/confxml.xml
配置文件
<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5">
<host hostip="10.0.0.121" port="8008"></host> //本地IP地址
<debug start="false"/>
<fileSystem xfs="false"/>
<filter start="false">
<exclude expression="(.).svn"></exclude>
<exclude expression="(.).gz"></exclude>
<exclude expression="^info/"></exclude>
<exclude expression="^static/"></exclude>
</filter>
<inotify>
<delete start="true"/>
<createFolder start="true"/>
<createFile start="false"/>
<closeWrite start="true"/>
<moveFrom start="true"/>
<moveTo start="true"/>
<attrib start="false"/>
<modify start="false"/>
</inotify>
<sersync> <localpath watch="/data/"> <remote ip="10.0.0.120" name="backup"/> ///服务端IP地址,模板名称 <!--<remote ip="192.168.8.39" name="tongbu"/>--> <!--<remote ip="192.168.8.40" name="tongbu"/>--> </localpath> <rsync> <commonParams params="-avrtuz"/> //Rsync传输方式 <auth start="true" users="rsyncuser" passwordfile="/etc/rsyncd.passwd"/> ///Rsync 用户名 密码 <userDefinedPort start="true" port="873"/><!-- port=874 --> ///端口 <timeout start="false" time="100"/><!-- timeout=100 --> <ssh start="false"/> </rsync> <failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once--> <crontab start="false" schedule="600"><!--600mins--> <crontabfilter start="false"> <exclude expression="*.php"></exclude> <exclude expression="info/*"></exclude> </crontabfilter> </crontab> <plugin start="false" name="command"/> </sersync> <plugin name="command"> <param prefix="/bin/sh" suffix="" ignoreError="true"/> <!--prefix /opt/tongbu/mmm.sh suffix--> <filter start="false"> <include expression="(.*)\.php"/> <include expression="(.*)\.sh"/> </filter> </plugin> <plugin name="socket"> <localpath watch="/opt/tongbu"> <deshost ip="192.168.138.20" port="8009"/> </localpath> </plugin> <plugin name="refreshCDN"> <localpath watch="/data0/htdocs/cms.xoyo.com/site/"> <cdninfo domainname="ccms.chinacache.com" port="80" username="xxxx" passwd="xxxx"/> <sendurl base="http://pic.xoyo.com/cms"/> <regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/> </localpath> </plugin>
</head>
相关文章推荐
- linux下rsync+sersync实现自动备份数据
- Rsync+sersync数据备份
- linux下rsync+sersync实现自动备份数据
- rsync+sersync实现数据时时备份
- 基于rsync+sersync数据实时双向同步的设计(一)
- rsync远程增量备份数据
- Linux下Rsync+sersync实现数据实时同步
- rsync+inotify实现数据的实时备份
- Linux 数据备份服务器 Rsync
- rsync实时备份增量数据
- rsync搭建数据镜像定时备份系统
- rsync客户端以及服务器端配置,推送、数据拉取、定时备份以及常见错误解决思路
- Rsync+inotify 搭建企业实时备份数据服务器
- rsync 数据镜像备份 记录
- rsync服务器架设(数据同步|文件增量备份)
- Windows下使用rsync备份远程Linux服务器数据
- rsync+sersync实时同步NextCloud数据
- linux下的数据备份工具rsync讲解
- rsync 使用:(llinux 和windows 版本数据同步|文件增量备份)
- linux之rsync远程数据同步备份