mysqldump备份
时间:2021-07-01 10:21:17
帮助过:4人阅读
# Author: elisun
IP=
localhost
USER=
elisun
PASSWORD=
elisun
BAKDB=
"test"
MYSQLPATH=/usr/local/mysql/
bin
BACKDIR=/data/
mysql_backup
DATE=`
date +%Y%m%
d`
if [ ! -e $BACKDIR ];
then
mkdir $BACKDIR
fi
for db
in $BAKDB
do
MYSQLCHAR=`$MYSQLPATH/mysql -u$USER -h$IP -p$PASSWORD -e
"show create database $db;" |
awk ‘{print $9}‘ |
tail -
1`
$MYSQLPATH/mysqldump -u$USER -h$IP -p$PASSWORD --default-character-set=$MYSQLCHAR $db > $BACKDIR/$db
"_"$DATE.sql &&
echo "$MYSQLCHAR "
echo "$db"
cd $BACKDIR
/bin/
tar zcf $db
"_"$DATE.
tar.gz $db
"_"$DATE.sql&&
echo "$db tar success "
done
/usr/bin/
find $BACKDIR -name
"*.tar.gz" -mtime +
5 -exec
rm -
f {} \;
/usr/bin/
find $BACKDIR -name
"*.sql" -mtime +
0 -exec
rm -
f {} \;
?
mysqldump备份
标签:shel span rac backup nbsp password lis show cat