mysqlhotcopy
mysqlhotcopy
is a Perl script that uses a
combination of LOCK
TABLES
,
FLUSH
TABLES
, and Unix
cp to perform a fast backup of the database. It
simply copies the raw database files to another location. Because it
does only a file copy, it is much faster than
mysqldump. And because the copy is in native
format, the backup is not portable to other hardware or operating
systems, except for MyISAM tables, which are portable. Also,
mysqlhotcopy can be run only on the same host as
the database, whereas mysqldump can be executed
remotely.
To run mysqlhotcopy, type:
$ mysqlhotcopy test /usr/backups
This command creates a new directory in the /usr/backups directory that has a copy of all the data files in the test database.
If you are using binary logging, you will also want to specify --flushlog, so the binary logs get checkpointed at the time of the backup.
Get Managing & Using MySQL, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.