MySQL backup script

Source: Internet
Author: User
Tags mysql backup

#!/bin/sh

################################################

#this scripts is created by Tangbo

#tangbo qq:79313760

################################################

#parameter defined Start

Bakdate= ' Date +%f '

Myuser=root

Mypass= "111111"

Mysock=/data/3306/mysql.sock

Dbname= "Caiwu"

Main_path=/server/backup

Data_path=/server/backup

Log_file=${data_path}/mysql_logs_${bakdate}.log

Data_file=${data_path}/mysql_backup_${bakdate}.sql.gz


#command defined

Mysql_path=/usr/local/mysql/bin

#MYSQL_DUMP = "$MYSQL _path/mysqldump-u$myuser-p$mypass-s $MYSOCK-A-b-f--single-transaction-e"

mysql_dump= "$MYSQL _path/mysqldump-u$myuser-p$mypass-s $MYSOCK-F-B $DBNAME--DEFAULT-CHARACTER-SET=GBK-- Single-transaction-e "

#backup command

${mysql_dump} | gzip > $DATA _file

#check Backup Result

Du-sh $DATA _file > $LOG _file

Mail-s "${bakdate} mysql bak log" [email protected] < $LOG _file

################# #end ##########################


This article from "Bobcat" blog, declined reprint!

MySQL 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.