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