快速业务通道

自动备份数据库的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
Empire CMS,phome.net
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
Empire CMS,phome.net
"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!"
#

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号