#!/bin/bash
#back_MySQL by 2016-11-14
bak_dir=/data/backup_db/`date +%Y%m%d`
mysqldb=mysql
mysqluser=*****
mysqlpw=******
if [ $UID -ne 0 ];then
成都創(chuàng)新互聯(lián)公司專(zhuān)注于網(wǎng)站建設(shè)|成都網(wǎng)站維護(hù)公司|優(yōu)化|托管以及網(wǎng)絡(luò)推廣,積累了大量的網(wǎng)站設(shè)計(jì)與制作經(jīng)驗(yàn),為許多企業(yè)提供了網(wǎng)站定制設(shè)計(jì)服務(wù),案例作品覆蓋會(huì)所設(shè)計(jì)等行業(yè)。能根據(jù)企業(yè)所處的行業(yè)與銷(xiāo)售的產(chǎn)品,結(jié)合品牌形象的塑造,量身設(shè)計(jì)品質(zhì)網(wǎng)站。
echo "must to be use root for exec shell"
exit
fi
#判斷是否存在文件,\033[32m是顯示顏色的
if [ ! -d $bak_dir ];then
mkdir -p $bak_dir
echo -e "\033[32mThe $bak_dir create successfully!\033[0m"
else
echo "This $bak_dir is exists...."
fi
#備份語(yǔ)句
mysqldump -u$mysqluser -p$mysqlpw -d $mysqldb
>$bak_dir/$mysqldb.sql.tar.gz
#是否備份成功
if [ $? -eq 0 ];then
echo -e "\033[32mThe mysql backup $mysqldb
successfully\033[0m"
else
echo -e "\033[32mThe mysql backup $mysqldb failed .please
check!\033[0m"
fi
#執(zhí)行腳本和備份結(jié)果