Yesterday I logged into my server to back up my databases. I back up the mysql databases using a tool called “mysqlhotcoy”. It’s a handy perl application that copies the database files for easy restores, and it also works really quick when you run it.
I ran the mysqlhotcopy command as root, and was greeted with an error similar to this:
Invalid db.table name 'foo.foo`.`bar'
um, no…. this table exists
I have cpanel installed on my server, a lot of server do. cpanel does updates to many application, mysqlhotcopy is one of them. It looks like my version of mysqlhotcopy was updated to 1.22, and there is some major problems with mysqlhotcopy 1.22.
I did some googeling and I found some people talking about the problem. I even found a quick patch for the problem. The problem comes from a host adding the username and an underscore before a database name (example: “username_databasename.table
“). mysqlhotcopy only looks for databasename.table
The following patch instructions will fix mysqlhotcopy 1.22
- Open the perl script for editing. It is located at
/usr/bin/mysqlhotcopy
- find the following subroutine
sub get_list_of_tables {
my ( $db ) = @_;my $dbh = DBI->connect(“dbi:mysql:${db}${dsn};mysql_read_default_group=mysqlhotcopy”,
$opt{user}, $opt{password},
{
RaiseError => 1,
PrintError => 0,
AutoCommit => 1,
});my @dbh_tables = eval { $dbh->tables() };
$dbh->disconnect();
return @dbh_tables;
} - look for this line (mine was link 821):
my @dbh_tables = eval { $dbh->tables() };
- immediately after that line add the following:
map { s/^.*?\.//o } @dbh_tables
Here is my patched subroutine:
sub get_list_of_tables {
my ( $db ) = @_;my $dbh = DBI->connect(“dbi:mysql:${db}${dsn};mysql_read_default_group=mysqlhotcopy”,
$opt{user}, $opt{password},
{
RaiseError => 1,
PrintError => 0,
AutoCommit => 1,
});my @dbh_tables = eval { $dbh->tables() };
map { s/^.*?\.//o } @dbh_tables;
$dbh->disconnect();
return @dbh_tables;
}
After I applied the patch, everything was back to working order.
Some people have other approaches that would work also, like downgrading mysqlhotcopy all together.
Personally, I think adding one line of code wasn’t that big of a deal to fix the program