首页 > 数据库技术 > 详细

mysql linux 备份脚本

时间:2014-05-19 10:55:27      阅读:434      评论:0      收藏:0      [点我收藏+]
  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 备份脚本

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!