[mylvmbackup] do_innodb_backup using wrong switch for pid-file

  • From: Jim Wilson <jim@xxxxxxxxxxxxxx>
  • To: mylvmbackup@xxxxxxxxxxxxx
  • Date: Tue, 25 Mar 2008 09:58:40 -0600

First of all, wonderful tool! Saved me a lot of time and once I got
my .conf correct, worked like a charm (almost...).

I wanted to do the auto innodb recover before backing up, and was having
trouble starting mysqld_safe. I believe the problem is below:

The proper name of switch for mysqld_safe is "--pid-file", not
"--pidfile", at least as of mysql 5.0.45. Since mysql seems to ignore
flags it does not know about, no error is thrown and the pid-file within
the my.cnf is used. But in my case, that is the pid of the running
mysqld!! So I get an error telling me mysqld is already running...

Putting the below in mylvmbackup.conf file seems to work:
mysqld_safe=/usr/bin/mysqld_safe --port 3307
--socket=/tmp/mysqld-recover.sock --pid-file=/tmp/mysqld-recover.pid

My log from a backup is below. I need to do further checking, but it
appears to be working...

20080325 09:48:46 Info: Connecting to database...
20080325 09:48:46 Info: Flushing tables with read lock...
20080325 09:49:27 Info: Taking position record...
20080325 09:49:27 Info: Taking snapshot...
File descriptor 3 left open
  Logical volume "backup" created
20080325 09:49:29 Info: Unlocking tables...
20080325 09:49:29 Info: Disconnecting from database...
20080325 09:49:29 Info: Mounting snapshot...
20080325 09:49:30 Info: Recovering innodb...
Starting mysqld daemon with databases from /mnt/vg/backup/apex-lvmbackup
mysqld_safe[9484]: started
STOPPING server from pid file /tmp/mysqld-recover.pid
mysqld_safe[9489]: ended
20080325 09:49:30 Info: Copying my.cnf...
20080325 09:49:30 Info: Taking actual backup...
20080325 09:49:30 Info: Creating tar
archive /var/backups/mysql/apex-lvmbackup-2008-03-25-09-48-46_mysql.tar.gz
...

HTH

Original code below:

sub do_innodb_recover
{
  if ( system("echo 'select 1;' | $mysqld_safe --pidfile=$pidfile
--datadir=$mountdir --skip-networking --skip-grant --bootstrap
--skip-ndbcluster --skip-slave-start") != 0 )
  {
    log_msg ("Failed to perform InnoDB recovery on the snapshot!",
LOG_ERR);
  }
}
Jim Wilson
Colorado Springs, CO


Other related posts: