Mysqldump Full backup Script mysqlallbackup.sh

Source: Internet
Author: User
Tags mysql backup

Library small, about 16G, daily increment is very small, less than 100M, so with mysqldump daily full-scale backup, the backup result information sent to the email notification DBA.


mysqlallbackup.sh


: MySQL DataBase full Backup.

# Use mysqldump--help get more detail.
# 20.20.21.11:mysqla
#
Set-x
# define Data directy
Mysqldir=/usr/local/mysqla
# Defile User,pwd
Databackupdir=/data/backup
emailfile= $dataBackupDir/email.txts
# email
[Email protected]
# backup File
logfile= $dataBackupDir/mysqlbackup.log
#DATE = ' Date-l '
echo "Full backup of the database on 10.80.21.12 begin ..." > $eMailFile
echo $ (date +%y-%m-%d-%h:%m:%s) >> $eMailFile


CD $dataBackupDir
# defile FileName
dumpfile=20_20_21_11_mysqla_$ (date +%y%m%d_%h%m%s). sql
gzdumpfile=20_20_21_11_mysqla_$ (date +%y%m%d_%h%m%s). sql.tar.gz
# $mysqlDir/bin/mysqldump-uroot-pxxxxx--skip-opt--default-character-set=utf8--extended-insert=false--triggers-r --hex-blob--all-databases--flush-logs--delete-master-logs--delete-master-logs--lock-tables=false > $dumpFile
/usr/local/mysqla/bin/mysqldump-uroot-p ' mbkangsheng#@!2010611 '-s/tmp/mysqla.sock--default-character-set=utf8-- Extended-insert=false--triggers-r--skip-opt--hex-blob--all-databases--master-data=1--flush-logs > $dumpFile
if [[$?==0]]; Then
echo "BackupFileName: $GZDumpFile" >> $eMailFile
echo "DataBase Backup success!" >> $eMailFile
Else
echo "DataBase Backup fail!" >> $emailFile
Fi
echo "--------------------------------------------------------" >> $logFile

Cat $eMailFile >> $logFile


# Send Email

Cat $eMailFile | Mail-s "MySQL Backup" $eMail

Mysqldump Full backup Script mysqlallbackup.sh

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.