以前线上用的mysql备份脚本:
[root@youxia110 shell]# cat mysqlbinlogbak.sh
#!/bin/sh
account=root
password=f7m9g7fi
datadir=/var/lib/mysql
bakdir=/var/bak
mysqladmin -u$account -p$password flush-logs
total=`ls $datadir/mysql-bin.* |wc -l`
total="$(($total-2))"
for f in `ls $datadir/mysql-bin.* |head -$total`
do
mv $f $bakdir
done
cd $bakdir
for i in `ls `
do
if [ -f $i ]
then
var=${i##*.}
if [ $var == gz ]
then
continue
else
gzip -9 $i
fi
fi
done
本文转自 trt2008 51CTO博客,原文链接:http://blog.51cto.com/chlotte/544154,如需转载请自行联系原作者