Amanda-Users

Re: RegEx not working?

2007-05-10 19:12:16
Subject: Re: RegEx not working?
From: Frank Smith <fsmith AT hoovers DOT com>
To: Richard Stockton <amanda AT richardleestockton DOT org>
Date: Thu, 10 May 2007 17:44:09 -0500
Richard Stockton wrote:
> Hi there,
> 
> I have 3 separate configs running on one server (bak13, bak14, bak15).
> In the past I have made sure that they did not use each other's tapes
> by use of the label regex.  Here is the regex for bak14;
> 
> labelstr "^VOL[14][0-9]" # label constraint regex: all tapes must match
> 
> The other 2 are similar, replacing only the "14" with "13" or "15".
> However, when I run "amcheck bak14" with the wrong tape in the drive,
> I get this message;
> ==================================================================
> Subject: BAK-05 /bak14 AMANDA PROBLEM: FIX BEFORE RUN, IF POSSIBLE
> 
> Amanda Tape Server Host Check
> -----------------------------
> read label `VOL132', date `20070510005900'
> label VOL132 match labelstr but it not listed in the tapelist file.
>         (expecting a new tape)
> Server check took 61.588 seconds
> 
> Amanda Backup Client Hosts Check
> --------------------------------
> Client check: 1 host checked in 0.183 seconds, 0 problems found
> 
> (brought to you by Amanda 2.5.1p3)
> ==================================================================
> 
> Why is the above regex matching the label for bak14 which should only
> accept "VOL140" through "Vol149"?  This exact same regex appears to
> work properly in earlier versions of amanda.

Did id?  A regex of "^VOL[14][0-9]" would match two ranges, both
VOL10 to VOL19 and VOL40 to VOL49. A [] with a list of characters
is an 'either' unless it is two characters separated by a - which
makes it a range, so [14] matches either a 1 or a 4.  That makes
your label VOL14 match because it starts with a 1, but it would
also match VOL12 or VOL19, as well as VOL40.

Don't you need something like:
"^VOL14[0-9]"  to match VOL140 to VOL149
or
"^VOL14[0-9][0-9]" to match VOL1400 to VOL1499 (actually either
should match longer strings as well that start with 140-149).

Frank

> 
> TIA for any enlightenment.
>   - Richard
> 


-- 
Frank Smith                                      fsmith AT hoovers DOT com
Sr. Systems Administrator                       Voice: 512-374-4673
Hoover's Online                                   Fax: 512-374-4501

<Prev in Thread] Current Thread [Next in Thread>