# #!/bin/bash # ######################################################################
 # # ScriptName : AMBT.sh--Auto Mysql Backup Tool #
 # # Date : 2007 - 10 - 04 Thu #
 # # Author : Drinkey [SYC] http://drinkey.syclover.cn #
 # # Version : 0.1 'Not finished yet... #
 # # #
 # # Descrition : You can use this script to backup your database, #
 Discuz! ,it can read the database #
 # # and backup your database automaticly.If you're using #
 # # others,you can enter the infomation on your keyboard. #
 # # #
 # # Useage : $PWD/ambt path_of_the_CONFIG.INC.PHP #
 # # $PWD/ambt , then enter your Infomation of your DB #
 # # #
 # # Note : The user and password you entered or the user of Discu#
 # # z!,they're supposed to has permission to backup your #
 # # database. #
 # ######################################################################
 # CONF='config.inc.php'
 # ROOT_UID=0
 # E_NOTEXIST=65
 # PREFIX='mysql_backup'
 # DUMPFILE=$PWD/$PREFIX$(date +%y%m%d).sql
 #
 # #------IF the user is NOT root,asking for some infomation --------#
 # if [ "$UID" -ne "$ROOT_UID" ]; then
 # echo -e "You're NOT ROOT.\n"
 # echo -e "Please Enter the info of database which you want backup.\n"
 # echo "Database Name:"
 # read N_DBName
 # echo "Database User:"
 # read N_DBUser
 # echo "Database Password:"
 # read N_DBPassword
 #
 # #------IF there's a file with same name,means he has backuped today ----#
 # if [ -x "$DUMPFILE" ]; then
 # echo "You've backuped your database today."
 # echo "If you want backup anyway,please delete $DUMPFILE"
 # else
 # mysqldump -u$N_DBUser -p$N_DBPassword --opt $N_DBName > $DUMPFILE
 # sleep 1
 # echo "Backup complet!"
 # fi
 #
 # else
 # #------The path the user entered is correct??-------#
 # if [ -x "$1$CONF" ]; then
 # COFILE="$1$CONF"
 # echo "File exists,read info from $COFILE."
 # awk -F\' '/\$dbuser/ { print "User: "$2}' $COFILE > $PWD/tmp
 # awk -F\' '/\$dbpw/ { print "Passwd: "$2}' $COFILE >> $PWD/tmp
 # awk -F\' '/\$dbname/ { print "DBName: "$2}' $COFILE >> $PWD/tmp
 # sleep 1
 # DBUser="`awk '/User/{print $2}' tmp`"
 # DBName="`awk '/DBName/{print $2}' tmp`"
 # DBPassword="`awk '/Passwd/{print $2}' tmp`"
 # sleep 1
 # mysqldump -u$DBUser -p$DBPassword $DBName > $DUMPFILE
 # echo "Backup complet!"
 # rm -f tmp
 # else
 # echo "File not exists,Please check the path."
 # exit $E_NOTEXIST
 # fi
 #
 # fi
|