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