One, automatic backup MySQL script: The following script for MySQL automatic backup script, for reference only, can be modified according to the actual situation. #!/bin/sh #auto backup MySQL #wugk#Define Path definition variable bakdir=/data/backup/mysql/' Date +%y-%m-%d ' MySQLdb=WebApp MYSQLPW=Backup MYSQLUSR=The backup #must use root user run scripts must be run with root, $UID as a system variableif[$UID-ne0];then echo This script must use the root user! ! !Sleep2Exit0fi #Define dir and mkdir dir to determine if the directory exists, does not exist the newif [ ! -d $BAKDIR];then mkdir-P $BAKDIRElseEcho This is$BAKDIR exists. Fi #Use mysqldump backup MySQL uses mysqldump to back up the database/usr/bin/mysqldump-u$mysqlusr-p$mysqlpw-d $MYSQLDB > $BAKDIR/webapp_db.sql CD $BAKDIR; tar-CZF webapp_mysql_db.tar.gz *. SQL #查找备份目录下以. SQL end file and delete find.-type f-name "*.sql" |xargs RM-The RF #如何数据库备份成功, print successfully, and delete the backup directory 30 days before the directory [$? -eq0]&&echo "This ' date +%y-%m-%d ' MySQL BACKUP isSUCCESS "CD/data/backup/mysql/; find. -type D-mtime + -|xargs RM-RF Echo"The MySQL backup successfully"second, the Nginx case mode installation script: The following script for Nginx automatic installation script, only for reference, can be modified according to the actual situation, here the use of scenario, the real environment can be removed from this mode, the automatic installation. #!/bin/SH # # #nginx install Shell # # #wugk -- A- A# # #Define PATH definition variable Soft_path=/data/soft/Nginx_file=nginx-1.2.4. tar.gz Down_path=http://nginx.org/download/#Define dir and mkdir soft dir creating a software catalogif [ ! -d $SOFT _path];then mkdir-p $SOFT _path fi #Define download function definition download functions download () {CD $SOFT _path; wget $DOWN _path/$NGINX _file} #Define install function definition install functions install () {yum install pcre-devel-y cd $SOFT _path, tar xzf $NGINX _file CD NGINX-1.2.4/&&./configure--prefix=/usr/local/nginx/--with-http_stub_status_module--with-Http_ssl_module [$? -eq0]&&make &&Make Install} #Start Nginx Server Define start function definition start functions start () {lsof-I.: the [ $? -ne0]&&/usr/local/nginx/sbin/Nginx} #Stop nginx Server Define stop function definition stop functions stop () {PS-ef |grep nginx |grep-v grep |awk'{print $}'|xargs Kill-9} #Config Case Menu Install configure case installation Menu Case$1 inchdownload) download;; install) install;; Start) Start; stop) stop;; *) echo"usage:$0 {Download or install or start or stop}"Exit $?Esac Three, automatically unzip the tar, Zip script: www.2cto.com The following script for the automatic decompression of the TAR package and zip package script, for reference only, can be modified according to the actual situation, can be extrapolate, applied to other applications. #解压zip包脚本如下: #!/bin/sh #auto tar package #wugk -- A- A#Define Path PATH1=/tmp/Images PATH2=/usr/www/Images #Print Welcome info Cat<<EOF+ +--------------------------------------------------------+ + +---------Welcome to use Auto Tar scripts-------+ + +--- -----------------------------------------------------++eof#find Dir All TAR packages Find/tmp/all tar packages under the images directory forIinch' Find $PATH 1-name"*.tar" ` DoTar-XVF $i-C $PATH 2 done #解压TAR包脚本如下: #!/bin/SH PATH1=/tmp/Images PATH2=/usr/www/Images #!/bin/SH PATH1=/tmp/Images PATH2=/usr/www/images #Find Dir all ZIP packages Find/tmp/images all the tar packages in the directory and create the unzip directory CD $PATH 1 forIinch' Find. -name"*.zip"|awk-f. {print $2} ` Domkdir-P path2$i Unzip-O. $i. zip-d path2$i done
MySQL automatic backup and nginx automatic installation script