Bacula-users

Re: [Bacula-users] How do counters work?

2011-06-20 22:40:14
Subject: Re: [Bacula-users] How do counters work?
From: Stuart McGraw <smcg4191 AT frii DOT com>
To: bacula-users AT lists.sourceforge DOT net
Date: Mon, 20 Jun 2011 20:36:34 -0600
On 06/20/2011 04:51 PM, Dan Langille wrote:
> I;m posting this because nobody has answered you yet. 
> Perhaps my prompts will get you to supply additional information.  :)

Thanks, much appreciated.
 
> On Jun 20, 2011, at 1:41 PM, Stuart McGraw wrote:
> 
>> So I am generating backup volumes limited in size 
>> to fit on a DVD.  Since I use automatic volume labeling
>> and some backups result in multiple volumes, I include
>> a counter in the label name.  I want its value to be
>> 1 for the first volume of the job, 2 for the second, 
>> etc.
> 
> Well, that's not the purpose of counters.  Volume names
> are really for Bacula, not for humans.   Counters are
> there just to help with automated labeling of Volumes.
> 
> I suggest that discussion on whether or not we like this
> behavior that is outside the scope of this discussion.  :)

That's fine.  But I don't understand your statement 
that volume names (the things set by the LabelFormat
directive, yes?) are solely for Bacula.  Why then does 
the LabelFormat directive exist rather than Bacula
simply using an incrementing serial number?  It seems
to me self-evident that both humans and Bacula need
to use them and they should, to the extent possible, 
be constructed to meet both needs.  

>> First problem: counter does not get reset per job
>> but only when director is restarted.  (This strikes 
>> me as particularly useless behavior... is not the 
>> most frequent (only?) use of counters in a label?
> 
> Just because a feature does not do what you want, does
> not make it useless. 

Of course.  I was trying to convey that *I* could
not see a use for it.

> Clearly it was designed with a use
> case in mind.  :)

That may well be but often, especially early
in development, things that seemed like a good
ideas turn out to be not as useful as envisioned.

I asked if I was missing something as a way of
soliciting an explanation of its use.  However
that was just an aside and not directly relevant
to my problem.

>> Why would one want a value in a long-lived label
>> dependent on an arbitrary event like a service 
>> restart?  Maybe I am missing something). 
> 
> We have not seen your counter usage, so we cannot comment upon it. 

Sorry, I though my explanation was sufficient.  I 
create a (db persistent) counter and use that counter
in a LabelFormat directive.  See below.

> You didn't mention the docs, so perhaps these will help.
> 
> http://www.bacula.org/5.0.x-manuals/en/misc/misc/Variable_Expansion.html
> http://www.bacula.org/5.0.x-manuals/en/main/main/Configuring_Director.html#SECTION0018190000000000000000

Thanks, I've read those (multiple times :-)

>> So I specify a catalog and save the counter in the
>> database.  I write a before job script to reset
>> the counter to its minimumvalue.  
>> 
>> But although the script seems to be working, it has 
>> no effect.  Even if I change the counter value in the 
>> database by hand after the director has started but
>> before running the job, the job uses the old counter 
>> value.  Is it possible that the director reads the 
>> counter value at startup, maintains it internally, 
>> and only writes back to the database when its 
>> incremented?
> 
> It is difficult to judge a script we have not seen.  :)

The script is irrelevant.

Add a (db persistent) counter to a bacula-dir.conf 
file, eg;

   Counter {
    Name = MyCtr
    Minimum = 1
    Catalog = MyCatalog
    }

Use that counter in a Pool resource LabelFormat
directive where the SD is set up to auto-label
new volumes:

    LabelFormat = "${JobName}-${MyCtr+}"

Start the director (so that it will create the 
counter in the database), then stop the director.

Manually change the counter value:

  psql# UPDATE counters SET currentvalue=6 WHERE counter='MyCtr';

Start director and run a job.  Note that the label 
generated is "...-6".  Change the value of the counter

  psql# UPDATE counters SET currentvalue=3 WHERE counter='MyCtr';

Run another job and note that the the label generated 
this time is not "...-3" but is instead, "...-7".

Obviously, if Bacula does not ever re-read the counter 
value from the database, the most perfect counter-
changing script in the world run in a RunBeforeJob will 
have no effect.

If you still want to see my conf files and counter reset
script, I'll be happy to post them -- I just thought that
they provide the same information I give above in a more 
obfuscated form.  But if you think they'll be helpful,
fine.

To recap, I am hoping there is some way of having Bacula 
auto-label volumes with first label in a *job* having 
a suffix of "-1", and if a second or subsequent volumes 
are necessary, generated with suffixes of "-2", "-3", 
etc, with the next job starting at "-1" again.









------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users

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