备份数据库:
/usr/local/kkmail/service/mysql/bin/mysqldump -u kkmail -p --databases kkmail |gzip>20180309.sql.gz


还原数据库:
停止和数据库相关的服务、解压备份的sql数据库文件、还原数据库、最后开启这些服务:
for i in kkmail_app kkmail_nginx kkmail_apache kkmail_dovecot kkmail_redis kkmail_postfix;do /etc/init.d/$i stop;done
gunzip 20180309.sql.gz
/usr/local/kkmail/service/mysql/bin/mysql -ukkmail -p kkmail <20180309.sql
for i in kkmail_app kkmail_nginx kkmail_apache kkmail_dovecot kkmail_redis kkmail_postfix;do /etc/init.d/$i start;done
思考:备份的时候是否要锁表。