7.1. mysqlbackup Command-Line Options
$ mysqlbackup --help
Usage:
mysqlbackup [--sleep=MS] [--compress[=LEVEL]] [--include=REGEXP]
[--user=WORD][--password=WORD] [--port=PORT]
[--socket=SOCKET] [--no-timestamp]
[--ibbackup=IBBACKUP-BINARY] [--slave-info]
[--backup-and-apply-log] [--databases=LIST]
[--exec-when-locked="utility arg1 arg2 ..."]
[--incremental --lsn=LSN]
[--only-known-file-types]
MY.CNF BACKUP-ROOT-DIR
mysqlbackup --apply-log [--use-memory=MB] [--uncompress]
[--ibbackup=IBBACKUP-BINARY] MY.CNF BACKUP-DIR
mysqlbackup --apply-log --incremental [--use-memory=MB] [--uncompress]
[--ibbackup=IBBACKUP-BINARY]
INCREMENTAL-BACKUP-MY.CNF FULL-BACKUP-MY.CNF
mysqlbackup --copy-back MY.CNF BACKUP-DIR
The first command line above makes a hot backup of a MySQL database. By
default it creates a backup directory (named by the current date and time)
in the given backup root directory. With the --no-timestamp option it
does not create a time-stamped backup directory, but it puts the backup in
the given directory (which must not exist). This command makes a complete
backup of all MyISAM and InnoDB tables and indexes in all databases or in
all of the databases specified with the --databases option. The created
backup contains by default all InnoDB data and log files, .frm files, and
all files in the subdirectories of the database directory. Please notice
that backups of other than MyISAM and InnoDB engines may not be valid,
even if mysqlbackup copies all files associated with them, because the
engine might not flush all data to disk when mysqlbackup locks all
databases.
If --incremental is specified, it instructs ibbackup to make an INCREMENTAL
backup that only contains data pages whose latest modification has a log
sequence number (lsn) greater than LSN. This LSN must be specified via the
--lsn switch. Make sure that you have taken a full backup before taking an
incremental backup or you will not be able to restore your database.
The MY.CNF options file defines the location
of the database. This command connects to the MySQL server using
mysql client API, and runs ibbackup (InnoDB Hot Backup program) as
a child process.
The command with --apply-log option prepares a backup for starting a MySQL
server on the backup. This command expands InnoDB data files as specified
in BACKUP-DIR/backup-my.cnf using BACKUP-DIR/ibbackup_logfile,
and creates new InnoDB log files as specified in BACKUP-DIR/backup-my.cnf.
The BACKUP-DIR should be a path name of a backup directory created by
mysqlbackup. This command runs ibbackup as a child process, but it does not
connect to the database server.
If --incremental is specified after --apply-log, then ibbackup applies the
incremental backup at INCREMENTAL-BACKUP-MY.CNF to the FULL backup at
FULL-BACKUP-MY.CNF.
The command with --copy-back option copies data, index, and log files
from backup directory back to their original locations.
The MY.CNF options file defines the original location of the database.
The BACKUP-DIR is a path name of a backup directory created by mysqlbackup.
mysqlbackup reads [client] group only from the configuration files.
The configuration file MY.CNF or INCREMENTAL-BACKUP.CNF is read after all
the default configuration files are read. mysqlbackup acts only on user,
password, port and socket options from [client] group and ignores the rest
of the options.
On success the exit code of mysqlbackup process is 0. A non-zero exit code
indicates an error.
Options:
--help Display this helpscreen and exit.
--version Print version information and exit.
--apply-log Prepare a backup for starting mysql server on the backup.
Expand InnoDB data files as specified in
backup-dir/backup-my.cnf, using backup-dir/ibbackup_logfile,
and create new log files as specified in
backup-dir/backup-my.cnf.
--backup-and-apply-log
Make a backup and prepare it for starting mysql server on it
as if --apply-log option had been given. The --incremental
option is not allowed with this option. The --compress and
--uncompress options are ignored with this option.
--copy-back Copy data and index files from backup directory back to
their original locations.
--use-memory=MB
This option is passed to the ibbackup child process.
It tells ibbackup that it can use MB megabytes of
memory in restoration.
Try 'ibbackup --help' for more details on this option.
--sleep=MS This option is passed to the ibbackup child process.
You can use this parameter to tune the additional
MS milliseconds after each 1 MB of copied data.
disk i/o load the ibbackup program causes on the computer.
Try 'ibbackup --help' for more details on this option.
--compress[=LEVEL]
This option is passed to the ibbackup child process.
It instructs ibbackup to compress the backup copies of
InnoDB data files. Compression level can be
specified as an optional argument. Compression level is
an integer between 0 and 9: 1 gives fastest compression,
9 gives best compression, and 0 means no compression.
If compression level is not given, the default level 1 is
used. Try 'ibbackup --help' for more details on this option.
--include=REGEXP
This option is passed to the ibbackup child process.
It tells ibbackup to backup only those per-table data
files which match the given regular expression. For
each table with a per-table data file a string of the
form db_name.table_name is checked against the regular
expression. If the regular expression matches the
complete string db_name.table_name, the table is
included in the backup. The regular expression should
be of the POSIX 1003.2 "extended" form.
Try 'ibbackup --help' for more details on this option.
--databases=LIST
This option is used to specify the list of databases that
mysqlbackup should backup. The list is of the form
"db_name[.table_name] db_name1[.table_name1] ...".
If this option is not specified all databases containing
MyISAM and InnoDB tables will be backed up.
Please make sure that --databases contains all of the
Innodb databases & tables so that all of the innodb .frm
files are also backed up. In Unix variant systems, if the LIST
argument begins with a slash, mysqlbackup assumes that it is
a pathname of file and tries to read the list of databases
from that file. In Windows systems, if the list argument
begins with a "<drive_letter>:\", mysqlbackup assumes
that it is a pathname of file and tries to read the list
of databases from that file.
--uncompress
This option is passed to the ibbackup child process.
It tells ibbackup to uncompress compressed InnoDB data files.
Try 'ibbackup --help' for more details on this option.
--user=NAME It defines the user for database login if not current user.
--password=WORD
It defines the password to use when connecting to database.
If WORD is not given, a prompt for the same is issued on the
tty.
--port=PORT It defines the port to use when connecting to local database
server with TCP/IP.
--slave-info
This option is useful when backing up a replication
slave server. It prints the binary log position and
name of the binary log file of the master server.
It also writes this information to the 'ibbackup_slave_info'
file as a 'CHANGE MASTER' command. A new slave for this
master can be set up by starting a slave server on this
backup and issuing a 'CHANGE MASTER' command with the
binary log position saved in the 'ibbackup_slave_info' file.
--socket=SOCKET
It defines the socket to use when connecting to local
database server with UNIX domain socket.
--no-timestamp
This option prevents the creation of a new backup
directory (named by the current date and time) under
the backup root directory. Instead, the backup is put
in the directory given on the command-line (in the
place of BACKUP-ROOT-DIR argument). The directory must not
exist, because mysqlbackup creates it while making a backup.
--ibbackup=IBBACKUP-BINARY
Use this option to specify which ibbackup (InnoDB Hot
Backup) binary should be used. IBBACKUP-BINARY
should be the command used to run ibbackup. This can
be useful if ibbackup is not in your search path or
working directory. If this option is not given,
ibbackup is run with command "./ibbackup" in Unix
like systems and "ibbackup.exe" in Windows systems.
--exec-when-locked="utility arg1 arg2 ..."
The specified utility is executed when all tables are
locked near the end of the execution. This can be used
to mysqldump memory tables (engine=memory) and get a
consistent backup.
BACKUP_DIR will be set in the environment of the utility
to the directory that contains the backup (a subdirectory
of the specified BACKUP-ROOT-DIR).
For example, in Unix like systems:
--exec-when-locked='mysqldump mydb t1 > $BACKUP_DIR/t1.sql'
Note the single quotes that prevent your shell from
interpreting $BACKUP_DIR before starting mysqlbackup.
In Windows systems:
--exec-when-locked="mysqldump mydb t1 > %BACKUP_DIR%/t1.sql"
If the utility cannot be executed or if it returns
failure (non-zero exit status), then the whole backup
process will be aborted.
--only-known-file-types
Backup only files used in MySQL 5.1 by InnoDB, MyISAM, and
ARCHIVE engines. With this option the backup contains
InnoDB data and log files, table definitions (.frm files),
merge tables (.MRG), MyISAM tables and indexes (.MYD and
.MYI), triggers (.TRG and .TRN), database characteristics
(.opt), partitions (.par) and ARCHIVE tables (.ARM and .ARZ).