mysqldump备份
Posted 孙磊elisun
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysqldump备份相关的知识,希望对你有一定的参考价值。
# cat /data/shell/mysqldump.sh
#!/bin/sh # 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备份的主要内容,如果未能解决你的问题,请参考以下文章