mysql备份脚本

#!/bin/sh
#PATH=/usr/local/sbin:/usr/bin:/bin
 
# The Directory of Backup
BACKDIR=/usr/mysql_backup
# The Password of MySQL
ROOTPASS=123456
 
# Remake the Directory of Backup
rm -rf $BACKDIR
mkdir -p $BACKDIR
 
DBLIST=`ls -p /var/lib/mysql | grep / | tr -d /`
 
for dbname in $DBLIST
do
 
if [  ${dbname} == "mysql" -o ${dbname} == "test" -o ${dbname} == "information_schema" -o ${dbname} == "performance_schema"  ];then


echo "${dbname} is not dump"
else mysqldump -uroot -p$ROOTPASS $dbname>$BACKDIR/$dbname.sql

fi
done

你可能感兴趣的:(mysql备份)