码迷,mamicode.com
首页 > 数据库 > 详细

mysql linux 备份脚本

时间:2014-05-19 10:58:24      阅读:360      评论:0      收藏:0      [点我收藏+]

标签:class   c   tar   a   get   cti   

  1. #!/bin/sh
  2. # mysql data backup script
  3. #
  4. # use mysqldump --help,get more detail.
  5. #
  6. BakDir=/root/back/mysql
  7. LogFile=/root/back/mysql/mysqlbak.log
  8. DATE=`date +%Y%m%d%H%M%S`
  9. echo " " >> $LogFile
  10. echo " " >> $LogFile
  11. echo "-------------------------------------------" >> $LogFile
  12. echo $(date +"%y-%m-%d %H:%M:%S") >> $LogFile
  13. echo "--------------------------" >> $LogFile
  14. cd $BakDir
  15. DumpFile=$DATE.sql
  16. GZDumpFile=$DATE.sql.tar.gz
  17. /usr/local/bin/mysqldump -u user -pname  --database -h 127.0.0.1 db> $DumpFile
  18. echo "Dump Done" >> $LogFile
  19. tar czvf $GZDumpFile $DumpFile >> $LogFile 2>&1
  20. echo "[$GZDumpFile]Backup Success!" >> $LogFile
  21. rm -f $DumpFile
  22. #cd $BakDir/daily
  23. cd $BakDir   
  24. echo "Backup Done!"
  25. echo "please Check $BakDir Directory!"
  26. echo "copy it to your local disk or ftp to somewhere !!!"
  27. find $BakDir -ctime +30 -exec rm {} \;
  28. echo "delete file over 30 days"

其中user,name和db请根据自己的情况修改

mysql linux 备份脚本,布布扣,bubuko.com

mysql linux 备份脚本

标签:class   c   tar   a   get   cti   

原文地址:http://www.cnblogs.com/xred/p/3731839.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!