這篇文章將為大家詳細(xì)講解有關(guān)MySQLdump中怎么備份MYSQL數(shù)據(jù)庫(kù),文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個(gè)參考,希望大家閱讀完這篇文章后對(duì)相關(guān)知識(shí)有一定的了解。
創(chuàng)新互聯(lián)是專(zhuān)業(yè)的運(yùn)城網(wǎng)站建設(shè)公司,運(yùn)城接單;提供網(wǎng)站設(shè)計(jì)制作、成都網(wǎng)站建設(shè),網(wǎng)頁(yè)設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專(zhuān)業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行運(yùn)城網(wǎng)站開(kāi)發(fā)網(wǎng)頁(yè)制作和功能擴(kuò)展;專(zhuān)業(yè)做搜索引擎喜愛(ài)的網(wǎng)站,專(zhuān)業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來(lái)合作!
1、備份腳本內(nèi)容
[david_yeung@localhost ~]$ cat fast_backup
#!/bin/sh
#
# Created by david yeung.
#
# 20080707.
#
# Backup 's full data.
#
DBNAME=$1
BACKUPDIR=/home/david_yeung/backup_new
USERNAME=backup_user
PASSWD=123456
TARNAME="$BACKUPDIR"/backup"$1"`date '+%Y%m%d'`
# Add your own database name here.
case "$1" in
my_site);;
*) exit;;
esac
# Get all the tables' name.
NUM=`/usr/local/mysql/bin/mysql -u$USERNAME -p$PASSWD -s -vv -e "show tables" -D $DBNAME|wc -l`
HEADNUM=`expr ${NUM} - 3`
TAILNUM=`expr ${NUM} - 7`
ARR1=`/usr/local/mysql/bin/mysql -u$USERNAME -p$PASSWD -s -vv -e "show tables" -D $DBNAME| head -n"$HEADNUM" | tail -n "$TAILNUM"`
ARR2=($ARR1)
i=0
while [ "$i" -lt "${#ARR2[@]}" ]
do
tmpFileName=${ARR2[$i]}
# The real dump process.
/usr/local/mysql/bin/mysqldump -u$USERNAME -p"$PASSWD" "$DBNAME" "$tmpFileName" >> "$TARNAME"
let "i++"
done
2、因?yàn)槲覀円恢庇么鎯?chǔ)過(guò)程,所以得單獨(dú)備份出來(lái)。
[david_yeung@localhost ~]$ cat fast_sp
#!/bin/sh
# Created by david yeung 20080122.
#
# Backup site's routine.
TARNAME=/home/david_yeung/backup_new/spBackup"$1"`date '+%Y%m%d'`
/usr/local/mysql/bin/mysqldump -ubackup_user -p123456 -n -t -d -R my_site > "$TARNAME"
3、丟到計(jì)劃任務(wù)里面去,就不管了。
[root@localhost backup_new]# crontab -l
0 01 * * * /home/david_yeung/fast_backup my_site
0 0 * * 5 /home/david_yeung/fast_sp
關(guān)于mysqldump中怎么備份MYSQL數(shù)據(jù)庫(kù)就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。