标签:grep $0 mys lse lease already dir read not
#!/bin/bashdate +%F-%T
if [ ! -d $SQL_DIR ]; then
mkdir -p $SQL_DIR
fi
for SQL_DB in $SQL_DBS
do
$MYSQL_COM2 -h$IPADDR -u$MYSQL_USER -p$MYSQL_PASS -e "show databases" |grep "$SQL_DB"
if [ $? == 0 ];then
$MYSQL_COM1 -h$IPADDR -u$MYSQL_USER -p$MYSQL_PASS --database $SQL_DB >${SQL_DIR}${SQL_DB}-${BAK_TIME}.sql
if [ $? == 0 ];then
echo "this $SQL_DB was already backup .."
continue
else
echo -e "\033[32m@You input the database is not exist..Please resume !\033[0m"
exit
fi
else
if [ $SQL_DBS == all ];then
$MYSQL_COM1 -h$IPADDR -u$MYSQL_USER -p$MYSQL_PASS --all-databases >${SQL_DIR}all-${BAK_TIME}.sql
if [ $? == 0 ];then
echo "all databases was already backup .."
exit
else
echo -e "\033[32m@@You input the database is not exist..Please resume !\033[0m"
exit
fi
fi
fi
done
标签:grep $0 mys lse lease already dir read not
原文地址:https://blog.51cto.com/13689591/2451981