Home >Database >Mysql Tutorial >mysql 复原与备份

mysql 复原与备份

WBOY
WBOYOriginal
2016-06-07 16:24:511084browse

mysql 还原与备份 mysql还原与备份: 1、备份(我采用的是全备份,另外还有增量备份,没去仔细研究) #!/bin/bash log=sgpoker01_`date +%y%m%d%H%M`.log str=sgpoker01_`date +%y%m%d%H%M`.tar.gz pwd="" innobackupex --defaults-file=/etc/my.cnf.xtrabackup

mysql 还原与备份
mysql还原与备份:
1、备份(我采用的是全备份,另外还有增量备份,没去仔细研究)
#!/bin/bash
log=sgpoker01_`date +%y%m%d%H%M`.log
str=sgpoker01_`date +%y%m%d%H%M`.tar.gz
pwd=""
innobackupex --defaults-file=/etc/my.cnf.xtrabackup --databases=$1 --stream=tar  --no-lock /data/db_back/ 2>/data/db_back/$log | gzip 1>/data/db_back/$str

2、还原
---如果存在先删除库
---停止msql
---mkdir dd
---tar -izxvf ****.tar.gz -C dd
---innobackupex --defaults-file=/etc/my.cnf.xtrabackup --apply-log dd/
(这一步,dd目录下会生成ib_logfile,另外一定要指定配置文件,与备份采用的配置文件保持一致)
---将dd下要还原的库文件,ib_logfile0,ib_logfile1,ib_data1拷贝到mysql的datadir下面,我的是在/data/mysql
---chown -R mysql:mysql /data/mysql/
---启动msyql
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn