使用if条件语句编写MySQL备份脚本
时间:2021-07-01 10:21:17
帮助过:29人阅读
=/usr/share/nginx/html/project/ssh/backup/`date +%Y%m%
d`
mysqldb=
test
musqluser=
root
mysqlpwd=
123456
mysqlicmd=/usr/bin/
mysqldump
if [ $UID -ne
0 ];then
sudo su
fi
if [ ! -
d $dir ];then
mkdir -
p $dir
echo "create $dir now"
else
echo "$dir exists"
fi
$mysqlicmd -u$musqluser -p$mysqlpwd -d $mysqldb >$dir/
$mysqldb.sql
if [ $? -ef
0 ];then
echo -e
"\033[32mBackup Successfully!\033[0m"
else
echo -e
"\033[32mBackup failded!\033[0m"
fi
使用if条件语句编写MySQL备份脚本
标签:mys fail mba backup roo pwd 语句 root class