Day 38th-an example enterprise backup solution

Source: Internet
Author: User

First, examples

A company has a Web server, the data is very important, but if the hard drive is broken, the data will be lost, now the leader requires you to backup the data, so that the Web server data loss can be restored.
Requirements are as follows:
Every night, at 00 o'clock on the Web server A, package the backup system configuration file, the website program directory, and the access log, and push the rsync command to Server B for backup retention (the idea of a backup can be packaged locally by date before being pushed to backup Server B).

Issue one: Implement Web Server A data backup to Server B
Requirements are as follows:
1. The backup directory for both Web server A and backup Server B must be/backup
2. The system configuration file includes but not limited to:
A, scheduled task service configuration file/var/spool/cron/root
b, boot-up configuration file/etc/rc.local
C, daily script directory/server/scripts
D, firewall iptables configuration file/etc/sysconfig/iptables
E. What else do I need to back up to think about?
3. The Web Server site directory is assumed to be/var/html/www
4. The Web server A access log path is assumed to be/app/logs
5, the Web server retains the packaged seven days of backup data (local retention is not more than 7 days), Backup Server B retains 6 months of data backup.
6, Backup Server B to follow the backup data server IP for the directory to save, packaged files are saved by the time name.


Ii. Steps of implementation
Build rsync service on B
1. Edit the rsync service configuration file

[[email protected]/] #vim/etc/rsyncd.conf

2. Check that the Rsync service profile is configured correctly

[Email protected]/]#Cat/etc/rsyncd.conf#rsync_config_______________start# #rsyncd. conf start# #uid=Rsyncgid=Rsyncusechroot=Nomax Connections= $Timeout= -PIDfile=/var/run/Rsyncd.pidlockfile=/var/run/Rsync.locklogfile=/var/log/Rsyncd.log[backup]path=/backup/Ignore Errorsread only=falseList=falsehosts allow=192.168.1.0/ -hosts Deny=0.0.0.0/ +Auth Users=rsync_backupsecretsfile=/etc/Rsync.password#rsync_config_______________end

3. Create a synchronization directory and modify its owning users and groups

mkdir /backup/chown rsync.rsync-r/backup/

4. Create rsync service virtual user and password file

[Email protected]/]#Echo "rsync_backup:123456">/etc/Rsync.password[[email protected]/]#chmod  -/etc/Rsync.password[[email protected]/]#Cat/etc/Rsync.passwordrsync_backup:123456[[Email protected]/]# Rsync--daemon #启动rsync服务 [[email protected]/]# lsof-i:873#查看rsync服务是否启动成功COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE Namersync1728Root4uIPv4142840t0 TCP *: Rsync (LISTEN) rsync1728Root5uIPv6142850t0 TCP *:rsync (LISTEN)

5. Turn off firewall and SELinux

[Email protected]/]#/etc/init.d/0/]# getenforcepermissive

6, write a simple script on the backup side, delete the 180 days old backup, and add the script to the scheduled task

 [[email protected] scripts]# sh  # !/bin/bash  find /backup/-type f-name  " *.tar.gz  -mtime +180  |xargs  rm -f[[email protected] scripts]# crontab -00  00  * * sh  >/dev/null  2  >&< Span style= "color: #800080;" >1  


The configuration on a
1. Create a backup directory and modify the user and group to which the directory belongs

mkdirchown rsync.rsync-r backup/ls -ld backup/drwxr  24096: backup/

2. Create rsync password file

Echo " 123456 " >/etc/chmod /etc/cat /etc/Rsync.password 123456

3. Test whether synchronization is successful

[Email protected]/]# CD backup/[email protected] backup]#ls[email protected] backup]#TouchTest.txt[[email protected] backup]#Echo 124>Test.txt[[email protected] backup]#CatTest.txt124[[email protected] backup]# rsync-avz/backup/[email protected]192.168.1.115:: Backup--password-file=/etc/rsync.passwordsending Incrementalfilelist./test.txtsent107Bytes Received -bytes274.00bytes/sectotal size is4Speedup is0.03

4. Write a packaged synchronization script on a
4.1. Packaging Synchronization Scripts

[Email protected] scripts]#CatBak.SH#!/bin/SHIP=`ifconfig|awk-F'[ :]+' 'Nr==2{print $4}'`[  ! -d/backup/$ip] &&mkdir-p/backup/$IPCD/backup/$ip &&TarCzf bak_$ (Date+%F).Tar. gz/var/spool/cron//etc/rc.local/server/scripts//etc/sysconfig/Iptablesrsync-az/backup/[email protected]192.168.1.115:: Backup--password-file=/etc/Rsync.passwordFind/backup-type F-name"*.tar.gz"-mtime +7|Xargs RM-F

4.2. Add to Scheduled Tasks

[Email protected] scripts]# crontab-file and Web site to  B server####00 * * * */bin/sh /server/scripts/bak. sh >/dev/null2>&1

4.3. View packaged Backup effects

[Email protected] scripts]# cd/backup/[email protected] backup]#ls192.168.1.113[[Email protected] backup]# CD192.168.1.113/[[Email protected]192.168.1.113]#lsbak_2015- A- -.Tar. Gz[[email protected] backup]#ls192.168.1.113[[Email protected] backup]# CD192.168.1.113/[[Email protected]192.168.1.113]#lsbak_2015- A- -.Tar. gz


Question two, if there are 100 servers need to back up data, how to specify the backup scheme and implementation?
Answer:
Ideas: Many students say in the Web client backup finished email to the administrator, there are 100 clients, the eldest brother Crazy, open the mailbox in the morning 100 spam, this idea is not right.
Correct thinking: server-side Check results:
1) du-sh/backup/ip/backup file of the day >/tmp/bak.log
2) package, push, and then push a flag (ip+ time filename), local cleanup 7 days ago.
3) Manual or timed Jie Bao, simulated data recovery to confirm the integrity of the data backup.

Question three, how to back up the data, the backup of the success and failure of the results of information sent to the system administrator mailbox?
Question four, how to achieve real-time data synchronization if the data of the NFS shared server is backed up?

Day 38th-an example enterprise backup solution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.