Run a MySQL Restore Operation Using SBT from the Command Line Interface

Run a restore job to restore a backed up image to the same or a different location.

A restore job consists of the following three steps:

  1. Extracting

  2. Applying Logs and Incremental Backups

  3. Copying Back

Before You Begin

  • Before running a restore job on Linux, execute the following command on the client after substituting with parameters values.

    export LD_LIBRARY_PATH=<Software_Installation_Directory>/Base
  • Ensure that the MySQL user is a part of Commvault group.

  • Configure the command line storage policy from the CommCell Console.

Procedure for Extracting

You can extract both the full and the incremental backup images to your preferred location using the extraction method. To restore a specific backup, make sure to provide the exact backup image name in the following command.

Navigate to the bin directory of MySQL Enterprise Backup and run the following command after substituting the parameter values:

./mysqlbackup --backup-dir=<destination location for extracting> --backup-image=<image name specified during backup> --sbt-lib-path=<path to libobk.so> --sbt-database-name=<MySQL instance name> image-to-backup-dir

Navigate to the bin directory of MySQL Enterprise Backup and run out-of-place or cross-machine restore:

./mysqlbackup --backup-dir=<destination location for extracting> --backup-image=<image name specified during backup> --sbt-lib-path=<path to libobk.so> --sbt-database-name=<Source MySQL instance name> image-to-backup-dir

Example

./mysqlbackup --backup-dir=/vkm/sbt --backup-image="sbt:image1" --sbt-lib-path=/opt/software2/Base/libobk.so --sbt-database-name=myserve image-to-backup-dir

To query the image name specified during backup, run the getbackupList command.

Procedure for Applying Logs and Incremental Backups

You can first apply logs to update InnoDB tables by including any changes made to the data while full backup was running. Then apply incremental backups to update the backed up data.

The path for applying the incremental backups should be the same path where the backup image was extracted in the previous step. Before applying the incremental backup, ensure that you extract the incremental backup image as mentioned above.

Navigate to the bin directory of MySQL Enterprise Backup and run the following commands after substituting the parameter values:

./mysqlbackup --backup-dir=<directory path given for extract from full> apply-log
./mysqlbackup --incremental-backup-dir=<directory path given for extract from incremental backup> --backup-dir=<directory path given for extract from full> apply-incremental-backup

Example

./mysqlbackup --backup-dir=/vkm/sbt apply-log
./mysqlbackup --incremental-backup-dir=/vkm/sbtinc --backup-dir=/vkm/sbt apply-incremental-backup

Procedure for Copying Back

You can restore files from a backup either to the same location from where it was backed up within a MySQL server or to another MySQL server instance.

Before You Begin

  • Stop the MySQL server.

  • Rename or delete the MySQL data directory.

Navigate to the bin directory of MySQL Enterprise Backup and run the following commands after substituting the parameter values:

./mysqlbackup --defaults-file=<MySQL configuration file location> --backup-dir=<directory path given for extract from full> --datadir=<MySQL data directory path> copy-back

Example

./mysqlbackup --defaults-file=/usr/my.cnf --backup-dir=/vkm/sbt2 --datadir=/var/lib/mysql copy-back

Available Parameters

The following table displays all the parameters you can use with the commands mentioned in the above sections.

Parameter

Description of Parameter Values

--defaults-file

MySQL configuration file.

--socket

Path of the socket file.

--sbt-lib-path

Location of libobk.so.

--sbt-database-name

MySQL instance name in the CommCell Console. Instance name should not contain more than 8 characters.

--backup-image

Image name unique for each backup.

--backup-dir

Path to the staging directory. Provide a directory name that does not exist in the staging directory location.

getbackupList Command

The getbackupList utility lists the backup image names for all the backup jobs run on that client. Use the following command to query the backup job history and find the backup image name. You can use the image name for extracting the backup image during restore.

From Command prompt, navigate to Software_Installation_Directory/Base, and execute the following command after substituting with suitable values.

./getbackupList -jobid <job ID> -outfile </tmp/xxxx.out> -dbjob

Example

./getbackupList -jobid 332 -outfile /tmp/mysql.out -dbjob

To query the job ID of a backup job, run the qlist jobhistory command.

qlist jobhistory Command

The qlist jobhistory utility lists the job ID, associated storage policy and the status of all the backup jobs run on that client. Use the following command to query the job ID for a specific backup job.

  1. From Command prompt, navigate to Software_Installation_Directory/Base and run the following command:

    qlogin -cs <commserve name> -u <user name>

  2. Execute the following command from the Software_Installation_Directory/Base folder after substituting with suitable values.

    ./qlist jobhistory -c <client name> -a Q_MYSQL -i <instance_name>

Example

./qlist jobhistory -c test -a Q_MYSQL -i mytest

Because the output includes backup history of all the subclients, look for job IDs of command line subclients only. Substitute the required job ID in the getbackupList command for extracting the backup image during restore.

In case of an error, an error code and error description are displayed in the following format:

jobhistory: Error errorcode: error_description

Loading...