Restoring Binary Mode Backup with Prepare

If the Prepare has already been done during the backup because you used the prepare option on the plugin, you will not need to manually do the Prepare. This can save considerable time.

First, you should use the Bacula restore and select a Full backup to be restored. Once the files are restored to a suitable directory, you will find something similar to the following directory structure:

@MYSQL/main/all-databases.xbstream
@MYSQL/main/my.cnf
@MYSQL/main/mysql.dat

Once you have restored the backup content with Bacula, if you didn’t choose automatic extraction with restore_extract or extract_restored_xbstream, you can then restore the data using the -x option on xbstream (or mbstream for MariaDB version 10 or greater) as in the following example:

% cd @MYSQL/main
%ls
all-databases.xbstream my.cnf   mysql.dat
# Now extract the all-databases.xbstream
% xbstream -x < all-databases.xbstream
% ls
all-databases.xbstream mysql               xtrabackup_checkpoints
backup-my.cnf          performance_schema  xtrabackup_info
ib_buffer_pool         regress             xtrabackup_logfile
ibdata1                sys
my.cnf                 testdb

Now the files in the local directory are ready to be used by the server. The --copy-back option on innobackupex will copy the prepared data back to its original location as defined by the datadir in your my.cnf. Note that you can use --defaults-file=/path/to/my.cnf to specify the my.cnf configuration file.

However, before innobackupex will allow you to overwrite the original MySQL data files, you must either move them or remove them. For example, either:

% rm -rf /var/lib/mysql

or

% mv /var/lib/mysql /var/lib/mysql.old

If you are running on a server where the MySQL data files are kept in a different directory, you will need to adjust the above paths.

Now you can actually copy the files back with:

% innobackupex --copy-back $PWD
...
120604 02:58:44  innobackupex: completed OK!

For MariaDB version 10 or greater, use the mariabackup command with the parameter --innobackupex and the same arguments instead:

% mariabackup --innobackupex --copy-back $PWD

You should check the file permissions after copying the data back. You may need to adjust them with something like:

% chown -R mysql:mysql /var/lib/mysql

Now the datadir contains the restored data. You are ready to re-start the server, typically with something like:

% service mysql start

If the MySQL server does not start it may be due to SELinux or AppArmor. If SELinux is enabled, please reset the security context as root with the command below:

# restorecon -R /var/lib/mysql/

If the restart issue is due to AppArmor denials, until you solve the problems, you can temporarily disable apparmor with the following command:

% apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld

The opposite of the above is the following:

% apparmor_parser -a /etc/apparmor.d/usr.sbin.mysqld

Note

In the above two examples, mysqld is spelled with a d on the end in contrast to the service name where the name is simply mysql.

Finally, if you want to completely remove your database and create a new empty one, the following commands may help:

% rm -rf /var/lib/mysql          # Remove any old database setup
% mysql_install_db -u mysql      # Install new database
% systemctl unmask mysql.service # Emables the service for systemd
% service mysql start            # start the service.

Go back to the Restoring Complete Server Using Binary Mode (Percona).

Go back to the Restore page.

Go back to the main Operations page.