]> git.sur5r.net Git - bacula/docs/blob - docs/manual-fr/tips.tex
Initial revision
[bacula/docs] / docs / manual-fr / tips.tex
1 %%
2 %%
3
4 \section*{Tips and Suggestions}
5 \label{_ChapterStart8}
6 \index[general]{Tips and Suggestions }
7 \index[general]{Suggestions!Tips and }
8 \addcontentsline{toc}{section}{Tips and Suggestions}
9
10 \subsection*{Examples}
11 \label{examples}
12 \index[general]{Examples }
13 \addcontentsline{toc}{subsection}{Examples}
14
15 There are a number of example scripts for various things that can be found in
16 the {\bf example} subdirectory and its subdirectories of the Bacula source
17 distribution. 
18
19 \subsection*{Upgrading Bacula Versions}
20 \label{upgrading}
21 \index[general]{Upgrading Bacula Versions }
22 \index[general]{Versions!Upgrading Bacula }
23 \addcontentsline{toc}{subsection}{Upgrading Bacula Versions}
24
25 The first thing to do before upgrading from one version to another is to
26 ensure that don't overwrite your production (current) version of Bacula until
27 you have tested that the new version works. 
28
29 If you have installed Bacula into a single directory, this is simple: simply
30 make a copy of your Bacula directory. 
31
32 If you have done a more typical Unix installation where the binaries are
33 placed in one directory and the configuration files are placed in another,
34 then the simplest way is to configure your new Bacula to go into a single
35 file. 
36
37 Whatever your situation may be (one of the two just described), you should
38 probably start with the {\bf defaultconf} script that can be found in the {\bf
39 examples} subdirectory. Copy this script to the main Bacula directory, modify
40 it as necessary (there should not need to be many modifications), configure
41 Bacula, build it, install it, then stop your production Bacula, copy all the
42 {\bf *.conf} files from your production Bacula directory to the test Bacula
43 directory, start the test version, and run a few test backups. If all seems
44 good, then you can proceed to install the new Bacula in place of or possibly
45 over the old Bacula. 
46
47 When installing a new Bacula you need not worry about losing the changes you
48 made to your configuration files as the installation process will not
49 overwrite them. 
50
51 \subsection*{Getting Notified of Job Completion}
52 \label{notification}
53 \index[general]{Getting Notified of Job Completion }
54 \index[general]{Completion!Getting Notified of Job }
55 \addcontentsline{toc}{subsection}{Getting Notified of Job Completion}
56
57 One of the first things you should do is to ensure that you are being properly
58 notified of the status of each Job run by Bacula, or at a minimum of each Job
59 that terminates with an error. 
60
61 Until you are completely comfortable with {\bf Bacula}, we recommend that you
62 send an email to yourself for each Job that is run. This is most easily
63 accomplished by adding an email notification address in the {\bf Messages}
64 resource of your Director's configuration file. An email is automatically
65 configured in the default configuration files, but you must ensure that the
66 default {\bf root} address is replaced by your email address. 
67
68 For examples of how I (Kern) configure my system, please take a look at the
69 {\bf .conf} files found in the {\bf examples} sub-directory. We recommend the
70 following configuration (where you change the paths and email address to
71 correspond to your setup). Note, the {\bf mailcommand} and {\bf
72 operatorcommand} should be on a single line. They were split here for
73 presentation: 
74
75 \footnotesize
76 \begin{verbatim}
77 Messages {
78   Name = Standard
79   mailcommand = "/home/bacula/bin/bsmtp -h localhost
80                 -f \"\(Bacula\) %r\"
81                 -s \"Bacula: %t %e of %c %l\" %r"
82   operatorcommand = "/home/bacula/bin/bsmtp -h localhost
83                 -f \"\(Bacula\) %r\"
84                 -s \"Bacula: Intervention needed for %j\" %r"
85   Mail = your-email-address = all, !skipped, !terminate
86   append = "/home/bacula/bin/log" = all, !skipped, !terminate
87   operator = your-email-address = mount
88   console = all, !skipped, !saved
89 }
90 \end{verbatim}
91 \normalsize
92
93 You will need to ensure that the {\bf /home/bacula/bin} path on the {\bf
94 mailcommand} and the {\bf operatorcommand} lines points to your {\bf Bacula}
95 binary directory where the {\bf bsmtp} program will be installed. You will
96 also want to ensure that the {\bf your-email-address} is replaced by your
97 email address, and finally, you will also need to ensure that the {\bf
98 /home/bacula/bin/log} points to the file where you want to log all messages. 
99
100 With the above Messages resource, you will be notified by email of every Job
101 that ran, all the output will be appended to the {\bf log} file you specify,
102 all output will be directed to the console program, and all mount messages
103 will be emailed to you. Note, some messages will be sent to multiple
104 destinations. 
105
106 The form of the mailcommand is a bit complicated, but it allows you to
107 distinguish whether the Job terminated in error or terminated normally. Please
108 see the 
109 \ilink{Mail Command}{mailcommand} section of the Messages
110 Resource chapter of this manual for the details of the substitution characters
111 used above. 
112
113 Once you are totally comfortable with Bacula as I am, or if you have a large
114 number of nightly Jobs as I do (eight), you will probably want to change the
115 {\bf Mail} command to {\bf Mail On Error} which will generate an email message
116 only if the Job terminates in error. If the Job terminates normally, no email
117 message will be sent, but the output will still be appended to the log file as
118 well as sent to the Console program. 
119
120 \subsection*{Getting Email Notification to Work}
121 \label{email}
122 \index[general]{Work!Getting Email Notification to }
123 \index[general]{Getting Email Notification to Work }
124 \addcontentsline{toc}{subsection}{Getting Email Notification to Work}
125
126 The section above describes how to get email notification of job status.
127 Occasionally, however, users have problems receiving any email at all. In that
128 case, the things to check are the following: 
129
130 \begin{itemize}
131 \item Ensure that you have a valid email address specified on your  {\bf Mail}
132    record in the Director's Messages resource. The email  address should be fully
133    qualified. Simply using {\bf root} generally  will not work, rather you should
134 use {\bf root@localhost} or better  yet your full domain.  
135 \item Ensure that you do not have a {\bf Mail} record in the Storage  daemon's
136    or File daemon's configuration files. The only record  you should have is {\bf
137    director}:  
138
139 \footnotesize
140 \begin{verbatim}
141       director = director-name = all
142       
143 \end{verbatim}
144 \normalsize
145
146 \item If all else fails, try replacing the {\bf mailcommand} with 
147
148    \footnotesize
149 \begin{verbatim}
150 mailcommand = "mail -s test your@domain.com"
151 \end{verbatim}
152 \normalsize
153
154 \item Once the above is working, assuming you want to use {\bf bsmtp},  submit
155    the desired bsmtp command by hand and ensure that the email  is delivered,
156    then put that command into {\bf Bacula}. Small  differences in things such as
157 the parenthesis around the word  Bacula can make a big difference to some
158 bsmtp programs.  For example, you might start simply by using: 
159
160 \footnotesize
161 \begin{verbatim}
162 mailcommand = "/home/bacula/bin/bsmtp -f \"root@localhost\" %r"
163 \end{verbatim}
164 \normalsize
165
166 \end{itemize}
167
168 \subsection*{Getting Notified that Bacula is Running}
169 \label{JobNotification}
170 \index[general]{Running!Getting Notified that Bacula is }
171 \index[general]{Getting Notified that Bacula is Running }
172 \addcontentsline{toc}{subsection}{Getting Notified that Bacula is Running}
173
174 If like me, you have setup Bacula so that email is sent only when a Job has
175 errors, as described in the previous section of this chapter, inevitably, one
176 day, something will go wrong and {\bf Bacula} can stall. This could be because
177 Bacula crashes, which is vary rare, or more likely the network has caused {\bf
178 Bacula} to {\bf hang} for some unknown reason. 
179
180 To avoid this, you can use the {\bf RunAfterJob} command in the Job resource
181 to schedule a Job nightly, or weekly that simply emails you a message saying
182 that Bacula is still running. For example, I have setup the following Job in
183 my Director's configuration file: 
184
185 \footnotesize
186 \begin{verbatim}
187 Schedule {
188   Name = "Watchdog"
189   Run = Level=Full sun-sat at 6:05
190 }
191 Job {
192   Name = "Watchdog"
193   Type = Admin
194   Client=Watchdog
195   FileSet="Verify Set"
196   Messages = Standard
197   Storage = DLTDrive
198   Pool = Default
199   Schedule = "Watchdog"
200   RunAfterJob = "/home/kern/bacula/bin/watchdog %c %d"
201 }
202 Client {
203   Name = Watchdog
204   Address = rufus
205   FDPort = 9102
206   Catalog = Verify
207   Password = ""
208   File Retention = 1day
209   Job Retention = 1 month
210   AutoPrune = yes
211 }
212 \end{verbatim}
213 \normalsize
214
215 Where I established a schedule to run the Job nightly. The Job itself is type
216 {\bf Admin} which means that it doesn't actually do anything, and I've defined
217 a FileSet, Pool, Storage, and Client, all of which are not really used (and
218 probably don't need to be specified). The key aspect of this Job is the
219 command: 
220
221 \footnotesize
222 \begin{verbatim}
223   RunAfterJob = "/home/kern/bacula/bin/watchdog %c %d"
224 \end{verbatim}
225 \normalsize
226
227 which runs my ``watchdog'' script. As an example, I have added the Job codes
228 \%c and \%d which will cause the Client name and the Director's name to be
229 passed to the script. For example, if the Client's name is {\bf Watchdog} and
230 the Director's name is {\bf main-dir} then referencing \$1 in the script would
231 get {\bf Watchdog} and referencing \$2 would get {\bf main-dir}. In this case,
232 having the script know the Client and Director's name is not really useful,
233 but in other situations it may be. 
234
235 You can put anything in the watchdog scrip. In my case, I like to monitor the
236 size of my catalog to be sure that {\bf Bacula} is really pruning it. The
237 following is my watchdog script: 
238
239 \footnotesize
240 \begin{verbatim}
241 #!/bin/sh
242 cd /home/kern/mysql/var/bacula
243 du . * |
244 /home/kern/bacula/bin/bsmtp  \
245    -f "\(Bacula\) abuse@whitehouse.com" -h mail.yyyy.com \
246    -s "Bacula running" abuse@whitehouse.com
247 \end{verbatim}
248 \normalsize
249
250 If you just wish to send yourself a message, you can do it with: 
251
252 \footnotesize
253 \begin{verbatim}
254 #!/bin/sh
255 cd /home/kern/mysql/var/bacula
256 /home/kern/bacula/bin/bsmtp  \
257    -f "\(Bacula\) abuse@whitehouse.com" -h mail.yyyy.com \
258    -s "Bacula running" abuse@whitehouse.com <<END-OF-DATA
259 Bacula is still running!!!
260 END-OF-DATA
261 \end{verbatim}
262 \normalsize
263
264 \subsection*{Maintaining a Valid Bootstrap File}
265 \label{bootstrap}
266 \index[general]{Maintaining a Valid Bootstrap File }
267 \index[general]{File!Maintaining a Valid Bootstrap }
268 \addcontentsline{toc}{subsection}{Maintaining a Valid Bootstrap File}
269
270 By using a 
271 \ilink{ WriteBootstrap}{writebootstrap} record in each of your
272 Director's Job resources, you can constantly maintain a 
273 \ilink{bootstrap}{_ChapterStart43} file that will enable you to
274 recover the state of your system as of the last backup without having the
275 Bacula catalog. This permits you to more easily recover from a disaster that
276 destroys your Bacula catalog. 
277
278 When a Job resource has a {\bf WriteBootstrap} record, Bacula will maintain
279 the designated file (normally on another system but mounted by NSF) with up to
280 date information necessary to restore your system. For example, in my
281 Director's configuration file, I have the following record: 
282
283 \footnotesize
284 \begin{verbatim}
285  Write Bootstrap = "/mnt/deuter/files/backup/client-name.bsr"
286 \end{verbatim}
287 \normalsize
288
289 where I replace {\bf client-name} by the actual name of the client that is
290 being backed up. Thus, Bacula automatically maintains one file for each of my
291 clients. The necessary bootstrap information is appended to this file during
292 each {\bf Incremental} backup, and the file is totally rewritten during each
293 {\bf Full} backup. 
294
295 Note, one major disadvantage of writing to an NFS mounted volume as I do is
296 that if the other machine goes down, the OS will wait forever on the fopen()
297 call that Bacula makes. As a consequence, Bacula will completely stall until
298 the machine exporting the NSF mounts comes back up. The solution to this
299 problem was provided by Andrew Hilborne, and consists of using the {\bf soft}
300 option instead of the {\bf hard} option when mounting the NFS volume, which is
301 typically done in {\bf /etc/fstab}/. The NFS documentation explains these
302 options in detail. 
303
304 If you are starting off in the middle of a cycle (i.e. with Incremental
305 backups) rather than at the beginning (with a Full backup), the {\bf
306 bootstrap} file will not be immediately valid as it must always have the
307 information from a Full backup as the first record. If you wish to synchronize
308 your bootstrap file immediately, you can do so by running a {\bf restore}
309 command for the client and selecting a full restore, but when the restore
310 command asks for confirmation to run the restore Job, you simply reply no,
311 then copy the bootstrap file that was written to the location specified on the
312 {\bf Write Bootstrap} record. The restore bootstrap file can be found in {\bf
313 restore.bsr} in the working directory that you defined. In the example given
314 below for the client {\bf rufus}, my input is shown in bold. Note, the JobId
315 output has been partially truncated to fit on the page here: 
316
317 \footnotesize
318 \begin{verbatim}
319 (in the Console program)
320 *{\bf restore}
321 First you select one or more JobIds that contain files
322 to be restored. You will then be presented several methods
323 of specifying the JobIds. Then you will be allowed to
324 select which files from those JobIds are to be restored.
325 To select the JobIds, you have the following choices:
326      1: List last 20 Jobs run
327      2: List Jobs where a given File is saved
328      3: Enter list of JobIds to select
329      4: Enter SQL list command
330      5: Select the most recent backup for a client
331      6: Cancel
332 Select item:  (1-6): {\bf 5}
333 The defined Client resources are:
334      1: Minimatou
335      2: Rufus
336      3: Timmy
337 Select Client (File daemon) resource (1-3): {\bf 2}
338 The defined FileSet resources are:
339      1: Kerns Files
340 Item 1 selected automatically.
341 +-------+------+-------+---------+---------+------+-------+------------+
342 | JobId | Levl | Files | StrtTim | VolName | File | SesId | VolSesTime |
343 +-------+------+-------+---------+---------+------+-------+------------+
344 | 2     | F    | 84    |  ...    | test1   | 0    | 1     | 1035645259 |
345 +-------+------+-------+---------+---------+------+-------+------------+
346 You have selected the following JobId: 2
347 Building directory tree for JobId 2 ...
348 The defined Storage resources are:
349      1: File
350 Item 1 selected automatically.
351 You are now entering file selection mode where you add and
352 remove files to be restored. All files are initially added.
353 Enter "done" to leave this mode.
354 cwd is: /
355 $ {\bf done}
356 84 files selected to restore.
357 Run Restore job
358 JobName:    kernsrestore
359 Bootstrap:  /home/kern/bacula/working/restore.bsr
360 Where:      /tmp/bacula-restores
361 FileSet:    Kerns Files
362 Client:     Rufus
363 Storage:    File
364 JobId:      *None*
365 OK to run? (yes/mod/no): {\bf no}
366 {\bf quit}
367 (in a shell window)
368 {\bf cp ../working/restore.bsr /mnt/deuter/files/backup/rufus.bsr}
369 \end{verbatim}
370 \normalsize
371
372 \subsection*{Rejected Volumes After a Crash}
373 \label{RejectedVolumes}
374 \index[general]{Crash!Rejected Volumes After a }
375 \index[general]{Rejected Volumes After a Crash }
376 \addcontentsline{toc}{subsection}{Rejected Volumes After a Crash}
377
378 Bacula keeps a count of the number of files on each Volume in its Catalog
379 database so that before appending to a tape, it can verify that the number of
380 files are correct, and thus prevent overwriting valid data. If the Director or
381 the Storage daemon crashes before the job has completed, the tape will contain
382 one more file than is noted in the Catalog, and the next time you attempt to
383 use the same Volume, Bacula will reject it due to a mismatch between the
384 physical tape (Volume) and the catalog. 
385
386 The easiest solution to this problem is to label a new tape and start fresh.
387 If you wish to continue appending to the current tape, you can do so by using
388 the {\bf update} command in the console program to change the {\bf Volume
389 Files} entry in the catalog. A typical sequence of events would go like the
390 following: 
391
392 \footnotesize
393 \begin{verbatim}
394 - Bacula crashes
395 - You restart Bacula
396 \end{verbatim}
397 \normalsize
398
399 Bacula then prints: 
400
401 \footnotesize
402 \begin{verbatim}
403 17-Jan-2003 16:45 rufus-dir: Start Backup JobId 13,
404                   Job=kernsave.2003-01-17_16.45.46
405 17-Jan-2003 16:45 rufus-sd: Volume test01 previously written,
406                   moving to end of data.
407 17-Jan-2003 16:46 rufus-sd: kernsave.2003-01-17_16.45.46 Error:
408                   I cannot write on this volume because:
409                   The number of files mismatch! Volume=11 Catalog=10
410 17-Jan-2003 16:46 rufus-sd: Job kernsave.2003-01-17_16.45.46 waiting.
411                    Cannot find any appendable volumes.
412 Please use the "label"  command to create a new Volume for:
413     Storage:      SDT-10000
414     Media type:   DDS-4
415     Pool:         Default
416 \end{verbatim}
417 \normalsize
418
419 (note, lines wrapped for presentation)
420 The key here is the line that reads: 
421
422 \footnotesize
423 \begin{verbatim}
424   The number of files mismatch! Volume=11 Catalog=10
425 \end{verbatim}
426 \normalsize
427
428 It says that Bacula found eleven files on the volume, but that the catalog
429 says there should be ten. When you see this, you can be reasonably sure that
430 the SD was interrupted while writing before it had a chance to update the
431 catalog. As a consequence, you can just modify the catalog count to eleven,
432 and even if the catalog contains references to files saved in file 11,
433 everything will be OK and nothing will be lost. Note that if the SD had
434 written several file marks to the volume, the difference between the Volume
435 cound and the Catalog count could be larger than one, but this is unusual. 
436
437 If on the other hand the catalog is marked as having more files than Bacula
438 found on the tape, you need to consider the possible negative consequences of
439 modifying the catalog. Please see below for a more complete discussion of
440 this. 
441
442 Continuing with the example of {\bf Volume = 11 Catalog = 10}, to enable to
443 Bacula to append to the tape, you do the following: 
444
445 \footnotesize
446 \begin{verbatim}
447 {\bf update}
448 Update choice:
449      1: Volume parameters
450      2: Pool from resource
451      3: Slots from autochanger
452 Choose catalog item to update (1-3): {\bf 1}
453 Defined Pools:
454      1: Default
455      2: File
456 Select the Pool (1-2):
457 +-------+---------+--------+---------+-----------+------+----------+------+-----+
458 | MedId | VolName | MedTyp | VolStat | VolBytes  | Last | VolReten | Recy | Slt |
459 +-------+---------+--------+---------+-----------+------+----------+------+-----+
460 | 1     | test01  | DDS-4  | Error   | 352427156 | ...  | 31536000 | 1    | 0   |
461 +-------+---------+--------+---------+-----------+------+----------+------+-----+
462 Enter MediaId or Volume name: {\bf 1}
463 \end{verbatim}
464 \normalsize
465
466 (note table output truncated for presentation) First, you chose to update the
467 Volume parameters by entering a {\bf 1}. In the volume listing that follows,
468 notice how the VolStatus is {\bf Error}. We will correct that after changing
469 the Volume Files. Continuing, you respond 1, 
470
471 \footnotesize
472 \begin{verbatim}
473 Updating Volume "test01"
474 Parameters to modify:
475      1: Volume Status
476      2: Volume Retention Period
477      3: Volume Use Duration
478      4: Maximum Volume Jobs
479      5: Maximum Volume Files
480      6: Maximum Volume Bytes
481      7: Recycle Flag
482      8: Slot
483      9: Volume Files
484     10: Pool
485     11: Done
486 Select parameter to modify (1-11): {\bf 9}
487 Warning changing Volume Files can result
488 in loss of data on your Volume
489 Current Volume Files is: 10
490 Enter new number of Files for Volume: {\bf 11}
491 New Volume Files is: 11
492 Updating Volume "test01"
493 Parameters to modify:
494      1: Volume Status
495      2: Volume Retention Period
496      3: Volume Use Duration
497      4: Maximum Volume Jobs
498      5: Maximum Volume Files
499      6: Maximum Volume Bytes
500      7: Recycle Flag
501      8: Slot
502      9: Volume Files
503     10: Pool
504     11: Done
505 Select parameter to modify (1-10): {\bf 1}
506 \end{verbatim}
507 \normalsize
508
509 Here, you have selected {\bf 9} in order to update the Volume Files, then you
510 changed it from {\bf 10} to {\bf 11}, and you now answer {\bf 1} to change the
511 Volume Status. 
512
513 \footnotesize
514 \begin{verbatim}
515 Current Volume status is: Error
516 Possible Values are:
517      1: Append
518      2: Archive
519      3: Disabled
520      4: Full
521      5: Used
522      6: Read-Only
523 Choose new Volume Status (1-6): {\bf 1}
524 New Volume status is: Append
525 Updating Volume "test01"
526 Parameters to modify:
527      1: Volume Status
528      2: Volume Retention Period
529      3: Volume Use Duration
530      4: Maximum Volume Jobs
531      5: Maximum Volume Files
532      6: Maximum Volume Bytes
533      7: Recycle Flag
534      8: Slot
535      9: Volume Files
536     10: Pool
537     11: Done
538 Select parameter to modify (1-11): {\bf 11}
539 Selection done.
540 \end{verbatim}
541 \normalsize
542
543 At this point, you have changed the Volume Files from {\bf 10} to {\bf 11} to
544 account for the last file that was written but not updated in the database,
545 and you changed the Volume Status back to {\bf Append}. 
546
547 This was a lot of words to describe something quite simple. 
548
549 The {\bf Volume Files} option exists only in version 1.29 and later, and you
550 should be careful using it. Generally, if you set the value to that which
551 Bacula said is on the tape, you will be OK, especially if the value is one
552 more than what is in the catalog. 
553
554 Now lets consider the case: 
555
556 \footnotesize
557 \begin{verbatim}
558   The number of files mismatch! Volume=10 Catalog=12
559 \end{verbatim}
560 \normalsize
561
562 Here the Bacula found fewer files on the volume than what is marked in the
563 catalog. Now, in this case, you should hesitate lot before modifying the count
564 in the catalog, because if you force the catalog from 12 to 10, Bacula will
565 start writing after the file 10 on the tape, possibly overwriting valid data,
566 and if you ever try to restore any of the files that the catalog has marked as
567 saved on Files 11 and 12, all chaos will break out. In this case, you will
568 probably be better off using a new tape. In fact, you might want to see what
569 files the catalog claims are actually stored on that Volume, and back them up
570 to another tape and recycle this tape. 
571
572 \subsection*{Security Considerations}
573 \label{security}
574 \index[general]{Considerations!Security }
575 \index[general]{Security Considerations }
576 \addcontentsline{toc}{subsection}{Security Considerations}
577
578 Only the File daemon needs to run with root permission (so that it can access
579 all files). As a consequence, you may run your Director, Storage daemon, and
580 MySQL or PostgreSQL database server as non-root processes. Version 1.30 has
581 the {\bf -u} and the {\bf -g} options that allow you to specify a userid and
582 groupid on the command line to be used after Bacula starts. 
583
584 As of version 1.33, thanks to Dan Langille, it is easier to configure the
585 Bacula Director and Storage daemon to run as non-root. 
586
587 You should protect the Bacula port addresses (normally 9101, 9102, and 9103)
588 from outside access by a firewall or other means of protection to prevent
589 unauthorized use of your daemons. 
590
591 You should ensure that the configuration files are not world readable since
592 they contain passwords that allow access to the daemons. Anyone who can access
593 the Director using a console program can restore any file from a backup
594 Volume. 
595
596 You should protect your Catalog database. If you are using SQLite, make sure
597 that the working directory is readable only by root (or your Bacula userid),
598 and ensure that {\bf bacula.db} has permissions {\bf -rw-r\verb{--{r\verb{--{} (i.e. 640) or
599 more strict. If you are using MySQL or PostgreSQL, please note that the Bacula
600 setup procedure leaves the database open to anyone. At a minimum, you should
601 assign the user {\bf bacula} a userid and add it to your Director's
602 configuration file in the appropriate Catalog resource. 
603
604 \subsection*{Creating Holiday Schedules}
605 \label{holiday}
606 \index[general]{Schedules!Creating Holiday }
607 \index[general]{Creating Holiday Schedules }
608 \addcontentsline{toc}{subsection}{Creating Holiday Schedules}
609
610 If you normally change tapes every day or at least every Friday, but Thursday
611 is a holiday, you can use a trick proposed by Lutz Kittler to ensure that no
612 job runs on Thursday so that you can insert Friday's tape and be sure it will
613 be used on Friday. To do so, define a {\bf RunJobBefore} script that normally
614 returns zero, so that the Bacula job will normally continue. You can then
615 modify the script to return non-zero on any day when you do not want Bacula to
616 run the job. 
617
618 \subsection*{Automatic Labeling Using Your Autochanger}
619 \label{autolabel}
620 \index[general]{Automatic Labeling Using Your Autochanger }
621 \index[general]{Autochanger!Automatic Labeling Using Your }
622 \addcontentsline{toc}{subsection}{Automatic Labeling Using Your Autochanger}
623
624 If you have an autochanger but it does not support barcodes, using a ``trick''
625 you can make Bacula automatically label all the volumes in your autochanger's
626 magazine. 
627
628 First create a file containing one line for each slot in your autochanger that
629 has a tape to be labeled. The line will contain the slot number a colon (:)
630 then the Volume name you want to use. For example, create a file named {\bf
631 volume-list}, which contains: 
632
633 \footnotesize
634 \begin{verbatim}
635 1:Volume001
636 2:TestVolume02
637 5:LastVolume
638 \end{verbatim}
639 \normalsize
640
641 The records do not need to be in any order and you don't need to mention all
642 the slots. Normally, you will have a consistent set of Volume names and a
643 sequential set of numbers for each slot you want labeled. In the example
644 above, I've left out slots 3 and 4 just as an example. Now, modify your {\bf
645 mtx-changer} script and comment out all the lines in the {\bf list)} case by
646 putting a \# in column 1. Then add the following two lines: 
647
648 \footnotesize
649 \begin{verbatim}
650   cat <absolute-path>/volume-list
651   exit 0
652 \end{verbatim}
653 \normalsize
654
655 so that the whole case looks like: 
656
657 \footnotesize
658 \begin{verbatim}
659   list)
660 #
661 # commented out lines
662    cat <absolute-path>/volume-list
663    exit 0
664    ;;
665 \end{verbatim}
666 \normalsize
667
668 where you replace \lt{}absolute-path\gt{} with the full path to the
669 volume-list file. Then using the console, you enter the following command: 
670
671 \footnotesize
672 \begin{verbatim}
673    label barcodes
674 \end{verbatim}
675 \normalsize
676
677 and Bacula will proceed to mount the autochanger Volumes in the list and label
678 them with the Volume names you have supplied. Bacula will think that the list
679 was provided by the autochanger barcodes, but in reality, it was you who
680 supplied the \lt{}barcodes\gt{}. 
681
682 If it seems to work, when it finishes, enter: 
683
684 \footnotesize
685 \begin{verbatim}
686    list volumes
687 \end{verbatim}
688 \normalsize
689
690 and you should see all the volumes nicely created. 
691
692 \subsection*{Backing Up Portables Using DHCP}
693 \label{DNS}
694 \index[general]{DHCP!Backing Up Portables Using }
695 \index[general]{Backing Up Portables Using DHCP }
696 \addcontentsline{toc}{subsection}{Backing Up Portables Using DHCP}
697
698 You may want to backup laptops or portables that are not always connected to
699 the network. If you are using DHCP to assign an IP address to those machines
700 when they connect, you will need to use the Dynamic Update capability of DNS
701 to assign a name to those machines that can be used in the Address field of
702 the Client resource in the Director's conf file. 
703
704 \subsection*{Going on Vacation}
705 \label{Vacation}
706 \index[general]{Vacation!Going on }
707 \index[general]{Going on Vacation }
708 \addcontentsline{toc}{subsection}{Going on Vacation}
709
710 At some point, you may want to be absent for a week or two and you want to
711 make sure Bacula has enough tape left so that the backups will complete. You
712 start by doing a {\bf list volumes} in the Console program: 
713
714 \footnotesize
715 \begin{verbatim}
716 {\bf list volumes}
717  
718 Using default Catalog name=BackupDB DB=bacula
719 Pool: Default
720 +---------+---------------+-----------+-----------+----------------+-
721 | MediaId | VolumeName    | MediaType | VolStatus |       VolBytes |
722 +---------+---------------+-----------+-----------+----------------+-
723 |      23 | DLT-30Nov02   | DLT8000   | Full      | 54,739,278,128 |
724 |      24 | DLT-21Dec02   | DLT8000   | Full      | 56,331,524,629 |
725 |      25 | DLT-11Jan03   | DLT8000   | Full      | 67,863,514,895 |
726 |      26 | DLT-02Feb03   | DLT8000   | Full      | 63,439,314,216 |
727 |      27 | DLT-03Mar03   | DLT8000   | Full      | 66,022,754,598 |
728 |      28 | DLT-04Apr03   | DLT8000   | Full      | 60,792,559,924 |
729 |      29 | DLT-28Apr03   | DLT8000   | Full      | 62,072,494,063 |
730 |      30 | DLT-17May03   | DLT8000   | Full      | 65,901,767,839 |
731 |      31 | DLT-07Jun03   | DLT8000   | Used      | 56,558,490,015 |
732 |      32 | DLT-28Jun03   | DLT8000   | Full      | 64,274,871,265 |
733 |      33 | DLT-19Jul03   | DLT8000   | Full      | 64,648,749,480 |
734 |      34 | DLT-08Aug03   | DLT8000   | Full      | 64,293,941,255 |
735 |      35 | DLT-24Aug03   | DLT8000   | Append    |  9,999,216,782 |
736 +---------+---------------+-----------+-----------+----------------+
737 \end{verbatim}
738 \normalsize
739
740 Note, I have truncated the output for presentation purposes. What is
741 significant for is that I can see that my current tape has almost 10 Gbytes of
742 data, and that the average amount of data I get on my tapes is about 60
743 Gbytes. So if I go on vacation now, I don't need to worry about tape capacity
744 (at least not for short absences). 
745
746 Equally significant is the fact that I did go on vacation the 28th of June
747 2003, and when I did the {\bf list volumes} command, my current tape at that
748 time, DLT-07Jun03 MediaId 31, had 56.5 Gbytes written. I could see that the
749 tape would fill shortly. Consequently, I manually marked it as {\bf Used} and
750 replaced it with a fresh tape that I labeled as DLT-28Jun03, thus assuring
751 myself that the backups would all complete without my intervention. 
752
753 \subsection*{How to Excude File on Windows Regardless of Case}
754 \label{Case}
755 \index[general]{How to Excude File on Windows Regardless of Case }
756 \index[general]{Case!How to Excude File on Windows Regardless of }
757 \addcontentsline{toc}{subsection}{How to Excude File on Windows Regardless of
758 Case}
759
760 This tip was submitted by Marc Brueckner who wasn't sure of the case of some
761 of his files on Win32, which is case insensitive. The problem is that Bacula
762 thinks that {\bf /UNIMPORTANT FILES} is different from {\bf /Unimportant
763 Files}. Marc was aware that the file exclusion permits wild-cards. So, he
764 specified: 
765
766 \footnotesize
767 \begin{verbatim}
768 "/[Uu][Nn][Ii][Mm][Pp][Oo][Rr][Tt][Aa][Nn][Tt] [Ff][Ii][Ll][Ee][Ss]"
769 \end{verbatim}
770 \normalsize
771
772 As a consequence, the above exclude works for files of any case. 
773
774 Please note that this works only in Bacula Exclude statement and not in
775 Include. 
776
777 \subsection*{Executing Scripts on a Remote Machine}
778 \label{RemoteExecution}
779 \index[general]{Machine!Executing Scripts on a Remote }
780 \index[general]{Executing Scripts on a Remote Machine }
781 \addcontentsline{toc}{subsection}{Executing Scripts on a Remote Machine}
782
783 This tip also comes from Marc Brueckner. (Note, this tip is probably outdated
784 by the addition of {\bf ClientRunBeforJob} and {\bf ClientRunAfterJob} Job
785 records, but the technique still could be useful.) First I thought the ``Run
786 Before Job'' statement in the Job-resource is for executing a script on the
787 remote machine(the machine to be backed up). It could be usefull to execute
788 scripts on the remote machine e.g. for stopping databases or other services
789 while doing the backup. (Of cause I have to start the services again when the
790 backup has finished) I found the following solution: Bacula could execute
791 scrips on the remote machine by using ssh. The authentication is done
792 automatically using a private key. First You have to generate a keypair. I ve
793 done this by: 
794
795 \footnotesize
796 \begin{verbatim}
797 ssh-keygen -b 4096 -t dsa -f Bacula_key
798 \end{verbatim}
799 \normalsize
800
801 This statement may take a little time to run. It creates a public/private key
802 pair with no pass phrase. You could save the keys in /etc/bacula. Now you have
803 two new files : Bacula\_key which contains the private key and Bacula\_key.pub
804 which contains the public key. 
805
806 Now you have to append the Bacula\_key.pub file to the file authorized\_keys
807 in the \textbackslash{}root\textbackslash{}.ssh directory of the remote
808 machine. Then you have to add (or uncomment) the line 
809
810 \footnotesize
811 \begin{verbatim}
812 AuthorizedKeysFile           %h/.ssh/authorized_keys
813 \end{verbatim}
814 \normalsize
815
816 to the sshd\_config file on the remote machine. Where the \%h stands for the
817 home-directory of the user (root in this case). 
818
819 Assuming that your sshd is already running on the remote machine, you can now
820 enter the folloing on the machine where Bacula runs: 
821
822 \footnotesize
823 \begin{verbatim}
824 ssh -i Bacula_key  -l root "ls -la"
825 \end{verbatim}
826 \normalsize
827
828 This should execute the ``ls -la'' command on the remote machine. 
829
830 Now you could add lines like the following to your Director's conf file: 
831
832 \footnotesize
833 \begin{verbatim}
834 ...
835 Run Before Job = ssh -i /etc/bacula/Bacula_key 192.168.1.1 \
836                  "/etc/init.d/database stop"
837 Run After Job = ssh -i /etc/bacula/Bacula_key 192.168.1.1 \
838                  "/etc/init.d/database start"
839 ...
840 \end{verbatim}
841 \normalsize
842
843 Even though Bacula version 1.32 has a ClientRunBeforeJob, the ssh method still
844 could be useful for updating all the Bacula clients on several remote machines
845 in a single script. 
846
847 \subsection*{Recycling All Your Volumes}
848 \label{recycle}
849 \index[general]{Recycling All Your Volumes }
850 \index[general]{Volumes!Recycling All Your }
851 \addcontentsline{toc}{subsection}{Recycling All Your Volumes}
852
853 This tip comes from Phil Stracchino. 
854
855 If you decide to blow away your catalog and start over, the simplest way to
856 re-add all your prelabelled tapes with the minimum of fuss (provided you don't
857 care about the data on the tapes) is to add the tape labels using the console
858 {\bf add} command, then go into the catalog and manually set the VolStatus of
859 every tape to {\bf Recycle}. 
860
861 The SQL command to do this is very simple: 
862
863 \footnotesize
864 \begin{verbatim}
865 update Media set VolStatus = "Recycle";
866 \end{verbatim}
867 \normalsize
868
869 Bacula will then ignore the data already stored on the tapes and just re-use
870 each tape without further objection. 
871
872 \subsection*{Backing up ACLs on ext3 or XFS filesystems}
873 \label{ACLs}
874 \index[general]{Filesystems!Backing up ACLs on ext3 or XFS }
875 \index[general]{Backing up ACLs on ext3 or XFS filesystems }
876 \addcontentsline{toc}{subsection}{Backing up ACLs on ext3 or XFS filesystems}
877
878 This tip comes from Volker Sauer. 
879
880 Note, this tip was given prior to implementation of ACLs in Bacula (version
881 1.34.5). It is left here because dumping/displaying ACLs can still be useful
882 in testing/verifying that Bacula is backing up and restoring your ACLs
883 properly. Please see the 
884 \ilink{aclsupport}{ACLSupport} FileSet option in the
885 configuration chapter of this manual. 
886
887 For example, you could dump the ACLs to a file with a script similar to the
888 following: 
889
890 \footnotesize
891 \begin{verbatim}
892 #!/bin/sh
893 BACKUP_DIRS="/foo /bar"
894 STORE_ACL=/root/acl-backup
895 umask 077
896 for i in $BACKUP_DIRS; do
897  cd $i /usr/bin/getfacl -R --skip-base .>$STORE_ACL/${i//\//_}
898 done
899 \end{verbatim}
900 \normalsize
901
902 Then use Bacula to backup {\bf /root/acl-backup}. 
903
904 The ACLs could be restored using Bacula to the {\bf /root/acl-backup} file,
905 then restored to your system using: 
906
907 \footnotesize
908 \begin{verbatim}
909 setfacl --restore/root/acl-backup
910 \end{verbatim}
911 \normalsize
912
913 \subsection*{Total Automation of Bacula Tape Handling}
914 \label{automate}
915 \index[general]{Handling!Total Automation of Bacula Tape }
916 \index[general]{Total Automation of Bacula Tape Handling }
917 \addcontentsline{toc}{subsection}{Total Automation of Bacula Tape Handling}
918
919 This tip was provided by Alexander Kuehn. 
920
921 \elink{Bacula}{http://www.bacula.org/} is a really nice backup program except
922 that the manual tape changing requires user interaction with the bacula
923 console. 
924
925 Fortunately I can fix this.
926 NOTE!!! This suggestion applies for people who do *NOT* have tape autochangers
927 and must change tapes manually.!!!!! 
928
929 Bacula supports a variety of tape changers through the use of mtx-changer
930 scripts/programs. This highly flexible approach allowed me to create 
931 \ilink{this shell script}{mtx-changer.txt} which does the following:
932 Whenever a new tape is required it sends a mail to the operator to insert the
933 new tape. Then it waits until a tape has been inserted, sends a mail again to
934 say thank you and let's bacula continue it's backup.
935 So you can schedule and run backups without ever having to log on or see the
936 console.
937 To make the whole thing work you need to create a Device resource which looks
938 something like this (``Archive Device'', ``Maximum Changer Wait'', ``Media
939 Type'' and ``Label media'' may have different values): 
940
941 \footnotesize
942 \begin{verbatim}
943 Device {
944    Name=DDS3
945    Archive Device = # use yours not mine! ;)/dev/nsa0
946    Changer Device = # not really required/dev/nsa0
947    Changer Command = "# use this (maybe change the path)!
948          /usr/local/bin/mtx-changer %o %a %S"
949    Maximum Changer Wait = 3d          # 3 days in seconds
950    AutomaticMount = yes;              # mount on start
951    AlwaysOpen = yes;                  # keep device locked
952    Media Type = DDS3                  # it's just a name
953    RemovableMedia = yes;              #
954    Offline On Unmount = Yes;          # keep this too
955    Label media = Yes;                 #
956 }
957 \end{verbatim}
958 \normalsize
959
960 As the script has to emulate the complete wisdom of a mtx-changer it has an
961 internal ``database'' where which tape is stored, you can see this at that
962 line:
963
964 \footnotesize
965 \begin{verbatim}
966 labels="VOL-0001 VOL-0002 VOL-0003 VOL-0004 VOL-0005 VOL-0006
967 VOL-0007 VOL-0008 VOL-0009 VOL-0010 VOL-0011 VOL-0012"
968 \end{verbatim}
969 \normalsize
970
971 The above should be all on one line, and it effectivly tells Bacula that
972 volume ``VOL-0001'' is located in slot 1 (which is our lowest slot), that
973 volume ``VOL-0002'' is located in slot 2 and so on..
974 The script also maintains a logfile (/var/log/mtx.log) where you can monitor
975 its operation.
976
977 \subsection*{Running Concurrent Jobs}
978 \label{ConcurrentJobs}
979 \index[general]{Jobs!Running Concurrent }
980 \index[general]{Running Concurrent Jobs }
981 \addcontentsline{toc}{subsection}{Running Concurrent Jobs}
982
983 Bacula can run multiple concurrent jobs, but the default configuration files
984 are not set to do so. Using the {\bf Maximum Concurrent Jobs} directive, you
985 have a lot of control over how many jobs can run at the same time, and which
986 jobs can run simultaneously. The downside is that it can be a bit tricky to
987 set it up for the first time as you need to set the concurrency in at least
988 five different places. 
989
990 The Director, the File daemon, and the Storage daemon each have a {\bf Maximum
991 Concurrent Jobs} directive that determines overall number of concurrent jobs
992 the daemon will run. The default is one for the Director and ten for both the
993 File daemon and the Storage daemon, so assuming you will not be running more
994 than ten concurrent jobs, the only changes that are needed are in the
995 Director's conf file (bacula-dir.conf). 
996
997 Within the Director's configuration file, {\bf Maximum Concurrent Jobs} can be
998 set in the Direct, Job, Client, and Storage resources. Each one must be set
999 properly, according to your needs, otherwise your jobs may be run one at a
1000 time. 
1001
1002 For example, if you want two different jobs to run simultaneously backing up
1003 the same Client to the same Storage device, they will run concurrentl only if
1004 you have set {\bf Maximum Concurrent Jobs} greater than one in the Director
1005 resource, the Client resource, and the Storage resource in bacula-dir.conf. 
1006
1007 We recommend that you carefully test your multiple concurrent backup including
1008 doing thorough restore testing before you put it into production. 
1009
1010 Below is a super stripped down bacula-dir.conf file showing you the four
1011 places where the the file has been modified to allow the same job {\bf
1012 NightlySave} to run up to four times concurrently. The change to the Job
1013 resource is not necessary if you want different Jobs to run at the same time,
1014 which is the normal case. 
1015
1016 \footnotesize
1017 \begin{verbatim}
1018 #
1019 # Bacula Director Configuration file -- bacula-dir.conf
1020 #
1021 Director {
1022   Name = rufus-dir
1023   Maximum Concurrent Jobs = 4
1024   ...
1025 }
1026 Job {
1027   Name = "NightlySave"
1028   Maximum Concurrent Jobs = 4
1029   Client = rufus-fd
1030   Storage = File
1031   ...
1032 }
1033 Client {
1034   Name = rufus-fd
1035   Maximum Concurrent Jobs = 4
1036   ...
1037 }
1038 Storage {
1039   Name = File
1040   Maximum Concurrent Jobs = 4
1041   ...
1042 }
1043 \end{verbatim}
1044 \normalsize