#!/bin/bash# #WEB页面, Web Environment version, database, full station backup script # when there is a reason why the entire server cannot be recovered, use the relevant data backed up above to redo the same server date_a= ' date +%y%m%d-%h% m%s ' Mkdir -p /web_bak/${date_a}/conf &> /dev/nullmkdir -p /web_bak/${date _a}/web &> /dev/nullmkdir -p /web_bak/${date_a}/mysql &> /dev/null The configuration file under the #/etc directory is backed up, and the environment version number information bak= "Httpd my.cnf my.cnf.d php.d php.ini" For bak in $bak;d o #cp -rfp /etc/$bak /web_bak/${date_a}/conf &> /dev/ null #done # Backup corresponding software version information php -v | grep ^php &> /web_bak/${date_a} /php-version #httpd -v | grep "Server version" &> /web_bak/${ date_a}/apache-version #mysql -V &> /web_bak/${date_a}/mysql-version #cat /etc/redhat-release &> /web_bak/${date_a}/redhat-release ## /var/www/html Backing up Web files in the entire directory Cp -rfp /var/www/html /web_bak/${date_a}/web &> /dev/null# backing up the database user_db=root # DB user name passwd_db=passwd #DB密码localhost =127.0.0.1 #DB主机名port =3306 #DB端口name_db =mysql # Database name mysqldump --opt -u$user_db -p$passwd_db -h$localhost -p$port $name _db > /web_bak/${date_a}/mysql/${name_db}.sql
Web pages, Web environment versions, databases, full-site backup scripts