~ubuntu-branches/ubuntu/utopic/bacula-doc/utopic

« back to all changes in this revision

Viewing changes to manual/bacula/Variable_Expansion.html

  • Committer: Bazaar Package Importer
  • Author(s): John Goerzen
  • Date: 2010-02-09 08:35:53 UTC
  • mfrom: (1.3.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100209083553-qsrpwqsv01wnh8lz
Tags: 5.0.0-1
* New upstream release.  Closes: #380247.
* Removed tetex build-deps, fixing FTBFS.  Closes: #562310.
* Build all English manuals mentioned in the README.  The other
  languages are not ready for deployment.  Closes: #561686.
* Switch to dpkg-source 3.0 (quilt) format since upstream ships a
  tar.bz2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
 
 
3
 
<!--Converted with LaTeX2HTML 2002-2-1 (1.71)
4
 
original version by:  Nikos Drakos, CBLU, University of Leeds
5
 
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
6
 
* with significant contributions from:
7
 
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
8
 
<HTML>
9
 
<HEAD>
10
 
<TITLE>Variable Expansion</TITLE>
11
 
<META NAME="description" CONTENT="Variable Expansion">
12
 
<META NAME="keywords" CONTENT="bacula">
13
 
<META NAME="resource-type" CONTENT="document">
14
 
<META NAME="distribution" CONTENT="global">
15
 
 
16
 
<META NAME="Generator" CONTENT="LaTeX2HTML v2002-2-1">
17
 
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
18
 
 
19
 
<LINK REL="STYLESHEET" HREF="bacula.css">
20
 
 
21
 
<LINK REL="next" HREF="Using_Stunne_Encryp_Commun.html">
22
 
<LINK REL="previous" HREF="Thanks.html">
23
 
<LINK REL="up" HREF="Bacula_Users_Guide.html">
24
 
<LINK REL="next" HREF="Using_Stunne_Encryp_Commun.html">
25
 
</HEAD>
26
 
 
27
 
<BODY >
28
 
 
29
 
<DIV CLASS="navigation"><!--Navigation Panel-->
30
 
<A NAME="tex2html2537"
31
 
  HREF="Using_Stunne_Encryp_Commun.html">
32
 
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
33
 
<A NAME="tex2html2531"
34
 
  HREF="Bacula_Users_Guide.html">
35
 
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
36
 
<A NAME="tex2html2525"
37
 
  HREF="Thanks.html">
38
 
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
39
 
<A NAME="tex2html2533"
40
 
  HREF="Contents.html">
41
 
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
42
 
<A NAME="tex2html2535"
43
 
  HREF="General_Index.html">
44
 
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
45
 
<BR>
46
 
<B> Next:</B> <A NAME="tex2html2538"
47
 
  HREF="Using_Stunne_Encryp_Commun.html">Using Stunnel to Encrypt</A>
48
 
<B> Up:</B> <A NAME="tex2html2532"
49
 
  HREF="Bacula_Users_Guide.html">Bacula User's Guide</A>
50
 
<B> Previous:</B> <A NAME="tex2html2526"
51
 
  HREF="Thanks.html">Thanks</A>
52
 
 &nbsp; <B>  <A NAME="tex2html2534"
53
 
  HREF="Contents.html">Contents</A></B> 
54
 
 &nbsp; <B>  <A NAME="tex2html2536"
55
 
  HREF="General_Index.html">Index</A></B> 
56
 
<BR>
57
 
<BR></DIV>
58
 
<!--End of Navigation Panel-->
59
 
<!--Table of Child-Links-->
60
 
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>
61
 
 
62
 
<UL CLASS="ChildLinks">
63
 
<LI><A NAME="tex2html2539"
64
 
  HREF="Variable_Expansion.html#SECTION005810000000000000000">General Functionality</A>
65
 
<LI><A NAME="tex2html2540"
66
 
  HREF="Variable_Expansion.html#SECTION005820000000000000000">Bacula Variables</A>
67
 
<LI><A NAME="tex2html2541"
68
 
  HREF="Variable_Expansion.html#SECTION005830000000000000000">Full Syntax</A>
69
 
<LI><A NAME="tex2html2542"
70
 
  HREF="Variable_Expansion.html#SECTION005840000000000000000">Semantics</A>
71
 
<LI><A NAME="tex2html2543"
72
 
  HREF="Variable_Expansion.html#SECTION005850000000000000000">Examples</A>
73
 
</UL>
74
 
<!--End of Table of Child-Links-->
75
 
<HR>
76
 
 
77
 
<H1><A NAME="SECTION005800000000000000000"></A>
78
 
<A NAME="VarsChapter"></A>
79
 
<BR>
80
 
Variable Expansion
81
 
</H1>
82
 
<A NAME="28586"></A>
83
 
<A NAME="28587"></A>
84
 
 
85
 
<P>
86
 
Please note that as of version 1.37, the Variable Expansion 
87
 
is deprecated and replaced by Python scripting (not yet
88
 
documented).
89
 
 
90
 
<P>
91
 
Variable expansion is somewhat similar to Unix shell variable expansion.
92
 
Currently (version 1.31), it is used only in format labels, but in the future,
93
 
it will most likely be used in more places. 
94
 
 
95
 
<P>
96
 
 
97
 
<H1><A NAME="SECTION005810000000000000000">
98
 
General Functionality</A>
99
 
</H1>
100
 
<A NAME="28589"></A>
101
 
<A NAME="28590"></A>
102
 
 
103
 
<P>
104
 
This is basically a string expansion capability that permits referencing
105
 
variables, indexing arrays, conditional replacement of variables, case
106
 
conversion, substring selection, regular expression matching and replacement,
107
 
character class replacement, padding strings, repeated expansion in a user
108
 
controlled loop, support of arithmetic expressions in the loop start, step and
109
 
end conditions, and recursive expansion. 
110
 
 
111
 
<P>
112
 
When using variable expansion characters in a Volume Label Format record, the
113
 
format should always be enclosed in double quotes (<B>"</B>). 
114
 
 
115
 
<P>
116
 
For example, <B>${HOME}</B> will be replaced by your home directory as
117
 
defined in the environment. If you have defined the variable <B>xxx</B> to be
118
 
<B>Test</B>, then the reference <B>${xxx:p/7/Y/r}</B> will right pad the
119
 
contents of <B>xxx</B> to a length of seven characters filling with the
120
 
character <B>Y</B> giving <B>YYYTest</B>. 
121
 
 
122
 
<P>
123
 
 
124
 
<H1><A NAME="SECTION005820000000000000000">
125
 
Bacula Variables</A>
126
 
</H1>
127
 
<A NAME="28600"></A>
128
 
<A NAME="28601"></A>
129
 
 
130
 
<P>
131
 
Within Bacula, there are three main classes of variables with some minor
132
 
variations within the classes. The classes are: 
133
 
 
134
 
<P>
135
 
<DL>
136
 
<DT><STRONG>Counters</STRONG></DT>
137
 
<DD><A NAME="28603"></A>
138
 
   Counters are defined by the <B>Counter</B>  resources in the Director's conf
139
 
file. The counter can either  be a temporary counter that lasts for the
140
 
duration of Bacula's  execution, or it can be a variable that is stored in 
141
 
the catalog, and thus retains its value from one Bacula execution  to another.
142
 
Counter variables may be incremented by postfixing  a plus sign (<B>+</B> after
143
 
the variable name). 
144
 
 
145
 
<P>
146
 
</DD>
147
 
<DT><STRONG>Internal Variables</STRONG></DT>
148
 
<DD><A NAME="28606"></A>
149
 
   Internal variables are read-only,  and may be related to the current job (i.e.
150
 
Job name), or  maybe special variables such as the date and time.  The
151
 
following variables are available:  
152
 
 
153
 
<P>
154
 
<DL COMPACT>
155
 
<DT>Year</DT>
156
 
<DD>-- the full year  
157
 
</DD>
158
 
<DT>Month</DT>
159
 
<DD>-- the current month 1-12  
160
 
</DD>
161
 
<DT>Day</DT>
162
 
<DD>-- the day of the month 1-31  
163
 
</DD>
164
 
<DT>Hour</DT>
165
 
<DD>-- the hour 0-24  
166
 
</DD>
167
 
<DT>Minute</DT>
168
 
<DD>-- the current minute 0-59  
169
 
</DD>
170
 
<DT>Second</DT>
171
 
<DD>-- the current second 0-59  
172
 
</DD>
173
 
<DT>WeekDay</DT>
174
 
<DD>-- the current day of the week 0-6 with 0 being Sunday  
175
 
</DD>
176
 
<DT>Job</DT>
177
 
<DD>-- the job name  
178
 
</DD>
179
 
<DT>Dir</DT>
180
 
<DD>-- the Director's name  
181
 
</DD>
182
 
<DT>Level</DT>
183
 
<DD>-- the Job Level 
184
 
</DD>
185
 
<DT>Type</DT>
186
 
<DD>-- the Job type 
187
 
</DD>
188
 
<DT>JobId</DT>
189
 
<DD>-- the JobId 
190
 
</DD>
191
 
<DT>JobName</DT>
192
 
<DD>-- the unique job name composed of Job and date  
193
 
</DD>
194
 
<DT>Storage</DT>
195
 
<DD>-- the Storage daemon's name  
196
 
</DD>
197
 
<DT>Client</DT>
198
 
<DD>-- the Client's name  
199
 
</DD>
200
 
<DT>NumVols</DT>
201
 
<DD>-- the current number of Volumes in the Pool  
202
 
</DD>
203
 
<DT>Pool</DT>
204
 
<DD>-- the Pool name  
205
 
</DD>
206
 
<DT>Catalog</DT>
207
 
<DD>-- the Catalog name  
208
 
</DD>
209
 
<DT>MediaType</DT>
210
 
<DD>-- the Media Type  
211
 
   
212
 
</DD>
213
 
</DL>
214
 
 
215
 
<P>
216
 
</DD>
217
 
<DT><STRONG>Environment Variables</STRONG></DT>
218
 
<DD><A NAME="28609"></A>
219
 
   Environment variables are read-only,  and must be defined in the environment
220
 
prior to executing Bacula.  Environment variables may be either scalar or an
221
 
array, where the  elements of the array are referenced by subscripting the
222
 
variable  name (e.g. <B>${Months[3]}</B>). Environment variable arrays are 
223
 
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
224
 
<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 
225
 
differing lengths. 
226
 
</DD>
227
 
</DL>
228
 
 
229
 
<P>
230
 
 
231
 
<H1><A NAME="SECTION005830000000000000000">
232
 
Full Syntax</A>
233
 
</H1>
234
 
<A NAME="28618"></A>
235
 
<A NAME="28619"></A>
236
 
 
237
 
<P>
238
 
Since the syntax is quite extensive, below, you will find the pseudo BNF. The
239
 
special characters have the following meaning: 
240
 
 
241
 
<P>
242
 
<PRE>
243
 
 ::=     definition
244
 
 ( )     grouping if the parens are not quoted
245
 
 |       separates alternatives
246
 
 '/'     literal / (or any other character)
247
 
 CAPS    a character or character sequence
248
 
 *       preceding item can be repeated zero or more times
249
 
 ?       preceding item can appear zero or one time
250
 
 +       preceding item must appear one or more times
251
 
</PRE>
252
 
<P>
253
 
And the pseudo BNF describing the syntax is: 
254
 
 
255
 
<P>
256
 
<PRE>
257
 
 input       ::= ( TEXT
258
 
                 | variable
259
 
                 | INDEX_OPEN input INDEX_CLOSE (loop_limits)?
260
 
                 )*
261
 
 variable    ::= DELIM_INIT (name|expression)
262
 
 name        ::= (NAME_CHARS)+
263
 
 expression  ::= DELIM_OPEN
264
 
                 (name|variable)+
265
 
                 (INDEX_OPEN num_exp INDEX_CLOSE)?
266
 
                 (':' command)*
267
 
                 DELIM_CLOSE
268
 
 command     ::= '-' (TEXT_EXP|variable)+
269
 
               | '+' (TEXT_EXP|variable)+
270
 
               | 'o' NUMBER ('-'|',') (NUMBER)?
271
 
               | '#'
272
 
               | '*' (TEXT_EXP|variable)+
273
 
               | 's' '/' (TEXT_PATTERN)+
274
 
                     '/' (variable|TEXT_SUBST)*
275
 
                     '/' ('m'|'g'|'i'|'t')*
276
 
               | 'y' '/' (variable|TEXT_SUBST)+
277
 
                     '/' (variable|TEXT_SUBST)*
278
 
                     '/'
279
 
               | 'p' '/' NUMBER
280
 
                     '/' (variable|TEXT_SUBST)*
281
 
                     '/' ('r'|'l'|'c')
282
 
               | '%' (name|variable)+
283
 
                     ('(' (TEXT_ARGS)? ')')?
284
 
               | 'l'
285
 
               | 'u'
286
 
 num_exp     ::= operand
287
 
               | operand ('+'|'-'|'*'|'/'|'%') num_exp
288
 
 operand     ::= ('+'|'-')? NUMBER
289
 
               | INDEX_MARK
290
 
               | '(' num_exp ')'
291
 
               | variable
292
 
 loop_limits ::= DELIM_OPEN
293
 
                 (num_exp)? ',' (num_exp)? (',' (num_exp)?)?
294
 
                 DELIM_CLOSE
295
 
 NUMBER      ::= ('0'|...|'9')+
296
 
 TEXT_PATTERN::= (^('/'))+
297
 
 TEXT_SUBST  ::= (^(DELIM_INIT|'/'))+
298
 
 TEXT_ARGS   ::= (^(DELIM_INIT|')'))+
299
 
 TEXT_EXP    ::= (^(DELIM_INIT|DELIM_CLOSE|':'|'+'))+
300
 
 TEXT        ::= (^(DELIM_INIT|INDEX_OPEN|INDEX_CLOSE))+
301
 
 DELIM_INIT  ::= '$'
302
 
 DELIM_OPEN  ::= '{'
303
 
 DELIM_CLOSE ::= '}'
304
 
 INDEX_OPEN  ::= '['
305
 
 INDEX_CLOSE ::= ']'
306
 
 INDEX_MARK  ::= '#'
307
 
 NAME_CHARS  ::= 'a'|...|'z'|'A'|...|'Z'|'0'|...|'9'
308
 
</PRE>
309
 
<P>
310
 
 
311
 
<H1><A NAME="SECTION005840000000000000000">
312
 
Semantics</A>
313
 
</H1>
314
 
<A NAME="28625"></A>
315
 
 
316
 
<P>
317
 
The items listed in <B>command</B> above, which always follow a colon (<B>:</B>)
318
 
have the following meanings: 
319
 
 
320
 
<P>
321
 
<PRE>
322
 
 -    perform substitution if variable is empty
323
 
 +    perform substitution if variable is not empty
324
 
 o    cut out substring of the variable value
325
 
 #    length of the variable value
326
 
 *    substitute empty string if the variable value is not empty,
327
 
      otherwise substitute the trailing parameter
328
 
 s    regular expression search and replace. The trailing
329
 
      options are: m = multiline, i = case insensitive,
330
 
                   g = global,    t = plain text (no regexp)
331
 
 y    transpose characters from class A to class B
332
 
 p    pad variable to l = left, r = right or c = center,
333
 
      with second value.
334
 
 %    special function call (none implemented)
335
 
 l    lower case the variable value
336
 
 u    upper case the variable value
337
 
</PRE>
338
 
<P>
339
 
The <B>loop_limits</B> are start, step, and end values. 
340
 
 
341
 
<P>
342
 
A counter variable name followed immediately by a plus (<B>+</B>) will cause
343
 
the counter to be incremented by one. 
344
 
 
345
 
<P>
346
 
 
347
 
<H1><A NAME="SECTION005850000000000000000">
348
 
Examples</A>
349
 
</H1>
350
 
<A NAME="28633"></A>
351
 
 
352
 
<P>
353
 
To create an ISO date: 
354
 
 
355
 
<P>
356
 
<PRE>
357
 
  DLT-${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}
358
 
</PRE>
359
 
<P>
360
 
on 20 June 2003 would give <B>DLT-2003-06-20</B> 
361
 
 
362
 
<P>
363
 
If you set the environment variable <B>mon</B> to 
364
 
 
365
 
<P>
366
 
<PRE>
367
 
   January|February|March|April|May|...
368
 
   File-${mon[${Month}]}/${Day}/${Year}
369
 
</PRE>
370
 
<P>
371
 
on the first of March would give <B>File-March/1/2003 </B> 
372
 
 
373
 
<P>
374
 
 
375
 
<DIV CLASS="navigation"><HR>
376
 
<!--Navigation Panel-->
377
 
<A NAME="tex2html2537"
378
 
  HREF="Using_Stunne_Encryp_Commun.html">
379
 
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
380
 
<A NAME="tex2html2531"
381
 
  HREF="Bacula_Users_Guide.html">
382
 
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
383
 
<A NAME="tex2html2525"
384
 
  HREF="Thanks.html">
385
 
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
386
 
<A NAME="tex2html2533"
387
 
  HREF="Contents.html">
388
 
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
389
 
<A NAME="tex2html2535"
390
 
  HREF="General_Index.html">
391
 
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
392
 
<BR>
393
 
<B> Next:</B> <A NAME="tex2html2538"
394
 
  HREF="Using_Stunne_Encryp_Commun.html">Using Stunnel to Encrypt</A>
395
 
<B> Up:</B> <A NAME="tex2html2532"
396
 
  HREF="Bacula_Users_Guide.html">Bacula User's Guide</A>
397
 
<B> Previous:</B> <A NAME="tex2html2526"
398
 
  HREF="Thanks.html">Thanks</A>
399
 
 &nbsp; <B>  <A NAME="tex2html2534"
400
 
  HREF="Contents.html">Contents</A></B> 
401
 
 &nbsp; <B>  <A NAME="tex2html2536"
402
 
  HREF="General_Index.html">Index</A></B> </DIV>
403
 
<!--End of Navigation Panel-->
404
 
<ADDRESS>
405
 
Kern Sibbald
406
 
2009-01-04
407
 
</ADDRESS>
408
 
</BODY>
409
 
</HTML>