In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Full backup of linux configuration files and log files
1. Set up two hosts respectively to meet the test requirements
Server IP hostname nginx-web server 192.168.10.150web1 backup server
192.168.10.20backup
Requirements: package the backup system configuration files, website program directories and access logs on the Web server exactly at 00:00 every evening, and push the backup retention on the backup server backup through the rsync command (the backup idea can be packed locally by date, and then pushed to the backup server backup). Nginx-web server is a server in actual work, and the specific requirements are as follows:
1) the backup directory of the server must all be / backup.
2) system configuration files to be backed up include, but are not limited to:
a. The configuration file for the scheduled task service (/ var/spool/cron/root).
b. Boot configuration file (/ etc/rc.local).
c. Directory of daily scripts (/ server/scripts).
d. The configuration file for the firewall iptables (/ etc/sysconfig/iptables).
3) Web server site directory (/ home/www).
4) Web server access log path (/ app/logs)
5) the Web server can keep the backup data for 7 days after packaging (local retention cannot be more than 7 days)
6) the backup server should save the backup according to the IP of the backup web server for the directory, and the backup files should be saved according to the time name.
7) on the backup server, keep all the copies of the data every Monday, and keep the copies of the data for 6 months.
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.
2. Nginx-web server backup code
[root@web1 /] # vim backup.shroud balance bingray bash # definition variable hostip= `hostanme-I `cd / varfile= ". / var/spool/cron/root. / server/scripts. / etc/sysconfig/iptables" date= `date +% Fmuri% a`webfile = "/ home/www" weblog= "/ app/logs" mkdir / backup > / dev/null 2 > & configuration files required by the 1mkdir-p / backup/$hostip# packaging system, web site directory, Log directory tar-zcf / backup/$hostip/$ {date} .tar.gz. / $varfiletar-zcf / backup/$hostip/webfile_$ {date} .tar.gz. / $webfiletar-zcf / backup/$hostip/weblog_$ {date} .tar.gz. / $weblogmd5sum / backup/$hostip/* > / backup/$hostip/md5 ${date} .txt # sent to the backup server rcyns-avz. / backup/$hostip rsync_backup@192.168.10.20::backup-- password- via rsync File=/etc/rsync.password > / dev/null 2 > & 1if [$?-ne 0] Then echo "backup failed" | mail-s "backup status" 745651470@qq.comfi# cleans the files packaged 7 days ago find / backup/$hostip/-type f-mtime + 7-name "* .tar *" | xargs rm-ffind / backup/$hostip/-type f-mtime + 7-name "md5*.txt" | xargs rm-f
Scheduled task
[root@web1 /] # crontab-e00 * / bin/bash backup.sh > / dev/null 2 > & 1
3. Backup the server-side code
[root@backup /] # vim jiaoyan.shangxinxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (ls / backup / xargs-n1`) for.
< ${#A[*]};i++ )do /usr/bin/md5sum -c /backup/${A[i]/md5${date}.txt >>. / jiaoyanjieguo 2 > / dev/null # #-c option to verify the file md5. When verifying, the verification is carried out according to the generated md5. Generate the md5 of the current file and compare it with the previously generated md5. If it is consistent, return OK, otherwise return the error message done/bin/mail-s "backup data" 745651470@qq.com
< ./jiaoyanjieguo >Dev/null 2 > & 1rm-rf. / jiaoyanjieguofind / backup/-type f-mtime + 180!-name "* Mon*" | xargs rm-f
Scheduled task
[root@backup /] # crontab-e00 06 * / bin/bash jiaoyan.sh > / dev/null 2 > & 1
Note: for the installation of the rsync service in the trial, reference: http://douer.blog.51cto.com/6107588/1914098
The implementation of the script function is further optimized, if there are good ideas to share together.
Reference document: http://caojiaoyue.blog.51cto.com/11798573/1923404
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.