备份mysql数据库

2014-11-17 0 215
备份mysql数据库
#!/bin/bash
#backup mysql data
#Auther:arezone
#website:http://www.olinux.org.cn

DBDIR=/data/mysql
BACKDIR=/data/bak/mysql
TIME=`date -d "today" +%F`
DB=$(ls -p $DBDIR | grep / |tr -d / | grep -Ev 'information_schema|performance_schema|mysql|test')
/etc/init.d/mysqld stop
if [ -d $BACKDIR ]
then
        echo "OK!"
else
        mkdir -p $BACKDIR
fi
cd $DBDIR
for i in $DB
do
tar czf $BACKDIR/$i\_db\_$TIME.tar.gz $i
done
/etc/init.d/mysqld start
find $BACKDIR -name "*.tar.gz" -type f -mtime +15 -exec rm {} \;  >/dev/null 2>&1

遇见资源网 shell 备份mysql数据库 http://www.ox520.com/16710.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务