mysql增量恢復指令碼

pathfinder_cui發表於2015-07-16
#!/bin/sh
bindir="/data/mysql/bin/"
binlogdir="/backup"
username="root"
passd="wanyin"
sock="/data/mysql/data/mysqld-3304.sock"
for filename in $(ls -l ${datadir}mysql-bin.[0-9]* | awk '{print $9}')
do
${bindir}mysqlbinlog -d wy_sso --base64-output=decode-rows -v  $filename | ${bindir}mysql -u${username} -p${passd} --socket=${sock} >log.txt 2>log.err
  if [ "$?" -eq 0 ] ; then
   echo "${filename} has been recovered."
  else
   echo "${filename} has not been completed"
   break
  fi
done

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29620572/viewspace-1735082/,如需轉載,請註明出處,否則將追究法律責任。

相關文章