mysqldump定时备份脚本

[mysql@mysql scripts]$ cat backup_db.sh 
#!/bin/bash  
#This is mysql mysql backup scripts  
#2015-05-01  
database=test  
databak_dir=/backup/bak
logs_dir=/backup/logs  
dumpbin=/u01/my3306/bin/mysqldump  
  
DATE=$(date +%Y%m%d)  
logFile=$logs_dir/mysql$DATE.log  
  
echo "  " > $logFile  
echo "-----------------------------------" >> $logFile  
echo "mysql backup start" >> $logFile  
echo $(date +"%y-%m-%d %H:%M:%S") >> $logFile  
echo "-----------------------------------" >> $logFile  
  
$dumpbin -uroot -pmysqld --databases $database >$databak_dir/mysql_bak$DATE.sql  
  
echo "-----------------------------------" >> $logFile  
echo "mysql backup end" >> $logFile  
echo $(date +"%y-%m-%d %H:%M:%S") >> $logFile  
echo "-----------------------------------" >> $logFile  

你可能感兴趣的:(mysql)