Enterprise network backup case:
Specific requirements are as follows:
1) The backup directory of all servers must be /backup.
2) The system configuration files to be backed up include but are not limited to:
a. The configuration file of the scheduled task service (/var/spool/cron/root) (suitable for web and nfs servers).
b. The configuration file (/etc/rc.local) that starts automatically at boot (suitable for web and nfs servers).
c. Directory for daily scripts (/server/scripts) (suitable for web and nfs servers).
d. The configuration file of firewall iptables (/etc/sysconfig/iptables).
3) The web server site directory is assumed to be (/var/html/www)
4) Web server A access log path is assumed to be (/app/logs)
5) The web server can keep the backup data for 7 days after packaging (the local storage cannot be more than 7 days, because too many hard disks will be full)
6) On the backup server, keep all data copies every Monday, and other data copies for 6 months.
7) On the backup server, the backup should be saved as a directory according to the intranet IP of the backup data server, and the backup files should be saved according to the time name.
8) * It is necessary to ensure that the backup data is as complete and correct as possible, check the backup data on the backup server, and send the backup success and failure result information to the system administrator's mailbox
Client deployment:
Note: When writing a script, first test the command on the command line, and after it is correct, put it in the script
Step-by-step writing/checking to ensure the correctness of the script
The content of the client script is as follows:
#!/bin/bash #by-jiangboyang jiang=`hostname -i` #mkdir [ ! -d /backup/$jiang ] && mkdir /backup/$jiang #tar tar zchf / backup / $ jiang / backup - $ (date +% F_% w _) -. tar.gz / var / spool / cron / root /etc/rc.local / var / html / www #rm find /backup -type f -mtime +7 |xargs rm #make md5sum md5sum $(find /backup/$jiang -type f -mmin -10) >/backup/$jiang/police.log #rsync rsync -av /backup/$jiang/ rsync_backup@backup::backup/172.16.1.41/ --password-file=/etc/rsync.passwd
Server script:
#!/bin/bash #jiang=`hostname -i` da=`date +%F` #md5sum Find out all the files of the verification information, test them, and record them in a file find /backup -type f -name "*.log" |xargs md5sum -c >/tmp/check$da.txt #rm find /backup/ -type f -mtime +180 ! -name "*_1_*" |xargs rm #mail mail -s "test" [email protected] </tmp/check$da.txt
The client refers to the host that performs backup, and the server refers to the backup server.
Verification instructions for md5sum:
md5sum -c When verifying whether the file is OK, it depends on the path when the verification information was generated
Where the verification information is generated, it is detected where
If the path is wrong, an error message will be displayed even if the file content has not been changed