BACKUP TABLE

This MySQL statement makes a backup copy of a MyISAM table. However, it has been deprecated because it does not work reliably.

Syntax

Below is the syntax for this command. Text within square brackets (i.e, [ and ] ) are optional. Choices are separated by bars (i.e, | ). Ellipses preceded by a comma indicates a repeating pattern. Ellipses before or after syntax are used to highlight a relevant except from the larger syntax. Text displayed in italic letters represent text that should be replaced with the specific names related to the database (e.g., column with the name of the column).

BACKUP TABLE table[, ...] TO '/path'

Explanation

This statement makes a backup copy of a MyISAM table. However, it has been deprecated because it does not work reliably. It's recommended that mysqlhotcopy be used until this statement is replaced.

You can specify additional tables in a comma-separated list. The absolute path to the directory to which MySQL is to copy files appears within quotes after the TO keyword.

The statement copies each table's .frm file and .MYD file, which contain the table structure and the table data, respectively. The .MYI file containing the index is not copied, but will be rebuilt with the RESTORE TABLE statement when restoring the table.

Examples

BACKUP TABLE clients TO '/tmp/backup';

+----------------------+--------+----------+----------+
| Table                | Op     | Msg_type | Msg_text |
+----------------------+--------+----------+----------+
| workrequests.clients | backup | status   | OK       |
+----------------------+--------+----------+----------+

If the backup succeeds, the results will look like the preceding output and two files will be created for each table backed up: a .frm file and a .MYD file. If MySQL does not have the filesystem privileges necessary to write to the backup directory, or if a file with the same name is already in the directory, the backup will fail. In that case, the results set will include one row with an error message type and another with a status type and the message text stating Operation failed.