PDA

View Full Version : Error in mysql-zrm.conf template for pre-scheduler plugin



Silenus
July 8th, 2014, 12:19 PM
Hi,

I'm testing out ZRM for backup and recovery of our MySQL database, and I would like to use the pre-scheduler-plugin to delay a backup if one of the 2 applications that write data to the database is running.

When I tried to schedule a backup with a pre-scheduler-plugin defined per the sample/default mysql-zrm.conf file, I get the following error:


-bash-4.1$ mysql-zrm-scheduler --add --interval daily --backup-set test --start 14:25
schedule:INFO: ZRM for MySQL Community Edition - version 3.0
schedule:WARNING: Unknown parameter pre-scheduler-plugin="/usr/share/mysql-zrm/plugins/pre-scheduler.pl" in /etc/mysql-zrm/mysql-zrm.conf. Assuming this is a custom parameter meant for one of the plugins
Logging to /var/log/mysql-zrm/mysql-zrm-scheduler.log
DONE


Digging a little deeper, I found that the zrm-pre-scheduler was trying to parse out "pre-scheduler" instead of "pre-scheduler-plugin". Changing the config variable pre-scheduler-plugin to pre-scheduler in the mysql-zrm.conf resolved this

Just something others might want to be aware of.

Silenus
July 9th, 2014, 01:42 PM
Upon further inspection, there are a few more issues with pre-scheduler.

The first being that the pattern is out of order from how the entries are put into the crontab file.

Original Line 111:

$pattern="\-\-action backup \-\-backup\-set $setname.*\-\-interval $int \-\-backup\-level $lev";
needs to be

$pattern="\-\-action backup \-\-backup\-set $setname.*\-\-backup\-level $lev \-\-interval $int";
as both the mysql-zrm-scheduler and zrm-pre-scheduler list the options in the order <action><backup-set><backup level><interval>

Next, the section of code where the new cron is written to the temp file needs to be changed. As it is, it generates an entry that looks like this:

50 16 * * * /usr/bin/zrm-pre-scheduler --action edit --interval daily --delay 1

The original code starting at line 164:

print OUTF "$min $hr $mday * $wday /usr/bin/$prog ";
print OUTF "--action $myaction ";
print OUTF "--interval $int " if ( $int );
print OUTF "--backup-level $lev " if ( $lev );
print OUTF "--delay $later\n";

needs to change to


print OUTF "$min $hr $mday * $wday /usr/bin/$prog ";
print OUTF "--action $myaction ";
print OUTF "--action backup ";
print OUTF "--backup-set $setname " if ( $setname);
print OUTF "--backup-level $lev " if (defined $lev );
print OUTF "--interval $int " if ( $int );
print OUTF "--delay $later\n";


Notice that the --backup-lev line is altered to use defined, as the code as it stands will not execute this line for full backups. The other lines could also use defined, however as they do not have an expected value that would eval to FALSE, they should be fine.

The third thing that should be changed is the Regex that finds the cron entry, though this isn't critical.
Original line 116:

if ( /^([^#].*)\s+([0-9]{1,2})\s+([0-9\*]{1,2})\s+([0-9\*]{1,2})\s+([0-9\*])\s+(.*$pattern\s+)(\-\-delay)\s+([0-9]{1,2})$/ ) {
Updated line 116:

if ( /^([^#].*)\s+([0-9]{1,2})\s+([0-9\*]{1,2})\s+([0-9\*]{1,2})\s+([0-9\*])\s+(.*$pattern)\s+(\-\-delay)\s+([0-9]{1,2})$/ ) {
What this does is takes the whitespace character out of the 6th capture group (command to execute until --delay). In this case the code as it stands will still work, however subsequent executions add additional spaces between the <interval> and the <delay>.

Hopefully this is helpful to others.