O'Reilly logo

Managing & Using MySQL, 2nd Edition by Hugh E. Williams, Randy Yarger, George Reese, Tim King

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required