Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > df754e4e6f7f5fc8ab9d6ed8559f3e3d > files > 249

bacula-docs-5.0.3-19.fc16.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<!--Converted with LaTeX2HTML 2008 (1.71)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>Variable Expansion</TITLE>
<META NAME="description" CONTENT="Variable Expansion">
<META NAME="keywords" CONTENT="misc">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">

<META NAME="Generator" CONTENT="LaTeX2HTML v2008">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">

<LINK REL="STYLESHEET" HREF="misc.css">

<LINK REL="next" HREF="Using_Stunnel_Encrypt_Commu.html">
<LINK REL="previous" HREF="Python_Scripting.html">
<LINK REL="up" HREF="Bacula_Miscellaneous_Guide.html">
<LINK REL="next" HREF="Using_Stunnel_Encrypt_Commu.html">
</HEAD>

<BODY >
<!--Navigation Panel-->
<A NAME="tex2html174"
  HREF="Using_Stunnel_Encrypt_Commu.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html168"
  HREF="Bacula_Miscellaneous_Guide.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html162"
  HREF="Python_Scripting.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html170"
  HREF="Contents.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html172"
  HREF="Index.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html175"
  HREF="Using_Stunnel_Encrypt_Commu.html">Using Stunnel to Encrypt</A>
<B> Up:</B> <A NAME="tex2html169"
  HREF="Bacula_Miscellaneous_Guide.html">Bacula Miscellaneous Guide</A>
<B> Previous:</B> <A NAME="tex2html163"
  HREF="Python_Scripting.html">Python Scripting</A>
 &nbsp; <B>  <A NAME="tex2html171"
  HREF="Contents.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html173"
  HREF="Index.html">Index</A></B> 
<BR>
<BR>
<!--End of Navigation Panel-->
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>

<UL>
<LI><A NAME="tex2html176"
  HREF="Variable_Expansion.html#SECTION00310000000000000000">General Functionality</A>
<LI><A NAME="tex2html177"
  HREF="Variable_Expansion.html#SECTION00320000000000000000">Bacula Variables</A>
<LI><A NAME="tex2html178"
  HREF="Variable_Expansion.html#SECTION00330000000000000000">Full Syntax</A>
<LI><A NAME="tex2html179"
  HREF="Variable_Expansion.html#SECTION00340000000000000000">Semantics</A>
<LI><A NAME="tex2html180"
  HREF="Variable_Expansion.html#SECTION00350000000000000000">Examples</A>
</UL>
<!--End of Table of Child-Links-->
<HR>

<H1><A NAME="SECTION00300000000000000000"></A>
<A NAME="VarsChapter"></A>
<BR>
Variable Expansion
</H1>
<A NAME="319"></A>
<A NAME="320"></A>

<P>
Please note that as of version 1.37, the Variable Expansion 
is deprecated and replaced by Python scripting (not yet
documented).

<P>
Variable expansion is somewhat similar to Unix shell variable expansion.
Currently (version 1.31), it is used only in format labels, but in the future,
it will most likely be used in more places. 

<P>

<H1><A NAME="SECTION00310000000000000000">
General Functionality</A>
</H1>
<A NAME="322"></A>
<A NAME="323"></A>

<P>
This is basically a string expansion capability that permits referencing
variables, indexing arrays, conditional replacement of variables, case
conversion, substring selection, regular expression matching and replacement,
character class replacement, padding strings, repeated expansion in a user
controlled loop, support of arithmetic expressions in the loop start, step and
end conditions, and recursive expansion. 

<P>
When using variable expansion characters in a Volume Label Format record, the
format should always be enclosed in double quotes (<B>"</B>). 

<P>
For example, <B>${HOME}</B> will be replaced by your home directory as
defined in the environment. If you have defined the variable <B>xxx</B> to be
<B>Test</B>, then the reference <B>${xxx:p/7/Y/r}</B> will right pad the
contents of <B>xxx</B> to a length of seven characters filling with the
character <B>Y</B> giving <B>YYYTest</B>. 

<P>

<H1><A NAME="SECTION00320000000000000000">
Bacula Variables</A>
</H1>
<A NAME="333"></A>
<A NAME="334"></A>

<P>
Within Bacula, there are three main classes of variables with some minor
variations within the classes. The classes are: 

<P>
<DL>
<DT><STRONG>Counters</STRONG></DT>
<DD><A NAME="336"></A>
   Counters are defined by the <B>Counter</B>  resources in the Director's conf
file. The counter can either  be a temporary counter that lasts for the
duration of Bacula's  execution, or it can be a variable that is stored in 
the catalog, and thus retains its value from one Bacula execution  to another.
Counter variables may be incremented by postfixing  a plus sign (<B>+</B> after
the variable name). 

<P>
</DD>
<DT><STRONG>Internal Variables</STRONG></DT>
<DD><A NAME="339"></A>
   Internal variables are read-only,  and may be related to the current job (i.e.
Job name), or  maybe special variables such as the date and time.  The
following variables are available:  

<P>
<DL COMPACT>
<DT>Year</DT>
<DD>- the full year  
</DD>
<DT>Month</DT>
<DD>- the current month 1-12  
</DD>
<DT>Day</DT>
<DD>- the day of the month 1-31  
</DD>
<DT>Hour</DT>
<DD>- the hour 0-24  
</DD>
<DT>Minute</DT>
<DD>- the current minute 0-59  
</DD>
<DT>Second</DT>
<DD>- the current second 0-59  
</DD>
<DT>WeekDay</DT>
<DD>- the current day of the week 0-6 with 0 being Sunday  
</DD>
<DT>Job</DT>
<DD>- the job name  
</DD>
<DT>general</DT>
<DD>- the Director's name  
</DD>
<DT>Level</DT>
<DD>- the Job Level 
</DD>
<DT>Type</DT>
<DD>- the Job type 
</DD>
<DT>JobId</DT>
<DD>- the JobId 
</DD>
<DT>JobName</DT>
<DD>- the unique job name composed of Job and date  
</DD>
<DT>Storage</DT>
<DD>- the Storage daemon's name  
</DD>
<DT>Client</DT>
<DD>- the Client's name  
</DD>
<DT>NumVols</DT>
<DD>- the current number of Volumes in the Pool  
</DD>
<DT>Pool</DT>
<DD>- the Pool name  
</DD>
<DT>Catalog</DT>
<DD>- the Catalog name  
</DD>
<DT>MediaType</DT>
<DD>- the Media Type  
   
</DD>
</DL>

<P>
</DD>
<DT><STRONG>Environment Variables</STRONG></DT>
<DD><A NAME="342"></A>
   Environment variables are read-only,  and must be defined in the environment
prior to executing Bacula.  Environment variables may be either scalar or an
array, where the  elements of the array are referenced by subscripting the
variable  name (e.g. <B>${Months[3]}</B>). Environment variable arrays are 
defined by separating the elements with a vertical bar (<B>|</B>),  thus <B>set Months="Jan|Feb|Mar|Apr|..."</B> defines  an environment variable named
<B>Month</B> that will be  treated as an array, and the reference <B>${Months[3]}</B> will  yield <B>Mar</B>. The elements of the array can have 
differing lengths. 
</DD>
</DL>

<P>

<H1><A NAME="SECTION00330000000000000000">
Full Syntax</A>
</H1>
<A NAME="351"></A>
<A NAME="352"></A>

<P>
Since the syntax is quite extensive, below, you will find the pseudo BNF. The
special characters have the following meaning: 

<P>
<PRE>
 ::=     definition
 ( )     grouping if the parens are not quoted
 |       separates alternatives
 '/'     literal / (or any other character)
 CAPS    a character or character sequence
 *       preceding item can be repeated zero or more times
 ?       preceding item can appear zero or one time
 +       preceding item must appear one or more times
</PRE>
<P>
And the pseudo BNF describing the syntax is: 

<P>
<PRE>
 input       ::= ( TEXT
                 | variable
                 | INDEX_OPEN input INDEX_CLOSE (loop_limits)?
                 )*
 variable    ::= DELIM_INIT (name|expression)
 name        ::= (NAME_CHARS)+
 expression  ::= DELIM_OPEN
                 (name|variable)+
                 (INDEX_OPEN num_exp INDEX_CLOSE)?
                 (':' command)*
                 DELIM_CLOSE
 command     ::= '-' (TEXT_EXP|variable)+
               | '+' (TEXT_EXP|variable)+
               | 'o' NUMBER ('-'|',') (NUMBER)?
               | '#'
               | '*' (TEXT_EXP|variable)+
               | 's' '/' (TEXT_PATTERN)+
                     '/' (variable|TEXT_SUBST)*
                     '/' ('m'|'g'|'i'|'t')*
               | 'y' '/' (variable|TEXT_SUBST)+
                     '/' (variable|TEXT_SUBST)*
                     '/'
               | 'p' '/' NUMBER
                     '/' (variable|TEXT_SUBST)*
                     '/' ('r'|'l'|'c')
               | '%' (name|variable)+
                     ('(' (TEXT_ARGS)? ')')?
               | 'l'
               | 'u'
 num_exp     ::= operand
               | operand ('+'|'-'|'*'|'/'|'%') num_exp
 operand     ::= ('+'|'-')? NUMBER
               | INDEX_MARK
               | '(' num_exp ')'
               | variable
 loop_limits ::= DELIM_OPEN
                 (num_exp)? ',' (num_exp)? (',' (num_exp)?)?
                 DELIM_CLOSE
 NUMBER      ::= ('0'|...|'9')+
 TEXT_PATTERN::= (^('/'))+
 TEXT_SUBST  ::= (^(DELIM_INIT|'/'))+
 TEXT_ARGS   ::= (^(DELIM_INIT|')'))+
 TEXT_EXP    ::= (^(DELIM_INIT|DELIM_CLOSE|':'|'+'))+
 TEXT        ::= (^(DELIM_INIT|INDEX_OPEN|INDEX_CLOSE))+
 DELIM_INIT  ::= '$'
 DELIM_OPEN  ::= '{'
 DELIM_CLOSE ::= '}'
 INDEX_OPEN  ::= '['
 INDEX_CLOSE ::= ']'
 INDEX_MARK  ::= '#'
 NAME_CHARS  ::= 'a'|...|'z'|'A'|...|'Z'|'0'|...|'9'
</PRE>
<P>

<H1><A NAME="SECTION00340000000000000000">
Semantics</A>
</H1>
<A NAME="358"></A>

<P>
The items listed in <B>command</B> above, which always follow a colon (<B>:</B>)
have the following meanings: 

<P>
<PRE>
 -    perform substitution if variable is empty
 +    perform substitution if variable is not empty
 o    cut out substring of the variable value
 #    length of the variable value
 *    substitute empty string if the variable value is not empty,
      otherwise substitute the trailing parameter
 s    regular expression search and replace. The trailing
      options are: m = multiline, i = case insensitive,
                   g = global,    t = plain text (no regexp)
 y    transpose characters from class A to class B
 p    pad variable to l = left, r = right or c = center,
      with second value.
 %    special function call (none implemented)
 l    lower case the variable value
 u    upper case the variable value
</PRE>
<P>
The <B>loop_limits</B> are start, step, and end values. 

<P>
A counter variable name followed immediately by a plus (<B>+</B>) will cause
the counter to be incremented by one. 

<P>

<H1><A NAME="SECTION00350000000000000000">
Examples</A>
</H1>
<A NAME="366"></A>

<P>
To create an ISO date: 

<P>
<PRE>
  DLT-${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}
</PRE>
<P>
on 20 June 2003 would give <B>DLT-2003-06-20</B> 

<P>
If you set the environment variable <B>mon</B> to 

<P>
<PRE>
   January|February|March|April|May|...
   File-${mon[${Month}]}/${Day}/${Year}
</PRE>
<P>
on the first of March would give <B>File-March/1/2003 </B> 

<P>
<HR>
<!--Navigation Panel-->
<A NAME="tex2html174"
  HREF="Using_Stunnel_Encrypt_Commu.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html168"
  HREF="Bacula_Miscellaneous_Guide.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html162"
  HREF="Python_Scripting.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html170"
  HREF="Contents.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html172"
  HREF="Index.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html175"
  HREF="Using_Stunnel_Encrypt_Commu.html">Using Stunnel to Encrypt</A>
<B> Up:</B> <A NAME="tex2html169"
  HREF="Bacula_Miscellaneous_Guide.html">Bacula Miscellaneous Guide</A>
<B> Previous:</B> <A NAME="tex2html163"
  HREF="Python_Scripting.html">Python Scripting</A>
 &nbsp; <B>  <A NAME="tex2html171"
  HREF="Contents.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html173"
  HREF="Index.html">Index</A></B> 
<!--End of Navigation Panel-->
<ADDRESS>

2012-01-24
</ADDRESS>
</BODY>
</HTML>