1、全量备份
innobackupex --defaults-file=/etc/my.cnf --user=root --password=mysql /backup/xtrabackup
备份成功后会提示:
170920 17:55:25 Executing UNLOCK TABLES
170920 17:55:25 All tables unlocked
170920 17:55:25 [00] Copying ib_buffer_pool to /backup/xtrabackup/2017-09-20_17-53-54/ib_buffer_pool
170920 17:55:25 [00] ...done
170920 17:55:25 Backup created in directory '/backup/xtrabackup/2017-09-20_17-53-54/'
MySQL binlog position: filename 'mysql-bin-3306.000026', position '154'
170920 17:55:25 [00] Writing /backup/xtrabackup/2017-09-20_17-53-54/backup-my.cnf
170920 17:55:25 [00] ...done
170920 17:55:25 [00] Writing /backup/xtrabackup/2017-09-20_17-53-54/xtrabackup_info
170920 17:55:25 [00] ...done
xtrabackup: Transaction log of lsn (1833677659) to (1833677668) was copied.
170920 17:55:25 completed OK!
并且会记录当前binlog的文件名和position点,以方便同步复制用。
2、全量恢复
停止MySQL服务
service mysql stop
删除老数据库数据目录下的所有文件
cd /mysql/data
将备份文件中的日志应用到备份文件中的数据文件上
innobackupex --detaults-file=/etc/my.cnf --apply-log /backup/xtrabackup/2017-09-20_17-53-54
事务日志恢复成功后会提示:
xtrabackup: starting shutdown with innodb_fast_shutdown = 1
InnoDB: FTS optimize thread exiting.
InnoDB: Starting shutdown...
InnoDB: Shutdown completed; log sequence number 1833677864
170920 18:10:21 completed OK!
将备份文件中的数据恢复到数据库中:
innobackupex --defaults-file=/etc/my.cnf --copy-back /backup/xtrabackup/2017-09-20_17-53-54
物理文件和事务日志恢复成功后会提示:
170920 18:15:33 [01] Copying ./weixin/admin_depart.frm to /mysql/data/weixin/admin_depart.frm
170920 18:15:33 [01] ...done
170920 18:15:33 [01] Copying ./weixin/admin_member.frm to /mysql/data/weixin/admin_member.frm
170920 18:15:33 [01] ...done
170920 18:15:33 [01] Copying ./weixin/admin_member.ibd to /mysql/data/weixin/admin_member.ibd
170920 18:15:33 [01] ...done
170920 18:15:33 [01] Copying ./weixin/admin_action.ibd to /mysql/data/weixin/admin_action.ibd
170920 18:15:33 [01] ...done
170920 18:15:33 [01] Copying ./weixin/admin_pri.frm to /mysql/data/weixin/admin_pri.frm
170920 18:15:33 [01] ...done
170920 18:15:33 [01] Copying ./weixin/admin_depart.ibd to /mysql/data/weixin/admin_depart.ibd
170920 18:15:33 [01] ...done
170920 18:15:33 [01] Copying ./weixin/wechat_conf.frm to /mysql/data/weixin/wechat_conf.frm
170920 18:15:33 [01] ...done
170920 18:15:33 completed OK!
数据恢复完成之后,需要修改相关文件的权限:
chown -R mysql:mysql /mysql/data
重启启动MySQL
service mysql start
XtraBackup全量备份与恢复
原创那海蓝蓝 博主文章分类:MySQL备份/恢复 ©著作权
©著作权归作者所有:来自51CTO博客作者那海蓝蓝的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:XtraBackup的安装与介绍
下一篇:管理二进制日志
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
DG_broker工具管理切换DG主备
DG_broker工具管理切换DG主备
oracle TCP hive -
xtrabackup热备和恢复mysql
xtrabackup热备和恢复mysql
mysql 热备 xtrabackup -
innobackupex数据全备增备恢复
innobackupex数据全备增备恢复
innobackupex数据全备增备恢复 mysql备份 -
Innobackupex MySQL 全备、增备及恢复
Innobackupex MySQL 全备、增备及恢复
Innobackupex 备份恢复 -
XBK全备及恢复演示
一介绍: 使用XBK工具的前提是需要指定mysql配置文件的位置,默认软件会去/e
mysql f5 perl