自动备份数据库的Shell
作者 佚名技术
来源 Linux系统
浏览
发布时间 2012-05-10
# #!/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 <CR>, 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
# 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
# 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!" # |
||
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
上一篇: 通过RHEL 5实现软RAID及LVM下一篇: linux时钟
关于自动备份数据库的Shell的所有评论