文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>mysql二进制日志备份

mysql二进制日志备份

时间:2009-04-30  来源:sinxadmin

#!/bin/bash


#configuration


db_user="root"
db_password="123456"
db_host="10.10.11.151"
db_port="3306"
db_name="crashcourse"
db_bin_dir="/home/mysql/log/"
db_bin_prefix="mysql"
db_binbackup_dir="/dir/logbin_backup/"
time_now=` date '+%Y%B%d%H%M%S' `

#start


#start

mysqladmin -h$db_host -P$db_port -u$db_user -p$db_password flush-logs

cd $db_bin_dir
for i in `cat ${db_bin_prefix}-bin.index`
do
        bin_list="$bin_list `basename $i`"

done
latest=$(basename `cat ${db_bin_prefix}-bin.index|tail -n1`)
backup_list=`ls $db_binbackup_dir |grep "${db_bin_prefix}-bin"`
backup_latest=`ls $db_binbackup_dir|grep "${db_bin_prefix}-bin" |tail -n1`

for j in $bin_list
do
        need_backup="YES"
        for k in $backup_list
        do
                if [ $j = $k ]
                then
                        need_backup="NO"
                fi
        done
        if [ $j = $latest ]
        then
                need_backup="NO"
        fi

        if [ $j = $backup_latest ]
        then
                need_backup="YES"
        fi

        if [ $need_backup = "YES" ]
        then
                cp $j $db_binbackup_dir
        fi
done

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载