MySQL Linux backup script

Source: Internet
Author: User

  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"

MySQL Linux backup script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.