.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "MYLVMBACKUP 1" .TH MYLVMBACKUP 1 "2022-09-22" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" mylvmbackup \- a utility for creating MySQL backups using LVM snapshots .SH "SYNOPSIS" .IX Header "SYNOPSIS" mylvmbackup [\s-1OPTIONS\s0] .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fImylvmbackup\fR is a tool for quickly creating full physical backups of a MySQL server's data files. To perform a backup, \fImylvmbackup\fR obtains a read lock on all tables and flushes all server caches to disk, makes an \s-1LVM\s0 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. .PP The \s-1LVM\s0 snapshot is mounted to a temporary directory and all data is backed up using the \fItar\fR program by default. The archive files are created using names in the form of \fIbackup\-YYYYMMDD_hhmmss_mysql.tar.gz\fR, where \fI\s-1YYYY\s0\fR, \fI\s-1MM\s0\fR, \&\fI\s-1DD\s0\fR, \fIhh\fR, \fImm\fR and \fIss\fR represent the year, month, day, hour, minute, and second of the time at which the backup occurred. The default prefix \&\fIbackup\fR, date format and file suffix may be modified. The use of timestamped archive names allows you to run \fImylvmbackup\fR many times without risking to overwrite old archives. It is possible to preserve only a defined number of last backups, to avoid running out of disk space. .PP Alternatively, instead of \fItar\fR, you can use \fIrsync\fR, \fIrsnap\fR or \fIzbackup\fR to perform the archiving. .PP The \fIrsync\fR backup can perform both local backups as well as backing up to a remote server using rsyncd or rsync via \s-1SSH.\s0 .PP \&\fIrsnap\fR is a wrapper around \fIrsync\fR to automatically maintain and rotate a given number of last backups (7 by default). It utilizes hard links to link to unchanged files for saving disk space. .PP \&\fIzbackup\fR is a globally-deduplicating backup tool. Feed a large .tar into it, and it will store duplicate regions of it only once, then compress and optionally encrypt the result. Feed another .tar file, and it will also re-use any data found in any previous backups. This way only new changes are stored, and as long as the files are not very different, the amount of storage required is very low. Any of the backup files stored previously can be read back in full at any time. .PP Moreover, a backup type \fInone\fR is provided for cases where the user wants to use \fImylvmbackup\fR only for creating the snapshots and intends to perform the actual backup by using the appropriate hooks. (Or for cases where the snapshot itself is considered to be the backup). .PP \&\fImylvmbackup\fR also provides several methods for logging and reporting the progress and success of a backup run. The log messages can either be printed to the console (\s-1STDOUT\s0) or logged via \fIsyslog\fR. Additionally, a report can be sent to you via email. .SH "GENERAL HINTS" .IX Header "GENERAL HINTS" It is required to run \fImylvmbackup\fR 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 \fI\-\-host\fR or \fI\-\-socket\fR. Even though \&\fImylvmbackup\fR communicates with the server through a normal client connection to obtain the read lock and flush data, it performs the actual backup by accessing the file system directly. It is also a requirement that the MySQL server's data directory resides on an \s-1LVM\s0 volume. (It is, however, a good idea to do the \s-1LVM\s0 backup to a different partition than the one where the data directory resides. Otherwise, there is a good chance that \s-1LVM\s0 will run out of undo space for \s-1LVM\s0 snapshot maintenance and the backup will fail.) .PP The user who invokes \fImylvmbackup\fR must have sufficient filesystem permissions to create the \s-1LVM\s0 snapshot and mount it. This includes read/write access to the backup directory. .PP If you plan to back up InnoDB tables using \s-1LVM\s0 snapshots, be advised that it is not sufficient to lock the tables and issue the \fI\s-1FLUSH TABLES\s0\fR command to get the table files into a consistent state. When starting the MySQL server from these restored files, InnoDB will detect these tables as being in an inconsistent state and will perform a log recovery run before the tables can be accessed again. As this can potentially take some time (which you may not want to spend after restoring a server and trying to get it back on its feet as fast as possible), consider using the option \fI\-\-innodb_recover\fR, which will perform the recovery operation on the backup snapshot prior to archiving it. .PP The recovery operation is performed by spawning a second mysqld instance that uses the snapshot volume as the data directory. Note that this functionality currently assumes a default InnoDB configuration in which all InnoDB table spaces and log files are stored inside of the data directory \- it does not work properly if you use options like \fI\-\-innodb\-data\-home\-dir\fR, \&\fI\-\-innodb\-data\-file\-path\fR or \fI\-\-innodb\-log\-group\-home\-dir\fR that modify the default file layout for InnoDB tables. .PP If you use InnoDB tables exclusively, you may also want to consider to include the option \fI\-\-skip_flush_tables\fR, to avoid the probably time-consuming and in this case unnecessary flushing of buffers. But don't enable this option when MyISAM tables are involved! .SH "HOOKS" .IX Header "HOOKS" It is possible to run arbitrary external programs or scripts (hooks) at various stages of the backup process, to perform additional actions as part of the backup process. .PP These scripts or symbolic links to executables should be placed in the directory that the \fIhooksdir\fR configuration option points to (\fI/usr/share/mylvmbackup\fR by default). They should return zero upon successful completion, any non-zero return value will be considered a failure which will be logged. .PP Hook scripts can also be implemented as Perl modules. The module must be named \&\fIhookname.pm\fR and must be a package of type \fIhookname\fR. The module must implement \fI\f(BIexecute()\fI\fR which is called by \fImylvmbackup\fR to initiate the hook. It must return boolean true/false (1 or 0) on success/failure. \fI\f(BIexecute()\fI\fR will be passed 2 parameters. The first parameter is a \fBclone()\fR of the global database handle \f(CW$dbh\fR. This will allow hook scripts to interact with the database using the established connection. The second parameter is a string containing any messages passed to the \fI\f(BIrun_hook()\fI\fR function. The module must also implement \&\fI\f(BIerrmsg()\fI\fR which will return a string error message to be sent to \&\fI\f(BIlog_msg()\fI\fR. This will be called by \fImylvmbackup\fR when \fI\f(BIexecute()\fI\fR returns false/0. .PP The names of the scripts or symbolic links reflect the stage in which the hook will be called. Currently, the following stages exist: .IP "\fBpreconnect\fR" 4 .IX Item "preconnect" before a connection to the database server is established .IP "\fBpreflush\fR" 4 .IX Item "preflush" before calling \s-1FLUSH TABLES\s0 .IP "\fBpresnapshot\fR" 4 .IX Item "presnapshot" before the file system snapshot is created .IP "\fBpreunlock\fR" 4 .IX Item "preunlock" before the database tables are unlocked again .IP "\fBpredisconnect\fR" 4 .IX Item "predisconnect" before the connection to the database server is released .IP "\fBpremount\fR" 4 .IX Item "premount" before the snapshot volume is mounted .IP "\fBprebackup\fR" 4 .IX Item "prebackup" before the snapshot backup will be performed .IP "\fBbackupsuccess\fR" 4 .IX Item "backupsuccess" after a successful backup .IP "\fBbackupfailure\fR" 4 .IX Item "backupfailure" after a failed backup .IP "\fBlogerr\fR" 4 .IX Item "logerr" when an error is logged .IP "\fBprecleanup\fR" 4 .IX Item "precleanup" before the snapshot is unmounted and discarded .PP These hooks are optional and will only be called if a file for the particular stage exists and is executable. Note that hooks implemented as Perl modules (\fIhookname.pm\fR) have priority over \*(L"plain\*(R" hook scripts (\fIhookname\fR), if both exist, only the first one will be used. The execution of all hooks can be suppressed by passing the \fI\-\-skip_hooks\fR option or by setting the \&\fIskip_hooks\fR configuration option to \fI1\fR; .SH "OPTIONS" .IX Header "OPTIONS" \&\fImylvmbackup\fR supports the following command line options. The same options can also be defined in the \fI/etc/mylvmbackup.conf\fR configuration file (omitting the leading dashes, of course). A sample configuration file is included in the distribution. .IP "\fB\-\-action=string\fR" 4 .IX Item "--action=string" Selects the mode of action. Possible values are \fIbackup\fR and \fIpurge\fR. .Sp When this option is omitted, the \fIbackup\fR action is assumed by default, which performs the actual backup creation. Older backup files are preserved. .Sp The \fIpurge\fR action can be used to remove older tar or local rsync backups from the backup directory, except for the a configurable number of most recent backups, defined by the \fIbackupretention\fR option. The backup creation process is skipped in this case. .Sp Note that this option erases \fBall\fR files contained in this directory that match the criterion of being older than the last n backup files (with the exception of hidden (dot) files! .IP "\fB\-\-user=string\fR" 4 .IX Item "--user=string" Specifies the username to use for connecting to the MySQL server. The default is \fIroot\fR. .IP "\fB\-\-password=string\fR" 4 .IX Item "--password=string" Specifies the password to use for connecting to the MySQL server. The default is the empty string (no password). Alternatively, you can set the password by defining the environment variable \fI\s-1MYSQL_PWD\s0\fR prior to starting the script. Note however that this method is considered to be highly insecure, as it's possible for other users to obtain the password by examining the environment variables of the running process. See the MySQL Reference manual for more details on password security. .IP "\fB\-\-host=string\fR" 4 .IX Item "--host=string" Specifies the host name to use for connecting to the MySQL server. Note that \&\fImylvmbackup\fR needs to be run on the same system that the MySQL server to be backed up runs on \- do not enter a remote host's host name or \s-1IP\s0 address here! A non-empty value for \fIhost\fR other than \fIlocalhost\fR overrides any given \&\fIsocket\fR path value. The default is the empty string. .IP "\fB\-\-port=number\fR" 4 .IX Item "--port=number" Specifies the \s-1TCP\s0 port number to use for connecting to the MySQL server. This value is only honoured, if \fIhost\fR is provided as well and is not equal to \fIlocalhost\fR. The default is the empty string. .IP "\fB\-\-socket=string\fR" 4 .IX Item "--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. .IP "\fB\-\-quiet\fR" 4 .IX Item "--quiet" Suppresses logging of informal messages. Warnings and errors will still be printed or logged (depending on the selected logging mechanism). The default is verbose logging. .IP "\fB\-\-innodb_recover\fR" 4 .IX Item "--innodb_recover" Run InnoDB recovery on the writable snapshot prior to performing the backup. .IP "\fB\-\-recoveryopts\fR" 4 .IX Item "--recoveryopts" Additional values to pass to the startup options of the separate MySQL instance that gets spawned to perform the InnoDB log recovery option. Depending on your MySQL Server version, you may have to modify these startup parameters. .Sp The default is \fI\-\-skip\-networking \-\-skip\-grant \-\-bootstrap \-\-skip\-syslog \-\-skip\-slave\-start\fR. .IP "\fB\-\-skip_flush_tables\fR" 4 .IX Item "--skip_flush_tables" Don't issue a \fI\s-1FLUSH TABLES WITH READ LOCK\s0\fR command before creating the snapshot. Only use this option when backing up InnoDB tables (as they don't support this function anyway and will require recovery in any case). This option skips the (probably time consuming) flushing of buffers. .IP "\fB\-\-extra_flush_tables\fR" 4 .IX Item "--extra_flush_tables" If your database performs a lot of writes, it may help to perform an extra initial \fI\s-1FLUSH TABLES\s0\fR so that the \fIlvcreate\fR can finish within the interactivity timeout during the read-locked flush. .IP "\fB\-\-pidfile=string\fR" 4 .IX Item "--pidfile=string" Specifies the full path and file name to the \s-1PID\s0 file of the server instance that is spawned to perform the InnoDB recovery (see option \&\fI\-\-innodb_recover\fR). Must be different from the \s-1PID\s0 file that the actual running server uses. The default is \fI/var/run/mysqld/mylvmbackup_recoverserver.pid\fR .IP "\fB\-\-lvcreate=string\fR" 4 .IX Item "--lvcreate=string" Specifies the pathname for the \fIlvcreate\fR program. The default is \fIlvcreate\fR. .IP "\fB\-\-lvremove=string\fR" 4 .IX Item "--lvremove=string" Specifies the pathname for the \fIlvremove\fR program. The default is \fIlvremove\fR. .IP "\fB\-\-lvs=string\fR" 4 .IX Item "--lvs=string" Specifies the pathname for the \fIlvs\fR program. The default is \fIlvs\fR. .IP "\fB\-\-mysqld_safe=string\fR" 4 .IX Item "--mysqld_safe=string" Specifies the pathname for the \fImysqld_safe\fR program. The default is \fImysqld_safe\fR. Only used to perform InnoDB recovery. .IP "\fB\-\-mycnf=string\fR" 4 .IX Item "--mycnf=string" Specifies the name of a MySQL config file (e.g. \fI/etc/my.cnf\fR) or an entire config directory (e.g. \fI/etc/mysql\fR) to include in the backup. The default is \fI/etc/my.cnf\fR. .IP "\fB\-\-skip_mycnf\fR" 4 .IX Item "--skip_mycnf" Skip backing up the MySQL configuration. The default is to include a copy of the MySQL configuration in the backup. .IP "\fB\-\-hooksdir=string\fR" 4 .IX Item "--hooksdir=string" The location of external scripts or executable to be called during various stages of the backup. See the \s-1HOOKS\s0 section in this manual page for more info. The default is \fI/usr/share/mylvmbackup\fR. .IP "\fB\-\-skip_hooks\fR" 4 .IX Item "--skip_hooks" Skip invoking any external hooks during the backup. .IP "\fB\-\-vgname=string\fR" 4 .IX Item "--vgname=string" Specifies the volume group of the logical volume where the MySQL data directory is located. The default is \fImysql\fR. .IP "\fB\-\-lvname=string\fR" 4 .IX Item "--lvname=string" Specifies the name of the logical volume where the MySQL data directory is located. The default is \fIdata\fR. .IP "\fB\-\-backuplv=string\fR" 4 .IX Item "--backuplv=string" Specifies the name used for the snapshot volume. If left empty, \fB_snapshot\fR will simply be appended to the original volume name (e.g. \fIdata_snapshot\fR). .Sp It is possible to use selected \fI\f(BItimestr()\fI\fR formatting sequences to create snapshot volume names which contain a dynamic date value. This can be useful if you use thin provisioned snapshots as the actual backup, by enabling the \&\fIkeep_snapshot\fR option. .Sp Currently, the following format strings are supported: .RS 4 .IP "\fI\f(CI%Y\fI\fR" 4 .IX Item "%Y" 4\-digit year (e.g. 2009) .IP "\fI\f(CI%m\fI\fR" 4 .IX Item "%m" Month (01..12) .IP "\fI\f(CI%d\fI\fR" 4 .IX Item "%d" Day of month, leading zero .IP "\fI\f(CI%h\fI\fR" 4 .IX Item "%h" Month abbreviation, .IP "\fI\f(CI%H\fI\fR" 4 .IX Item "%H" Hour, 24 hour clock, leading zero .IP "\fI\f(CI%M\fI\fR" 4 .IX Item "%M" Minute, leading zero .IP "\fI\f(CI%S\fI\fR" 4 .IX Item "%S" Seconds, leading zero .RE .RS 4 .Sp Example: \fI\f(CI$backuplv\fI=backup\-%Y\-%m\-%d\-%H\-%M\-%S\fR will expand to \&\fIbackup\-2013\-06\-07\-14\-08\-45\fR. .RE .IP "\fB\-\-keep_snapshot\fR" 4 .IX Item "--keep_snapshot" If this option is given, \fImylvmbackup\fR will not remove the snapshot before terminating. Note that keeping multiple \s-1LVM\s0 snapshots open at the same time can reduce I/O performance and you will need to manually discard the snapshot before invoking \fImylvmbackup\fR again. .IP "\fB\-\-keep_mount\fR" 4 .IX Item "--keep_mount" If this option is given, \fImylvmbackup\fR will not remove the mounted partition before terminating. This option also implies \fIkeep_snapshot=1\fR, as it would not be useful if the snapshot is removed. You need to manually unmount this directory before invoking \fImylvmbackup\fR again. .IP "\fB\-\-thin\fR" 4 .IX Item "--thin" If this option is given, \fImylvmbackup\fR will expect that the \s-1LVM\s0 volume is using thin provisioning and that the snapshot will use physical space from the existing thin pool. Any size specified with \fIlvsize\fR is ignored. .IP "\fB\-\-relpath=string\fR" 4 .IX Item "--relpath=string" Relative path on the logical volume to the MySQL data directory (no leading or trailing slash). Example: the logical volume is mounted on \fI/var/lib\fR, but the MySQL data directory is /var/lib/mysql. In this case, \fIrelpath\fR should be set to \fImysql\fR. The default is the empty string. .IP "\fB\-\-lvsize=string\fR" 4 .IX Item "--lvsize=string" Specifies the size for the snapshot volume. The default is \fI5G\fR (5 gigabytes). .IP "\fB\-\-backuptype=string\fR" 4 .IX Item "--backuptype=string" Specifies what type of backup to perform. The available options are \&\fItar\fR, \fIrsync\fR, \fIrsnap\fR, \fIzbackup\fR and \fInone\fR. Note that using \&\fIzbackup\fR still requires a \fItar\fR executable to prepare the backup archives. .IP "\fB\-\-backupretention=string\fR" 4 .IX Item "--backupretention=string" Specifies how many previous backups (tar archives or rsync directories only) to keep in the backup directory when performing the \fIpurge\fR action. The default is \fI0\fR (keep all backups). .Sp Note that this feature only works on a local backup directory with a static directory name! If you use \fI\f(BItimestr()\fI\fR formatting sequences for the backup directory, the retention mode will not work. .Sp The script looks at the last modification time (mtime) of each file and directory to determine which files will be removed. .Sp Be advised that this operation deletes \fBall\fR files and directories in the backup directory that are older than the last n files (with the exception of hidden (dot) files! .IP "\fB\-\-prefix=string\fR" 4 .IX Item "--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 \fIbackup\fR. .IP "\fB\-\-suffix=string\fR" 4 .IX Item "--suffix=string" Suffix added to the backup file names (after the time stamp). The default value is \fI_mysql\fR. .IP "\fB\-\-datefmt=string\fR" 4 .IX Item "--datefmt=string" Format of the time stamp included in the backup file name. See the \fIDate::Format\fR perldoc page for a description of the format. The default value is \fI\f(CI%Y\fI%m%d_%H%M%S\fR, which creates a time stamp like \fI\s-1YYYYMMDD_HHMMSS\s0\fR, e.g. \fI20070531_112549\fR Can be empty as well, to suppress adding a time stamp (e.g. when using rsync to always sync into the same backup directory). .IP "\fB\-\-mountdir=string\fR" 4 .IX Item "--mountdir=string" Path for mounting the snapshot volume to. The default value is \fI/var/run/mysqld/mylvmbackup/mnt/\fR. If the directory does not exist, it will be created. .Sp It is possible to use selected \fI\f(BItimestr()\fI\fR formatting sequences to create directory names which contain a dynamic date value. Currently, the following format strings are supported: .RS 4 .IP "\fI\f(CI%Y\fI\fR" 4 .IX Item "%Y" 4\-digit year (e.g. 2009) .IP "\fI\f(CI%m\fI\fR" 4 .IX Item "%m" Month (01..12) .IP "\fI\f(CI%d\fI\fR" 4 .IX Item "%d" Day of month, leading zero .IP "\fI\f(CI%h\fI\fR" 4 .IX Item "%h" Month abbreviation, .IP "\fI\f(CI%H\fI\fR" 4 .IX Item "%H" Hour, 24 hour clock, leading zero .IP "\fI\f(CI%M\fI\fR" 4 .IX Item "%M" Minute, leading zero .IP "\fI\f(CI%S\fI\fR" 4 .IX Item "%S" Seconds, leading zero .RE .RS 4 .Sp Example: \fI\f(CI$mountdir\fI=/path/to/%Y\-%m\-%d\fR will expand to \fI/path/to/2009\-06\-13\fR .RE .IP "\fB\-\-backupdir=string\fR" 4 .IX Item "--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. If the directory does not exist, it will be created. .Sp It is possible to use selected \fI\f(BItimestr()\fI\fR formatting sequences to create directory names which contain a dynamic date value. Currently, the following format strings are supported: .RS 4 .IP "\fI\f(CI%Y\fI\fR" 4 .IX Item "%Y" 4\-digit year (e.g. 2009) .IP "\fI\f(CI%m\fI\fR" 4 .IX Item "%m" Month (01..12) .IP "\fI\f(CI%d\fI\fR" 4 .IX Item "%d" Day of month, leading zero .IP "\fI\f(CI%h\fI\fR" 4 .IX Item "%h" Month abbreviation, .IP "\fI\f(CI%H\fI\fR" 4 .IX Item "%H" Hour, 24 hour clock, leading zero .IP "\fI\f(CI%M\fI\fR" 4 .IX Item "%M" Minute, leading zero .IP "\fI\f(CI%S\fI\fR" 4 .IX Item "%S" Seconds, leading zero .RE .RS 4 .Sp Example: \fI\f(CI$mountdir\fI=/path/to/%Y\-%m\-%d\fR will expand to \fI/path/to/2009\-06\-13\fR .Sp Instead of a local directory, you can also provide a valid rsync \s-1URL\s0 here, e.g. \&\fIusername@hostname:/path\fR, \fIhostname:path\fR or \fIhostname::rsync\-module/path\fR. This requires a properly configured remote rsync setup (e.g. pre-setup \s-1SSH\s0 keys or a working rsyncd configuration). .Sp Note that the \fIbackupretention\fR option does not work for rsync URLs or directory names that use format strings. You need to define a static local directory name in \fIbackupdir\fR if you want to use the \fIpurge\fR action to automatically remove older backups from the backup directory. .Sp The default is \fI/var/run/mysqld/mylvmbackup/backup/\fR .RE .IP "\fB\-\-mount=string\fR" 4 .IX Item "--mount=string" Specifies the pathname for the \fImount\fR program. The default is \fImount\fR. .IP "\fB\-\-umount=string\fR" 4 .IX Item "--umount=string" Specifies the pathname for the \fIumount\fR program. The default is \fIumount\fR. .IP "\fB\-\-tar=string\fR" 4 .IX Item "--tar=string" Specifies the pathname for the \fItar\fR program. The default is \fItar\fR. .IP "\fB\-\-tararg=string\fR" 4 .IX Item "--tararg=string" Specifies the initial arguments for the \fItar\fR program. The default is \fIcvf\fR. .IP "\fB\-\-tarsuffixarg=string\fR" 4 .IX Item "--tarsuffixarg=string" Specifies the suffix arguments for the \fItar\fR program. The default is the empty string. To exclude a database, you would pass \fI\-\-exclude dbname\fR here. .IP "\fB\-\-tarfilesuffix=string\fR" 4 .IX Item "--tarfilesuffix=string" Specifies the suffix for the tarball. This value should be set according to the selected compression method (e.g. \fI.tar.bz2\fR for bzip2 compression). The default is \fI.tar.gz\fR. .IP "\fB\-\-compress=string\fR" 4 .IX Item "--compress=string" Specifies the name of the compression program. Only used if \fIbackuptype\fR is set to \fItar\fR. Some possibilities are \fIgzip\fR, \fIbzip2\fR or \fIlzma\fR. The program must support reading the to be compressed data from \fIstdin\fR and writing to \fIstdout\fR, without requiring intermediate temporary files (for this reason, 7zip cannot be used). It's also possible to use \fIcat\fR. In this case, no compression will be done. Make sure to update the \fIcompressarg\fR option and the \fItarfilesuffix\fR accordingly. The default is \fIgzip\fR. Can be left empty. .IP "\fB\-\-compressarg=string\fR" 4 .IX Item "--compressarg=string" Specifies the command line options given to the \fIcompress\fR program. For \fIgzip\fR, that would be \fI\-\-stdout \-\-verbose \-\-best\fR, for \fIlzma\fR or \fIbzip2\fR \fI\-\-stdout \-\-verbose \-7\fR and for \fIcat\fR, it would be empty. The default is \fI\-\-stdout \-\-verbose \-\-best\fR. .IP "\fB\-\-rsnap=string\fR" 4 .IX Item "--rsnap=string" Specifies the pathname for the \fIrsnap\fR program. The default is \fIrsnap\fR. .IP "\fB\-\-rsnaparg=string\fR" 4 .IX Item "--rsnaparg=string" Specifies the arguments for the \fIrsnap\fR program. The default is \fI7\fR, which causes it to keep the last 7 snapshot (useful when running \fImylvmbackup\fR once per day). .IP "\fB\-\-rsnaprsyncarg=string\fR" 4 .IX Item "--rsnaprsyncarg=string" Specifies the arguments for the \fIrsync\fR process that is spawned by \&\fIrsnap\fR, e.g. \fI\-\-exclude \e*.o \-\-bwlimit=8\fR. You don't need to provide the double dashes usually required by \fIrsnap\fR to separate these arguments. Default value is the empty string. .IP "\fB\-\-rsync=string\fR" 4 .IX Item "--rsync=string" Specifies the pathname for the \fIrsync\fR program. The default is \fIrsync\fR. .IP "\fB\-\-rsyncarg=string\fR" 4 .IX Item "--rsyncarg=string" Specifies the arguments for the \fIrsync\fR program. The default is \fI\-avWP\fR. You must ensure that the recursive option is included either implicitly by \fI\-a\fR, or explicitly by using \fI\-r\fR. .IP "\fB\-\-zbackup=string\fR" 4 .IX Item "--zbackup=string" Specifies the pathname for the \fIzbackup\fR program. The default is \fIzbackup\fR. .IP "\fB\-\-zbackuparg=string\fR" 4 .IX Item "--zbackuparg=string" Specifies the arguments for the \fIzbackup\fR program. The default is \fI\-\-non\-encrypted\fR. .Sp You may use \fI\-\-password\-file /path/to/pass\fR to create an encrypted zbackup repository. The backup repository located in \fIbackupdir\fR will be initialized automatically by running \fIzbackup init\fR before the first invocation. .IP "\fB\-\-xfs\fR" 4 .IX Item "--xfs" Use the \fInouuid\fR mount option to safely mount snapshot partitions that use the \s-1XFS\s0 file system. .IP "\fB\-\-log_method=string\fR" 4 .IX Item "--log_method=string" How to log output from this script. Valid options are \fIconsole\fR, \fIsyslog\fR or \fIboth\fR. The default value is \fIconsole\fR. Enabling the \fIsyslog\fR option requires an installed \fISys::Syslog\fR Perl module. .IP "\fB\-\-syslog_socktype=string\fR" 4 .IX Item "--syslog_socktype=string" What type of socket to use for connecting to the syslog service. Valid options are \fInative\fR, \fItcp\fR and \fIudp\fR. The default value is \fInative\fR. .IP "\fB\-\-syslog_facility=string\fR" 4 .IX Item "--syslog_facility=string" Define a particular syslog facility Default value is the empty string. .IP "\fB\-\-syslog_remotehost=string\fR" 4 .IX Item "--syslog_remotehost=string" Host name of a remote syslog server. .IP "\fB\-\-mail_report_on=string\fR" 4 .IX Item "--mail_report_on=string" Enable sending the logging output via email to a specified email address. .Sp This option requires an installed \fIMIME::Lite\fR Perl module as well as a functional local sendmail (or alternative) facility. .Sp You should also review and adjust the \fImail_from\fR, \fImail_to\fR and \fImail_subject\fR configuration options to match you requirements. .Sp Supported values are \fInever\fR, this disables the mail reporting completely. A value of \fIalways\fR sends an email report for each invocation of \fImylvmbackup\fR, \fIerrors\fR only sends a report in case of an error condition. .Sp The default value is \fInever\fR. .IP "\fB\-\-mail_from=string\fR" 4 .IX Item "--mail_from=string" The email address to be used in the \fIFrom:\fR header for email reports (requires the \fImail_report\fR option to be set). The default value is \fIroot@localhost\fR. .IP "\fB\-\-mail_to=string\fR" 4 .IX Item "--mail_to=string" The email address to be used to send email reports to (requires the \fImail_report\fR option to be set). The default value is \fIroot@localhost\fR. .IP "\fB\-\-mail_subject=string\fR" 4 .IX Item "--mail_subject=string" The text to be used in the \fISubject:\fR header for email reports (requires the \fImail_report\fR option to be set). The default value is \*(L"mylvmbackup report for localhost\*(R". .IP "\fB\-\-configfile=string\fR" 4 .IX Item "--configfile=string" Specify an alternative configuration file. The default is \fI/etc/mylvmbackup.conf\fR. .IP "\fB\-\-help\fR" 4 .IX Item "--help" Displays a help message showing the available options. .SH "FILES" .IX Header "FILES" .IP "\fB/etc/mylvbackup.conf\fR" 4 .IX Item "/etc/mylvbackup.conf" The \fImylvmbackup\fR configuration file .IP "\fBmylvmbackup\fR" 4 .IX Item "mylvmbackup" The executable Perl script that performs the work. .SH "REQUIREMENTS" .IX Header "REQUIREMENTS" For proper operation \fImylvmbackup\fR requires Perl 5 with the \fI\s-1DBI\s0\fR and \&\fIDBD::mysql\fR modules. It also needs the \fIConfig::IniFiles\fR to read the global configuration file of the program. \fIDate::Format\fR is required to create the time stamp used in the backup file names. In addition, it utilizes \&\fIGetopt::Long\fR, \fIFile::Basename\fR and \fIFile::Temp\fR, which usually are part of the default Perl distribution. \&\fIFile::Copy::Recursive\fR is used to copy the MySQL configuration file(s). \&\fISys::Syslog\fR is only required in case you want to enable the syslog log facility. The \fIMIME::Lite\fR module is required when you enable the mail reporting functionality. It also requires a functional local sendmail (or alternative) facility. .PP It also requires several other external programs: \s-1GNU\s0 \fItar\fR and \fIgzip\fR to back up the data, \s-1LVM\s0 utilities (\fIlvcreate\fR, \fIlvremove\fR and \fIlvs\fR) to create and remove the \s-1LVM\s0 snapshot, and the system utilities \fImount\fR and \fIumount\fR. Please note that \fImylvmbackup\fR requires Linux \s-1LVM\s0 Version 2 or higher. It does not work on LVMv1, as this version does not support writable snapshots. .PP Optionally, \fIrsync\fR or \fIrsnap\fR may be required instead of \fItar\fR and \fIgzip\fR, depending on which backup type you choose. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBmount\fR\|(8), \fBtar\fR\|(1), \fBlvcreate\fR\|(8), \fBlvremove\fR\|(8), \fBlvs\fR\|(8), \fBumount\fR\|(8), \fBrsync\fR\|(1) .SH "AUTHOR" .IX Header "AUTHOR" This program was initially written by Aleksey \*(L"Walrus\*(R" Kishkin from MySQL \s-1AB,\s0 with suggestions from Peter Zaitsev and Lenz Grimmer. .PP It is currently maintained by Lenz Grimmer .SH "RESOURCES" .IX Header "RESOURCES" Main web site: .PP Mailing list: .PP Source code, bug tracker: .SH "CREDITS" .IX Header "CREDITS" See the file \s-1CREDITS\s0 included in the distribution for a list of individual contributors. .SH "COPYING" .IX Header "COPYING" \&\fImylvmbackup\fR is distributed under the \s-1GNU\s0 public license. See the file \&\s-1COPYING\s0 for details.