官方介绍
mysqlhotcopy is a Perl script that was originally written and contributed by Tim Bunce. It uses FLUSH TABLES, LOCK TABLES, and cp or scp to make a database backup. It is a fast way to make a backup of the database or single tables, but it can be run only on the same machine where the database directories are located. mysqlhotcopy works only for backing up MyISAM and ARCHIVE tables. It runs on Unix and NetWare.
To use mysqlhotcopy, you must have read access to the files for the tables that you are backing up, theSELECT privilege for those tables, the RELOAD privilege (to be able to execute FLUSH TABLES), and theLOCK TABLES privilege (to be able to lock the tables).
 
Mysqlhotcopy适用于小型数据库,适用flush tables,locktables,cp(scp)备份数据库
shell#mysqlhotcopy -u 用户 备份数据库名称  目标文件夹
执行报错:
install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains: /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 .) at (eval 12) line 3.
Perhaps the DBD::mysql perl module hasn't been fully installed,
or perhaps the capitalisation of 'mysql' isn't right.
Available drivers: DBM, ExampleP, File, Gofer, Proxy, SQLite, Sponge.
 at /usr/local/mysql/bin/mysqlhotcopy line 178
原因:缺少perl连接数据库驱动
解决办法:
安装 perl-DBD-MySQLperl-DBI
关于DBDDBI介绍
DBI is a database-independent interface for the Perl programming language. DBD::mysql is the driver for connecting to MySQL database servers with DBI.
·         DBI is the basic abstraction layer for working with databases in Perl.
·         DBD::mysql is the driver for using MySQL with DBI.
·         Net::MySQL is a pure-Perl implementation of the MySQL client-server protocol. (It is not necessary when using DBI with DBD::mysql, but may be useful in environments where you are not able to compile the MySQL client library required by DBD::mysql.)

 
 
接下来执行备份还是报错,
Invalid db.table name 'mysql.mysql`.`columns_priv' at /usr/local/mysql/bin/mysqlhotcopy line 854.
在网上查了下是mysqlhotcopy脚本的bug
解决办法
my @dbh_tables = eval { $dbh->tables() }(应该是834)这行下面添加
map { s/^.*?\.//o } @dbh_tables;
 
 

mysqlhotcopy常用参数
 
 --addtodest                       不重命名目标文件(如果存在),合并它们【增量备份】
--allowold                          
--checkpoint                        后面跟数据库名和表名,记录mysqlhotcopy操作记录
--host                                 
--port                                 
--user                                 
--tmpdir                             
--socket                              
--method                             使用cp或者scp,默认使用cp