Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use innobackupex to restore mysql databases

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article focuses on "how to use innobackupex to restore mysql database", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to use innobackupex to recover mysql database".

After backing up the database using innobackupex, refer to: http://blog.itpub.net/28536251/viewspace-2141029/, if you want to restore, it is also very simple.

Assuming that the current mysql database is inaccessible, there is a full backup of 2017-06-20 16-33-30 and an incremental backup of 2017-06-20 16-48-49 on another machine.

1. Obtain backup files

[root@my1 ~] # mkdir / var/lib/mysql/bakup

[root@my1 ~] # chown mysql:mysql / var/lib/mysql/bakup

[root@my1] # scp-r root@192.168.254.151:/var/lib/mysql/backup/innobackupex/2017-06-20 * / var/lib/mysql/bakup

[root@my1 ~] # ll-rth / var/lib/mysql/bakup

Total 8.0K

Drwxr-x--- 7 root root 4.0K Jun 21 18:06 2017-06-20 years 16-33-30

Drwxr-x--- 7 root root 4.0K Jun 21 18:06 2017-06-20 years 16-48-49

2. Preparatory work

Install backup recovery tool reference: http://blog.itpub.net/28536251/viewspace-2141029/

[root@my1 ~] # mkdir / var/lib/mysqlreco

[root@my1 ~] # chown mysql:mysql / var/lib/mysqlreco

[root@my1 ~] # grep datadir / etc/my.cnf

# datadir=/var/lib/mysql

Datadir=/var/lib/mysqlreco

[root@my1 ~] # / etc/init.d/mysql.server status

MySQL is not running [FAILED]

[root@my1] # innobackupex-- defaults-file=/etc/my.cnf-- apply-log-- redo-only / var/lib/mysql/bakup/2017-06-20 16-33-30 /

.

170621 18:11:53 completed OK!

Parameters:

●-- apply-log: read the configuration information from the specified options file and apply the log, etc., which means that what you want to do is to prepare for the backup set recovery. To restore, this parameter must be specified.

●-- redo-only: this parameter must be specified if there are other incremental backup sets to be processed after the backup set operation that is being prepared is complete. If there is no incremental backup, then this parameter does not need to be specified.

You do not need to specify username and password parameters when ● recovers.

Incremental backup is applied. The backup set to be operated this time is the last. You no longer need to specify the-- redo-only parameter:

[root@my1] # innobackupex-- defaults-file=/etc/my.cnf-- apply-log / var/lib/mysql/bakup/2017-06-20 16-33-30 /-- incremental-dir=/var/lib/mysql/bakup/2017-06-20 16-48-49 /

.

170621 18:16:14 completed OK!

Parameters:

●-- incremental-dir: specifies the path to the incremental backup set.

3. Perform recovery

[root@my1] # innobackupex-- defaults-file=/etc/my.cnf-- copy-back / var/lib/mysql/bakup/2017-06-20 16-33-30 /

.

170621 18:20:35 completed OK!

Parameters:

●-- copy-back: from the backup path, copy the file back to the path specified by the initialization option.

4. Start verification

[root@my1] # chown-R mysql:mysql / var/lib/mysqlreco

[root@my1 ~] # / etc/init.d/mysql.server start

Starting MySQL. [OK]

[root@my1] # mysql-uroot-p123456-e "select * from test.test4"

Mysql: [Warning] Using a password on the command line interface can be insecure.

+-+

| | v1 |

+-+

| | aa |

| | bb |

+-+

At this point, I believe you have a deeper understanding of "how to use innobackupex to recover mysql databases". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report