Follow dba-ninja.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

dba-ninja.com Links

Dba_db2_button

Sqlserver_dba_button

How to MySQL restore files from a directory backup to their original location

16 August,2021 by Rambler

Question: I have some directory  backups available to me created using the following command line: 

mysqlbackup --defaults-file=/myfolderpath/.backup-my.cnf --backup-dir=$BKUP_DIR backup-and-apply-log

What is the procedure to restore the backup  for a point in time recovery ?

Answer: Here is a template , and it makes some assumptions - modify based on your requirements 

You'll notice in the mysqlbackup command the usage of the copy-back switch used to restore files from a directory backup to their original locations within the MySQL server.

 

You will need to first gather some values , which will be used as part of the restore command

Global variable - datadir

Global variable - innodb_log_files_in_group

Global variable - innodb_log_file_size

Global variable - innodb_data_file_path

mysql> show global variables like 'datadir';

+---------------+----------------------+

| Variable_name | Value                |

+---------------+----------------------+

| datadir       | /mypath/mysql/data/ |

+---------------+----------------------+

1 row in set (0.00 sec)

 

mysql> show global variables like 'innodb_log_files_in_group';

+---------------------------+-------+

| Variable_name             | Value |

+---------------------------+-------+

| innodb_log_files_in_group | 2     |

+---------------------------+-------+

1 row in set (0.00 sec)

 

mysql> show global variables like 'innodb_log_file_size';

+----------------------+---------+

| Variable_name        | Value   |

+----------------------+---------+

| innodb_log_file_size | 5242880 |

+----------------------+---------+

1 row in set (0.00 sec)

 

mysql> show global variables like 'innodb_data_file_path';

+-----------------------+------------------------+

| Variable_name         | Value                  |

+-----------------------+------------------------+

| innodb_data_file_path | ibdata1:10M:autoextend |

+-----------------------+------------------------+

1 row in set (0.00 sec)

------------------------------

/etc/init.d/mysql stop

------------------------------

!!!!!!!BE CAREFUL . if you attempt to execute this command over an existing directory it will fail , with a suggestion to use --force , which overwrites the existing directory. I strongly suggest you first backup the current live directory , BEFORE proceeding!!!!!!!!!!!

mysqlbackup --backup-dir=/mypath/mysql/BKUP/2021-08-11_18-30-01/ --datadir=/mypath/mysql/data/ --innodb_log_files_in_group=2 --innodb_log_file_size=5242880 --innodb_data_file_path=ibdata1:10M:autoextend copy-back

/etc/init.d/mysql start

Login to database and verify the tables


Author: Rambler (http://www.dba-ninja.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on How to MySQL restore files from a directory backup to their original location


dba-ninja.com