MySQL backup script

Source: Internet
Author: User
Tags mysql backup

Perform a full hot backup of the Extmail database daily 01:00, and you can fully recover!

First, create a backup script, as follows:

1234567891011121314151617 vimysql_extmail_bak.sh#!/bin/bash# Program#    use mysqldump to Fully backup mysql data per week!BakDir=/mysqlback#要备份到的目录LogFile=/var/log/bak.log#备份记录日志Date=`date+%Y%m%d`Begin=`date+"%Y年%m月%d日 %H:%M:%S"`cd $BakDirDB=extmail#要备份的数据库名称DumpFile=$DB$Date.sqlGZDumpFile=$Date.sql.tar.gz/usr/bin/mysqldump-uroot -p123123 --quick --databases $DB --flush-logs --single-transaction > $DumpFile/bin/tarczvf $GZDumpFile $DumpFile/bin/rm $DumpFileLast=`date +"%Y年%m月%d日 %H:%M:%S"`echo开始:$Begin 结束:$Last $GZDumpFile succ >> $LogFile

Second, restore the backup SQL file as follows:

1234 cd/mysqlbacktarzxvf extmail20170515.tar.gzmvextmail20170515.sql extmail.sqlmysql -uroot -p < extmail.sql


This article from "12016522" 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.