mysql从库备份脚本

IP=`/sbin/ifconfig eth0 | grep 'inet addr' | cut -d: -f2 | awk '{ print $1}'`

DATE=`date +%Y%m%d_%H`

/usr/local/mysql/bin/mysqladmin -pbxd123 shutdown

PROCESS= `ps -ef |grep /usr/local/mysql/bin/mysqld_safe |grep -v grep`

if [ "$PROCESS" = "" ]

then

cd /usr/local/mysql/

DISKSIZE=`df -h|grep '9[0-9]%'`

if [ -z "$DISKSIZE" ]

then

find /backup/$IP/mysql/fullfile/ -ctime 10 |grep var|xargs rm -fr

tar -zcf /backup/$IP/mysql/fullfile/var_$DATE.tar.gz var

else

please check the mysqlfullfile backup

fi

sleep 20

/usr/local/mysql/bin/mysqld_safe --user=mysql &

exit 0;




你可能感兴趣的:(mysql,脚本)