!/bin/bash
Author:by ztj
Date:20230818
Description:mysql backup shell
Name:Mysql_Backup.sh
BAKDIR=/tmp/backup/mysql/$(date +%Y%m%d)
MYSQLDB=mysql
MYSQLUSER=root
MYSQLPW=root
if [ $UID -ne 0 ];then
echo "This script must use the root user!!!"
sleep 2
exit
fi
if [ ! -d $BAKDIR ];then
mkdir -p $BAKDIR
fi
mysqldump -u$MYSQLUSER -p$MYSQLPW -d $MYSQLDB >$BAKDIR/$MYSQLDB.sql
echo "The mysql backup successfully."