#!/bin/bash
bakdir=/home/webdata/mysqlbackup/mysqlbackup_log/
bindir=/home/mysql/var/
Logfile=/home/webdata/mysqlbackup/mysqlbackup_log/bak.log
Binfile=/home/mysql/var/mysql-bin.index
Mysqldump-udearedu-p--lock-tables--flush-logs--master-data=1 vkt >/home/webdata/mysqlbackup/mysqlbackup_log/ Vkt.backup
# # # Refresh the log, generate a new log and copy it to the appropriate directory
Counter= ' wc-l $BinFile |awk ' {print $} ' # # # is calculated inside the bin-log index. Binlog number of logs
Nextnum=0
For file in Cat $BinFile '
Do
Base= ' basename $file ' get rid of./File name
nextnum= ' expr $NextNum + 1 '
If [$NextNum-eq $Counter]
Then
Echo $base skip! >> $LogFile
Else
dest= $BakDir/$base
if (test-e $dest)
Then
Echo $base exist! >> $LogFile # # # # Skip the last bin_log log because the last log is being recorded
Else
CP $BinDir/$base $BakDir
echo $base copying >> $LogFile
Fi
Fi
Done
/usr/bin/expect<<eof
# # # introduced expect, for interactive login, ordinary Shell script can not be interactive, enter password automatically login mysql
# # #下面是自动拷贝到备份服务器
Set timeout 300;
Spawn Scp-r $BakDir 192.168.0.90:/sde/50_mysqlbackup
Expect "*password:"
Send "password\r"
Sleep 1
Expect 1
Expect EOF
Eof
This article is from the "full of Handsome Technology blog" blog, please be sure to keep this source http://manyushuai.blog.51cto.com/8818545/1733283
MySQL Incremental backup script