MySQL hot backup and restore---Leverage mysqldump---backup scripts

Source: Internet
Author: User

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

First, create a backup script, as follows:

VI mysql_extmail_bak.sh#!/bin/bash# program# use mysqldump to Fully backup MySQL data per week! bakdir=/mysqlback# the directory to be backed up logfile=/var/log/bak.log# backup log date= ' date +%y%m%d ' begin= ' date + '%Y year%M month%d Day%h:%m:%s ' CD $ bakdirdb=extmail# the name of the database to be backed up dumpfile= $DB $date.sqlgzdumpfile= $Date. sql.tar.gz/usr/bin/mysqldump-uroot-p123123-- Quick--databases $DB--flush-logs--single-transaction > $DumpFile/bin/tar czvf $GZDumpFile $DumpFile/bin/rm $ dumpfilelast= ' date +%y year%M month%d day%h:%m:%s ' echo start: $Begin end: $Last $GZDumpFile succ >> $LogFile

Second, restore the backup SQL file as follows:

Cd/mysqlbacktar zxvf extmail20170515.tar.gzmv extmail20170515.sql extmail.sqlmysql-uroot-p < Extmail.sql

Attached mysqldump parameter description: http://www.cnblogs.com/wxb-km/p/3610594.html this big Brother writes very detailed!

MySQL hot backup and restore---Leverage mysqldump---backup scripts

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.