Name

mylvmbackup — utility for creating MySQL backups via LVM snapshots

Synopsis

mylvmbackup [OPTIONS]

DESCRIPTION

mylvmbackup is a tool for quickly creating backups of MySQL server's data files. To perform a backup, mylvmbackup obtains a read lock on all tables and flushes all server caches to disk, makes an LVM snapshot of the volume containing the MySQL data directory, and unlocks the tables again. The snapshot process takes only a small amount of time. When it is done, the server can continue normal operations, while the actual file backup proceeds.

The LVM snapshot is mounted to a temporary directory and all data is backed up using the tar program. The archive file is created using a name of the form backup-YYYYMMDD_hhmmss_mysql.tar.gz, where YYYY, MM, DD, hh, mm, and ss represent the year, month, day, hour, minute, and second of the time at which the backup occurred. The prefix backup and the date format can be modified. The use of timestamped archive names allows you to run mylvmbackup many times without danger of rewriting old archives.

It is necessary to run mylvmbackup on the same host where the MySQL server runs. If your MySQL daemon is not listening on localhost or using the default socket location, you must specify --host or --socket. Even though mylvmbackup communicates with the server through a normal client connection to obtain the read lock and flush data, it makes the backup by accessing the file system directly. It is also necessary that the MySQL server data directory resides on an LVM volume. (It is, however, a good idea to do the LVM backup to a different partition than the one where the data directory resides. Otherwise, there is a good chance that LVM will run out of undo space for LVM snapshot maintenance and the backup will fail.)

The user who invokes mylvmbackup must have sufficient filesystem permissions to create the LVM snapshot and mount it. This includes read/write access to the backup directory.

OPTIONS

mylvmbackup supports the following command line options. The same options can also be defined in the /etc/mylvmbackup.conf configuration file.

--user=string
Specifies the username to use for connecting to the MySQL server. The default is root.
--password=string
Specifies the password to use for connecting to the MySQL server. The default is the empty string (no password).
--host=string
Specifies the host name to use for connecting to the MySQL server. The default is the empty string.
--port=number
Specifies the TCP port number to use for connecting to the MySQL server. The default is 3306.
--socket=string
Specifies the path to the local socket file, if it is not located at the default location. The default is the empty string.
--innodb_recover
Run InnoDB recovery on the writable snapshot (LVM2 only) prior to performing the backup.
--lvcreate=string
Specifies the pathname for the lvcreate program. The default is /sbin/lvcreate.
--lvremove=string
Specifies the pathname for the lvremove program. The default is /sbin/lvremove.
--vgname=string
Specifies the volume group of the logical volume where the MySQL data directory is located. The default is mysql.
--lvname=string
Specifies the name of the logical volume where the MySQL data directory is located. The default is data.
--relpath=string
Relative path on the logical volume to the MySQL data directory. The default is the empty string.
--lvsize=string
Specifies the size for the snapshot volume. The default is 5G (5 gigabytes).
--prefix=string
Prefix added to the backup file names. It is also appended to the name of the directory used to mount the snapshot volume. The default value is backup.
--datefmt=string
Format of the time stamp included in the backup file name. See the date(1) man page for a description of the format. The default value is %Y%m%d_%H%M%S.
--mountdir=string
Path for mounting the snapshot volume to. The default value is /var/tmp/mylvmbackup/mnt/.
--backupdir=string
Specifies the pathname of the directory where the archive files will be written to. The backup directory must not be on the same volume as the MySQL data directory. The default is /var/tmp/mylvmbackup/backup/
--mount=string
Specifies the pathname for the mount program. The default is /bin/mount.
--umount=string
Specifies the pathname for the umount program. The default is /bin/umount.
--tar=string
Specifies the pathname for the tar program. The default is /bin/tar.
--xfs
Use the nouuid mount option to safely mount snapshot partitions that use the XFS file system.
--log_method=string
How to log output from this script. Valid options are console, syslog or both. The default value is console.
--syslog_socktype=string
What type of socket to use for connecting to the syslog service. Valid options are native, tcp and udp. The default value is native.
--syslog_facility=string
Define a particular syslog facility Default value is the empty string.
--syslog_remotehost=string
Host name of a remote syslog server.
--configfile=string
Specify an alternative configuration file. The default is /etc/mylvmbackup.conf.
--help
Displays a help message showing the available options.

FILES

/etc/mylvbackup.conf
The mylvmbackup configuration file
mylvmbackup
The executable Perl script that performs the work.

REQUISITES

mylvmbackup is a Perl script that uses DBI to access the MySQL server. For proper operation, it requires that Perl be installed, as well as the DBI and DBD::mysql modules. For reading the configuration file, the Config::IniFiles Perl module is required as well. In addition, mylvmbackup uses several other programs: date to constuct the archive filename, tar to back up data, LVM utilities to create and remove the LVM snapshot, and the system utilities mount and umount.

SEE ALSO

date(1), mount(8), tar(1), lvcreate(8), lvremove(8), umount(8)

AUTHOR

This program was initially written by Aleksey "Walrus" Kishkin from MySQL AB, with suggestions from Peter Zaitsev and Lenz Grimmer.

It is currently maintained by Lenz Grimmer, <lenz@grimmer.com>

RESOURCES

Main web site: http://www.lenzg.org/mylvmbackup/

CREDITS

Robin H. Johnson from the Gentoo project cleaned up the code and added several useful features. See the ChangeLog for more details.

Fred Blaise contributed the initial support to use an external configuration file and logging via syslog.

COPYING

mylvmbackup is distributed under the GNU public license. See the file COPYING for details.