05.08 Full Network Backup Project Description

Chapter 1 Introduction of Network-wide Backup Project

Summarize, backup and save all important data on all servers in the whole network architecture!

Automation: Automatic Backup of Data Information
 Normalization: avoid backup data errors

Chapter II Implementation Process of Network-wide Backup Project

1. Plan and define the backup server

Deploy rsync backup service (using rsync daemon)
Write script files to manage backup data information
 Write timed task execution scripts to manage data

2. Confirm and validate the architecture server

Verify rsync backup service
 Writing script files to unify backup data information
 Write timed task execution script to backup data

Chapter 3: Deployment of rsync daemon mode for full network backup project

1. rsync service end deployment operation
2. rsync client authentication operation

Chapter IV Writing of Project Script for Network Backup

1. rsync client scripting requirements
Create backup backup directory locally
Unified compression of backup data for storage, with soft connection file tar-h
Push backup directory data to rsync backup server
Delete locally saved data 7 days ago
Verify backup data, add fingerprint information md5sum-c client transfer fingerprint file

2. rsync server-side scripting requirements
Verify data integrity
Configuration of mailboxes sent to supervisors by mail and the way to send mail (two ways to send mail)
Send mail, use file to express mail content

mail -s "check data" 835868899@qq.com  </tmp/mail.txt

Send mail, use command line to express mail content

# echo "system has abnormal problems, please check the system" | mail-s "abnormal alarm" 13661086369@163.com

Delete 180-day data and keep Monday data

find /backup/ -type f -mtime +180 ! -name "*week01.tar.gz"|xargs rm -f

Chapter V Timing Task Writing for Network-wide Backup Project

rsync Client Writes Timing Tasks
Writing Timing Tasks on rsync Server

Chapter 6 Deployment Steps of Network-wide Backup Project

1. [Server] Verify whether the rsync package is installed

[root@backup ~]# rpm -qa rsync
rsync-3.0.6-12.el6.x86_64

[root@backup ~]# rpm -qa |egrep rsyn* --color
rsyslog-5.8.10-10.el6_6.x86_64
rsync-3.0.6-12.el6.x86_64

2. [Server] Configure rsync software configuration file

cat >>/etc/rsyncd.conf <<END
##rsyncd.conf start##
uid = rsync
gid = rsync
use chroot = no
max connections = 200
timeout = 300
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
[backup]
path = /backup
ignore errors
read only = false
list = false
hosts allow = 172.16.1.0/24
hosts deny = 0.0.0.0/32
auth users = rsync_backup
secrets file = /etc/rsync.password
END

//Configuration of multi-module steps:
        01: modify rsyncd.conf Configuration file information to create multi-module configuration parameters
        02: Create a backup storage directory specified by multiple modules and authorize the backup storage directory
        03: The client specifies the newly created module for backup of test data transmission

3. [Server] Create rsync software process users

useradd -s /sbin/nologin -M rsync
id rsync

4. [Server] Create rsync backup directory/Authorize rsync user to manage backup directory

[root@backup ~]# mkdir /backup -p
[root@backup ~]# ll -d /backup/
drwxr-xr-x 2 root root 4096 May  4 12:00 /backup/
[root@backup ~]# # Modify backup directory permissions
[root@backup ~]# chown -R rsync.rsync /backup/
[root@backup ~]# ll -d /backup/
drwxr-xr-x 2 rsync rsync 4096 May  4 12:00 /backup/

5. [Server] Create Authenticated User Password File

[root@backup ~]# # Create an Authenticated User Password File
[root@backup ~]# echo "rsync_backup:123456" >/etc/rsync.password
[root@backup ~]# cat /etc/rsync.password
rsync_backup:123456
[root@backup ~]# chmod 600 /etc/rsync.password
[root@backup ~]# ll /etc/rsync.password
-rw------- 1 root root 20 May  4 12:04 /etc/rsync.password

6. [Server] Start rsync daemon service

rsync --daemon

7. [Server] Rsync boot-up and self-start

** Method 1 uses / etc/rc.local boot-up self-startup file**
[root@backup ~]# echo "rsync --daemon" >>/etc/rc.local 
[root@backup ~]# tail -2 /etc/rc.local 
# rsync boot info
rsync --daemon

** Method 2 Writing script file**
Write a script file, and use rsync --daemon to start the command
 Place the script file under / etc/init.d / directory
 The script content information needs to be added chkconfig: 2345 5525
 Granting script execution privileges
 Add to the list of chkconfig startup management services

** Method 3 xinetd self-startup rsync service added to the list of chkconfig startup management services
 Modify the configuration file to allow xinetd to manage rsync services**
[root@backup ~]# vim /etc/xinetd.d/rsync 
# default: off
# description: The rsync server is a good addition to an ftp server, as it \
#       allows crc checksumming etc.
service rsync
{
        disable = no
        flags           = IPv6
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/bin/rsync
        server_args     = --daemon
        log_on_failure  += USERID

8. [Client] Verify whether the rsync package is installed

[root@backup ~]# rpm -qa rsync
rsync-3.0.6-12.el6.x86_64

[root@backup ~]# rpm -qa |egrep rsyn* --color
rsyslog-5.8.10-10.el6_6.x86_64
rsync-3.0.6-12.el6.x86_64

9. [Client] Create rsync backup directory / backup

[root@nfs01 ~]# mkdir -p /backup
[root@nfs01 ~]# ll /backup/
total 0

10. [Client] Create rsync password authentication file to perform non-interactive secret-free operation

[root@nfs01 ~]# echo "123456" >/etc/rsync.password
[root@nfs01 ~]# cat /etc/rsync.password
123456
[root@nfs01 backup]# chmod 600 /etc/rsync.password
[root@nfs01 backup]# ll /etc/rsync.password
-rw------- 1 root root 7 May  8 16:49 /etc/rsync.password

11. [Client] Test the success of pushing to the server

[root@nfs01 backup]# rsync -avzP /backup/ rsync_backup@172.16.1.41::backup --password-file=/etc/rsync.password 
sending incremental file list
./
1.txt
           0 100%    0.00kB/s    0:00:00 (xfer#1, to-check=0/2)

sent 75 bytes  received 30 bytes  70.00 bytes/sec
total size is 0  speedup is 0.00

[root@backup backup]# ll
total 0
-rw-r--r-- 1 rsync rsync 0 May  8 16:51 1.txt

12. [Client] Write scripts to pack backup files, fingerprint verification files, push the server, and clean up the backup files 7 days ago.

[root@nfs01 scripts]# vim backup_nfs.sh 
#!/bin/bash
. /etc/init.d/functions

host_Ip=$(hostname -I |awk '{print $2}')
date_Info=$(date +%F_week%w)
finger_Path=/backup/172.16.1.31/

#Create file directory
mkdir /var/html/www -p
mkdir /app/logs/ -p
action "NO.1:  Create file directory" /bin/true

#tar file
cd / && mkdir -p /backup/$host_Ip
tar -zchf /backup/$host_Ip/sysfile_${date_Info}.tar.gz  ./var/spool/cron/root ./etc/rc.local ./se
rver/scripts ./etc/sysconfig/iptables
action "NO.2:  Tar sysfile_${date_Info}.tar.gz" /bin/true

tar -zchf /backup/$host_Ip/www_${date_Info}.tar.gz ./var/html/www
action "NO.3:  Tar www_${date_Info}.tar.gz" /bin/true

tar -zchf /backup/$host_Ip/logs_${date_Info}.tar.gz ./app/logs/
action "NO.4:  Tar logs_${date_Info}.tar.gz" /bin/true

#Create finger
find ${finger_Path} -type f -name "*.tar.gz" |xargs md5sum >/${finger_Path}/finger_${date_Info}.t
xt
action "NO.5:  Create finger_${date_Info}.txt" /bin/true

# rsync push data to rsync_server
rsync -az /backup/ rsync_backup@172.16.1.41::backup --password-file=/etc/rsync.password
action "NO.6:  rsync push to rsync_server" /bin/true

# clear data info for 7 day ago
find ${finger_Path} -type f -mtime +7 -name "*.tar.gz" |xargs rm -f
find ${finger_Path} -type f -mtime +7 -name "fin*" |xargs rm -f
action "NO.7:  clear data info for 7 day ago" /bin/true

13. [Server] script validation and file cleaning

[root@backup 172.16.1.31]# vim  /server/scripts/backup_nfs.sh
#!/bin/bash
date_Info=$(date +%F_week%w)

#Certification finger
find /backup/172.16.1.31/ -type f -name "finger_${date_Info}*" |xargs md5sum -c >/tmp/mail.txt
mail -s "[NFS]Server periodic backup Report" guoqunchao@yeah.net </tmp/mail.txt

#clear file
find /backup/ -type f -mtime +180 -name "*week01.tar.gz" |xargs rm -f

14. [Client] Join Timing Tasks

[root@nfs01 backup]# crontab -e
#rsync nfs file to rsync
00 00 * * * /bin/bash /server/scripts/backup_nfs.sh  >/dev/null 2>&1

15. [Server] Join Timing Tasks

[root@backup 172.16.1.31]# crontab -e
#backup_nfs file clear
00 06 * * * /bin/bash /server/scripts/backup_nfs.sh >/dev/null 2>&1

Chapter 7 Mailbox Service Settings

1. Modify / etc/mail.rc to add the last line

vim /etc/mail.rc
set from=guoqunchao@yeah.net smtp=smtp.yeah.net smtp-auth-user=guoqunchao smtp-auth-password=gqc1995 smtp-auth=login

   from Is the mailing address sent
   smtp It's the exterior of what happened. smtp The address of the server
   smtp-auth-userIt's external. smtp Server Authenticated User Name
   smtp-auth-passwordIt's external. smtp Server Authenticated User Password (Authorization Code)
   smtp-authIs the way of mail authentication

2. Restart mail service after configuring mail profile

/etc/init.d/postfix restart
Shutting down postfix                        [ ok ]
Start postfix                                [ ok ]

Keywords: rsync network RPM vim

Added by spartan7 on Fri, 14 Jun 2019 00:40:52 +0300