Archive:SEP sesam Extension for MySQL

From SEPsesam

SEP sesam Extension for MySQL

(C)SEP AG

Copyright 1999-2011 by SEP AG. All Rights reserved.

Any form of reproduction of the contents or parts of this manual is allowed only with the express written permission from SEP AG. When compiling and designing user documentation SEP AG uses great diligence and attempts to deliver accurate and correct information. However, SEP AG cannot issue a guarantee for the contents of this manual.


Introduction

The SEP sesam extension for MySQL allows an online backup of one or more MySQL databases at run time. This includes the backup and restore of one or all databases of a MySQL database server. For backup the MySQL backup program mysqldump and for restore the program mysql will be be used. Only the programs of the database manufacturer can guarantee that the data can backup in a consistent status.


ATTENTION

All database backup options in the documentation are neither parts nor components of SEP sesam. These are only recommendations and examples of how you can backup a MySQL database. There are many different fields of application for using a MySQL database. Therefore we can only show a few parameters to using during backup. Additional information of MySQL backup policies and strategies please see the MySQL documentation and the man pages of mysqldump und mysql.

Prerequisites

  • MySQL server version > 4.1 auf Linux (e.g. RHEL 4/5 und SLES 9/10)
  • SEP Sesam server version >= 3.4.1.X
  • Sesam client >= 3.4.1.51 on the MySQL database host
  • SEP sesam Extension for MySQL only, if the version of the installed Sesam client <3.6. The Sesam client >= version 3.6 already includes the MySQL extension. In this case the installation steps can be skipped.
  • Functioning SEP sesam filesystem backup

Installation Sesam Client 3.4

RPM

The RPM installation is the privileged installation method of the MySQL extension.

  • Please make sure that the Sesam client RPM is already installed
  • A path backup has to be possible with this client

Install or update the SEP sesam MySQL online extension by:

rpm -Uhv sesam_mysql-3.4.1-100.i386.rpm

Tarball

  • Be sure that the Sesam client is already installed
  • A path backup has to be possible with this client
  • Log in as user root
  • Unpack the Tarball to a temporary location (e.g. /tmp
  • Copy the MySQL components to binary directory of the Sesam client

Example:

cd /tmp
tar xvzf sesam-mysql.tgz
cp /tmp/sesam-mysql/* /opt/sesam/bin/sesam/

Installation Sesam Client 3.6

As with Sesam Client 3.6 the MySQL Extension is included in the Client package, no further Extensions have to be installed!

Backup Configuration

The configuration will be executed in the SEP sesam GUI.

  • Create a new backup task
  • Select MySQL as Backup type
  • Enter the MySQL database name in the field Source
  • On the page Options 1 you can define additional parameters for backup and restore. Details described in the section "Backup & Restore".


Info

It is recommend to set the user and password options of restore to the same values as the backup options. If necessary you can set the restore options in the Restore Wizard at the time of restore.

  • As Source you can enter the following values:
    • <DB_NAME>
      Backup of single database (e.g. my_db) Watched: the database name has to be entered case sensitive
    • DB:<DB_NAME>
      Backup of a single database (e.g. DB:my_db). The difference to the statement above in the backuped dump is that a CREATE DATABASE statement will be inserted
    • all
      Backup of all databases of the MySQL server
  • On the page Options 1 you can define additional parameters for backup and restore
    Here are some examples:
  • To set user and password to log on at the database:
-a user=<DBuser>,password=<password of DBuser>
  • Login information can also be specified in $HOME/.my.cnf on client side:
 root@mysql:~# cat .my.cnf
 [client]
 user=root
 password=secret
 root@mysql:~#


  • It's also possible to use /etc/my.cnf:
 [client]
 user=root
 password=secret


  • Another config file can be specified by setting --defaults-file variable
  -a defaults-file=/var/opt/sesam/var/opt/sesam/sm_mysql.cnf


Info

The previous configuration of the username and password by entries in the sm.ini-file of the client is not necessary anymore. These settings will be executed in the Sesam GUI.

b) For a better throughput during backup of MySQL database type ISAM. Do not use this option for InnoDB:

-a opt

c) For a consistent backup of a MySQL database of type InnoDB:

-a single-transaction

d) You can combine different parameters into one statement:

-a user=<DBuser>,password=<Passwort_DBusers>,opt,single-transaction


ATTENTION
  1. Specify the mysqldump parameter without any double hyphen. Sesam translates the given parameter into the right format when calling the MySQL program.
  2. The option line behind the -a may not contain any blanks.

Restore Configuration

A restore will be started by calling the restore wizard. First, select the backup job, then the period of time and then select the desired backup job for restore. There are 2 options:

  • No recover after restore
    The restore stores the data as a Dump file in the Sesam Work directory (usually /var/opt/sesam/var/work of the Sesam client or in older versions in /opt/sesam/bin/sesam). The name of the file comprise of the prefix mysql-, the Saveset-ID and the suffix .tmp. This file can import into the database by MySQL command mysql.
 Example: mysql < /var/opt/sesam/var/work/mysql-SF20081128224529.tmp
  • Auto recover after restore
    The data will be stored directly into the database without caching in the filesystem.


ATTENTION

If you use the option Auto recover after restore the database has to exist already, if not the restore will fail. Also, set the option overwrite existing files to overwrite an existing database.

If the CREATE DATABASE Statement is not in the backuped data, the data can only be restored into the same database. It's not possible to change the restore target.

In the case of a restore to a different database only the option no recover after restore is possible. Then you can edit the Dump file in the filesystem manually and import it as described above.

Backup configuration for special MySQL 5.0 features (Stored Procedures, Triggers)

By default the SEP Sesam software does not backup Stored Procedures or defined Triggers. However, it is also possible to use the Sesam backup client for backing up the Stored Procedures and Triggers defined in a database.

The can be enabled in the task properties from a backup job.

Backup Stored Procedures

The following example shows how to backup Stored Procedures with Sesam. Switch to Options 1 from the task and add

-a routines

in the additional save options field, like shown in this screenshot:

Mysql stored procedures.jpg

Backup defined Triggers

Just like Stored Procedures, it is also possible to add additional options to enable Triggers. Add the parameter

-a triggers

like shown in this screenshot:

Mysql triggers.jpg

Of course it is also possible to define multiple statements, backing up both Stored Procedures and Triggers with:

-a routines -a triggers

Troubleshooting

MySQL Backup fails with mysqldump: Error 2013: Lost connection to MySQL server during query'

This error occurs mostly while backing up MySQL databases to tape devices. The reason for this is the MySQL Setting net_write_timeout, which defaults to a value of 60 seconds.

The tape open can take longer than 60 seconds, as such, the MySQL database resets the connection during the backup process.

This problem can be solved by adding a higher value for the variable net_write_timeout in /etc/my.cnf.

In section

[mysqld]
 ... other options ..
net_write_timeout = 180

after adding this setting, restart your mysql daemon. If a restart is not possible the setting can also be applied online, but is lost after next restart:

# mysql -u root -p -e "set global net_write_timeout=180;"

If 180 seconds are set and the backup is still failing with the same error message, try to use a higher value for the timeout.

MySQL Backups with passwords that contain special characters / General password security

There may be problems during the backup if the password of the user that's supposed to execute the backup contains special characters. In general, the use of apostrophies as well as mutated vowels is suppressed in the GUI.

In this case - as for all MySQL backups - it's recommended to store the password in a special configuration file instead of the task. Another advantage of this is that the password doesn't appear in the SEP sesam logging.

Using the configuration file ".my.cnf" for the password

You have the option to create a configuration file with the name".my.cnf". This file has to be stored in

/.my.cnf

so the SEP sesam client can read it correctly.

The file has the following content:

[client]
password="mysqlpw"

The options in the GUI then only include the statement:

-a user=username

The password is then read from the configuration file during the backup.

Further Links/Literature