]> git.sur5r.net Git - bacula/docs/blob - docs/manual/tutorial.tex
b449e7a03806e216b862ebbab99fa5ebffa1f339
[bacula/docs] / docs / manual / tutorial.tex
1 %%
2 %%
3
4 \section*{A Brief Tutorial}
5 \label{_ChapterStart1}
6 \index[general]{Brief Tutorial }
7 \index[general]{Tutorial!Brief }
8 \addcontentsline{toc}{section}{Brief Tutorial}
9
10 This chapter will guide you through running Bacula. To do so, we assume you
11 have installed Bacula, possibly in a single file as shown in the previous
12 chapter, in which case, you can run Bacula as non-root for these tests.
13 However, we assume that you have not changed the .conf files. If you have
14 modified the .conf files, please go back and uninstall Bacula, then reinstall
15 it, but do not make any changes. The examples in this chapter use the default
16 configuration files, and will write the volumes to disk in your {\bf /tmp}
17 directory, in addition, the data backed up will be the source directory where
18 you built Bacula. As a consequence, you can run all the Bacula daemons for
19 these tests as non-root. Please note, in production, your File daemon(s) must
20 run as root. See the Security chapter for more information on this subject. 
21
22 The general flow of running Bacula is: 
23
24 \begin{enumerate}
25 \item cd \lt{}install-directory\gt{}  
26 \item Start the Database (if using MySQL or PostgreSQL)  
27 \item Start the Daemons with {\bf ./bacula start}  
28 \item Start the Console program to interact with the Director  
29 \item Run a job  
30 \item When the Volume fills, unmount the Volume, if it is a  tape, label a new
31    one, and continue running. In this  chapter, we will write only to disk files
32    so you won't  need to worry about tapes for the moment. 
33 \item Test recovering some files from the Volume just written to  ensure the
34    backup is good and that you know how to recover.  Better test before disaster
35    strikes  
36 \item Add a second client. 
37    \end{enumerate}
38
39 Each of these steps is described in more detail below. 
40
41 \subsection*{Before Running Bacula}
42 \index[general]{Bacula!Before Running }
43 \index[general]{Before Running Bacula }
44 \addcontentsline{toc}{subsection}{Before Running Bacula}
45
46 Before running Bacula for the first time in production, we recommend that you
47 run the {\bf test} command in the {\bf btape} program as described in the 
48 \ilink{Utility Program Chapter}{btape} of this manual. This will
49 help ensure that Bacula functions correctly with your tape drive. If you have
50 a modern HP, Sony, or Quantum DDS or DLT tape drive running on Linux or
51 Solaris, you can probably skip this test as Bacula is well tested with these
52 drives and systems. For all other cases, you are {\bf strongly} encouraged to
53 run the test before continuing. {\bf btape} also has a {\bf fill} command that
54 attempts to duplicate what Bacula does when filling a tape and writing on the
55 next tape. You should consider trying this command as well, but be forewarned,
56 it can take hours (about 4 hours on my drive) to fill a large capacity tape. 
57
58 \subsection*{Starting the Database}
59 \label{StartDB}
60 \index[general]{Starting the Database }
61 \index[general]{Database!Starting the }
62 \addcontentsline{toc}{subsection}{Starting the Database}
63
64 If you are using MySQL or PostgreSQL as the Bacula database, you should start
65 it before you attempt to run a job to avoid getting error messages from Bacula
66 when it starts. The scripts {\bf startmysql} and {\bf stopmysql} are what I
67 (Kern) use to start and stop my local MySQL. Note, if you are using SQLite,
68 you will not want to use {\bf startmysql} or {\bf stopmysql}. If you are
69 running this in production, you will probably want to find some way to
70 automatically start MySQL or PostgreSQL after each system reboot. 
71
72 If you are using SQLite (i.e. you specified the {\bf \verb:--:with-sqlite=xxx} option
73 on the {\bf ./configure} command, you need do nothing. SQLite is automatically
74 started by {\bf Bacula}. 
75
76 \subsection*{Starting the Daemons}
77 \label{StartDaemon}
78 \index[general]{Starting the Daemons }
79 \index[general]{Daemons!Starting the }
80 \addcontentsline{toc}{subsection}{Starting the Daemons}
81
82 To start the three daemons, from your installation directory, simply enter: 
83
84 ./bacula start This script starts the Storage daemon, the File daemon, and the
85 Director daemon, which all normally run as daemons in the background. If you
86 are using the autostart feature of Bacula, your daemons will either be
87 automatically started on reboot, or you can control them individually with the
88 files {\bf bacula-dir}, {\bf bacula-fd}, and {\bf bacula-sd}, which are
89 usually located in {\bf /etc/init.d}, though the actual location is system
90 dependent. 
91
92 Note, on Windows, currently only the File daemon is ported, and it must be
93 started differently. Please see the 
94 \ilink{Windows Version of Bacula}{_ChapterStart7} Chapter of this
95 manual. 
96
97 The rpm packages configure the daemons to run as user=root and group=bacula.
98 The rpm installation also creates the group bacula if it does not exist on the
99 system. Any users that you add to the group bacula will have access to files
100 created by the daemons. To disable or alter this behavior edit the daemon
101 startup scripts: 
102
103 \begin{itemize}
104 \item /etc/bacula/bacula 
105 \item /etc/init.d/bacula-dir 
106 \item /etc/init.d/bacula-sd 
107 \item /etc/init.d/bacula-fd 
108    \end{itemize}
109
110 and then restart as noted above. 
111
112 The 
113 \ilink{installation chapter}{_ChapterStart17} of this manual
114 explains how you can install scripts that will automatically restart the
115 daemons when the system starts. 
116
117 \subsection*{Interacting with the Director to Query or Start Jobs}
118 \index[general]{Jobs!Interacting with the Director to Query or Start }
119 \index[general]{Interacting with the Director to Query or Start Jobs }
120 \addcontentsline{toc}{subsection}{Interacting with the Director to Query or
121 Start Jobs}
122
123 To communicate with the director and to query the state of Bacula or run jobs,
124 from the top level directory, simply enter: 
125
126 ./bconsole 
127
128 Note, on 1.32 versions and lower, the command name is {\bf console} rather
129 than bconsole. Alternatively to running the command line console, if you have
130 GNOME installed and used the {\bf \verb:--:enable-gnome} on the configure command,
131 you may use the GNOME Console program: 
132
133 ./gnome-console 
134
135 For simplicity, here we will describe only the {\bf ./console} program. Most
136 of what is described here applies equally well to {\bf ./gnome-console}. 
137
138 The {\bf ./bconsole} runs the Bacula Console program, which connects to the
139 Director daemon. Since Bacula is a network program, you can run the Console
140 program anywhere on your network. Most frequently, however, one runs it on the
141 same machine as the Director. Normally, the Console program will print
142 something similar to the following: 
143
144 \footnotesize
145 \begin{verbatim}
146 [kern@polymatou bin]$ ./bconsole
147 Connecting to Director lpmatou:9101
148 1000 OK: HeadMan Version: 1.30 (28 April 2003)
149 *
150 \end{verbatim}
151 \normalsize
152
153 the asterisk is the console command prompt. 
154
155 Type {\bf help} to see a list of available commands: 
156
157 \footnotesize
158 \begin{verbatim}
159 *help
160   Command    Description
161   =======    ===========
162   add        add media to a pool
163   autodisplay autodisplay [on/off] -- console messages
164   automount  automount [on/off] -- after label
165   cancel     cancel job=nnn -- cancel a job
166   create     create DB Pool from resource
167   delete     delete [pool=<pool-name> | media volume=<volume-name>]
168   estimate   performs FileSet estimate debug=1 give full listing
169   exit       exit = quit
170   help       print this command
171   label      label a tape
172   list       list [pools | jobs | jobtotals | media <pool> |
173              files jobid=<nn>]; from catalog
174   llist      full or long list like list command
175   messages   messages
176   mount      mount <storage-name>
177   prune      prune expired records from catalog
178   purge      purge records from catalog
179   query      query catalog
180   quit       quit
181   relabel    relabel a tape
182   release    release <storage-name>
183   restore    restore files
184   run        run <job-name>
185   setdebug   sets debug level
186   show       show (resource records) [jobs | pools | ... | all]
187   sqlquery   use SQL to query catalog
188   status     status [storage | client]=<name>
189   time       print current time
190   unmount    unmount <storage-name>
191   update     update Volume or Pool
192   use        use catalog xxx
193   var        does variable expansion
194   version    print Director version
195   wait       wait until no jobs are running
196 *
197 \end{verbatim}
198 \normalsize
199
200 Details of the console program's commands are explained in the 
201 \ilink{Console Chapter}{_ConsoleChapter} of this manual. 
202
203 \subsection*{Running a Job}
204 \label{Running}
205 \index[general]{Job!Running a }
206 \index[general]{Running a Job }
207 \addcontentsline{toc}{subsection}{Running a Job}
208
209 At this point, we assume you have done the following: 
210
211 \begin{itemize}
212 \item Configured Bacula with {\bf ./configure \verb:--:your-options} 
213 \item Built Bacula using {\bf make} 
214 \item Installed Bacula using {\bf make install} 
215 \item Have created your database with, for example,  {\bf
216    ./create\_sqlite\_database} 
217 \item Have created the Bacula database tables with,  {\bf
218    ./make\_bacula\_tables} 
219 \item Have possibly edited your {\bf bacula-dir.conf} file  to personalize it
220    a bit. BE CAREFUL! if you change the  Director's name or password, you will
221    need to make similar  modifications in the other .conf files. For the moment
222 it is  probably better to make no changes.  
223 \item You have started Bacula with {\bf ./bacula start}  
224 \item You have invoked the Console program with {\bf ./bconsole} 
225    \end{itemize}
226
227 Furthermore, we assume for the moment you are using the default configuration
228 files. 
229
230 At this point, enter the following command: 
231
232 \footnotesize
233 \begin{verbatim}
234 show filesets
235 \end{verbatim}
236 \normalsize
237
238 and you should get something similar to: 
239
240 \footnotesize
241 \begin{verbatim}
242 FileSet: name=Full Set
243       Inc: /home/kern/bacula/bacula-1.30
244       Exc: /proc
245       Exc: /tmp
246       Exc: /.journal
247       Exc: /.fsck
248 FileSet: name=Catalog
249       Inc: /home/kern/bacula/testbin/working/bacula.sql
250 \end{verbatim}
251 \normalsize
252
253 This is a pre-defined {\bf FileSet} that will backup the Bacula source
254 directory. The actual directory names printed should correspond to your system
255 configuration. For testing purposes, we have chosen a directory of moderate
256 size (about 40 Megabytes) and complexity without being too big. The FileSet
257 {\bf Catalog} is used for backing up Bacula's catalog and is not of interest
258 to us for the moment. The {\bf Inc:} entries are the files or directories that
259 will be included in the backup and the {\bf Exc:} are those that will be
260 excluded. 
261
262 Now is the time to run your first backup job. We are going to backup your
263 Bacula source directory to a File Volume in your {\bf /tmp} directory just to
264 show you how easy it is. Now enter: 
265
266 \footnotesize
267 \begin{verbatim}
268 status dir
269 \end{verbatim}
270 \normalsize
271
272 and you should get the following output: 
273
274 \footnotesize
275 \begin{verbatim}
276 rufus-dir Version: 1.30 (28 April 2003)
277 Daemon started 28-Apr-2003 14:03, 0 Jobs run.
278 Console connected at 28-Apr-2003 14:03
279 No jobs are running.
280 Level          Type     Scheduled          Name
281 =================================================================
282 Incremental    Backup   29-Apr-2003 01:05  Client1
283 Full           Backup   29-Apr-2003 01:10  BackupCatalog
284 ====
285 \end{verbatim}
286 \normalsize
287
288 where the times and the Director's name will be different according to your
289 setup. This shows that an Incremental job is scheduled to run for the Job {\bf
290 Client1} at 1:05am and that at 1:10, a {\bf BackupCatalog} is scheduled to
291 run. Note, you should probably change the name {\bf Client1} to be the name of
292 your machine, if not, when you add additional clients, it will be very
293 confusing. For my real machine, I use {\bf Rufus} rather than {\bf Client1} as
294 in this example. 
295
296 Now enter: 
297
298 \footnotesize
299 \begin{verbatim}
300 status client
301 \end{verbatim}
302 \normalsize
303
304 and you should get something like: 
305
306 \footnotesize
307 \begin{verbatim}
308 The defined Client resources are:
309      1: rufus-fd
310 Item 1 selected automatically.
311 Connecting to Client rufus-fd at rufus:8102
312 rufus-fd Version: 1.30 (28 April 2003)
313 Daemon started 28-Apr-2003 14:03, 0 Jobs run.
314 Director connected at: 28-Apr-2003 14:14
315 No jobs running.
316 ====
317 \end{verbatim}
318 \normalsize
319
320 In this case, the client is named {\bf rufus-fd} your name will be different,
321 but the line beginning with {\bf rufus-fd Version ...} is printed by your File
322 daemon, so we are now sure it is up and running. 
323
324 Finally do the same for your Storage daemon with: 
325
326 \footnotesize
327 \begin{verbatim}
328 status storage
329 \end{verbatim}
330 \normalsize
331
332 and you should get: 
333
334 \footnotesize
335 \begin{verbatim}
336 The defined Storage resources are:
337      1: File
338 Item 1 selected automatically.
339 Connecting to Storage daemon File at rufus:8103
340 rufus-sd Version: 1.30 (28 April 2003)
341 Daemon started 28-Apr-2003 14:03, 0 Jobs run.
342 Device /tmp is not open.
343 No jobs running.
344 ====
345 \end{verbatim}
346 \normalsize
347
348 You will notice that the default Storage daemon device is named {\bf File} and
349 that it will use device {\bf /tmp}, which is not currently open. 
350
351 Now, let's actually run a job with: 
352
353 \footnotesize
354 \begin{verbatim}
355 run
356 \end{verbatim}
357 \normalsize
358
359 you should get the following output: 
360
361 \footnotesize
362 \begin{verbatim}
363 Using default Catalog name=MyCatalog DB=bacula
364 A job name must be specified.
365 The defined Job resources are:
366      1: Client1
367      2: BackupCatalog
368      3: RestoreFiles
369 Select Job resource (1-3):
370 \end{verbatim}
371 \normalsize
372
373 Here, Bacula has listed the three different Jobs that you can run, and you
374 should choose number {\bf 1} and type enter, at which point you will get: 
375
376 \footnotesize
377 \begin{verbatim}
378 Run Backup job
379 JobName:  Client1
380 FileSet:  Full Set
381 Level:    Incremental
382 Client:   rufus-fd
383 Storage:  File
384 Pool:     Default
385 When:     2003-04-28 14:18:57
386 OK to run? (yes/mod/no):
387 \end{verbatim}
388 \normalsize
389
390 At this point, take some time to look carefully at what is printed and
391 understand it. It is asking you if it is OK to run a job named {\bf Client1}
392 with FileSet {\bf Full Set} (we listed above) as an Incremental job on your
393 Client (your client name will be different), and to use Storage {\bf File} and
394 Pool {\bf Default}, and finally, it wants to run it now (the current time
395 should be displayed by your console). 
396
397 Here we have the choice to run ({\bf yes}), to modify one or more of the above
398 parameters ({\bf mod}), or to not run the job ({\bf no}). Please enter {\bf
399 yes}, at which point you should immediately get the command prompt (an
400 asterisk). If you wait a few seconds, then enter the command {\bf messages}
401 you will get back something like: 
402
403 \footnotesize
404 \begin{verbatim}
405 28-Apr-2003 14:22 rufus-dir: Last FULL backup time not found. Doing
406                   FULL backup.
407 28-Apr-2003 14:22 rufus-dir: Start Backup JobId 1,
408                   Job=Client1.2003-04-28_14.22.33
409 28-Apr-2003 14:22 rufus-sd: Job Client1.2003-04-28_14.22.33 waiting.
410                   Cannot find any appendable volumes.
411 Please use the "label"  command to create a new Volume for:
412     Storage:      FileStorage
413     Media type:   File
414     Pool:         Default
415 \end{verbatim}
416 \normalsize
417
418 The first message, indicates that no previous Full backup was done, so Bacula
419 is upgrading our Incremental job to a Full backup (this is normal). The second
420 message indicates that the job started with JobId 1., and the third message
421 tells us that Bacula cannot find any Volumes in the Pool for writing the
422 output. This is normal because we have not yet created (labeled) any Volumes.
423 Bacula indicates to you all the details of the volume it needs. 
424
425 At this point, the job is blocked waiting for a Volume. You can check this if
426 you want by doing a {\bf status dir}. In order to continue, we must create a
427 Volume that Bacula can write on. We do so with: 
428
429 \footnotesize
430 \begin{verbatim}
431 label
432 \end{verbatim}
433 \normalsize
434
435 and Bacula will print: 
436
437 \footnotesize
438 \begin{verbatim}
439 The defined Storage resources are:
440      1: File
441 Item 1 selected automatically.
442 Enter new Volume name:
443 \end{verbatim}
444 \normalsize
445
446 at which point, you should enter some name beginning with a letter and
447 containing only letters and numbers (period, hyphen, and underscore) are also
448 permitted. For example, enter {\bf TestVolume001}, and you should get back: 
449
450 \footnotesize
451 \begin{verbatim}
452 Defined Pools:
453      1: Default
454 Item 1 selected automatically.
455 Connecting to Storage daemon File at rufus:8103 ...
456 Sending label command for Volume "TestVolume001" Slot 0 ...
457 3000 OK label. Volume=TestVolume001 Device=/tmp
458 Catalog record for Volume "TestVolume002", Slot 0  successfully created.
459 Requesting mount FileStorage ...
460 3001 OK mount. Device=/tmp
461 \end{verbatim}
462 \normalsize
463
464 Finally, enter {\bf messages} and you should get something like: 
465
466 \footnotesize
467 \begin{verbatim}
468 28-Apr-2003 14:30 rufus-sd: Wrote label to prelabeled Volume
469    "TestVolume001" on device /tmp
470 28-Apr-2003 14:30 rufus-dir: Bacula 1.30 (28Apr03): 28-Apr-2003 14:30
471 JobId:                  1
472 Job:                    Client1.2003-04-28_14.22.33
473 FileSet:                Full Set
474 Backup Level:           Full
475 Client:                 rufus-fd
476 Start time:             28-Apr-2003 14:22
477 End time:               28-Apr-2003 14:30
478 Files Written:          1,444
479 Bytes Written:          38,988,877
480 Rate:                   81.2 KB/s
481 Software Compression:   None
482 Volume names(s):        TestVolume001
483 Volume Session Id:      1
484 Volume Session Time:    1051531381
485 Last Volume Bytes:      39,072,359
486 FD termination status:  OK
487 SD termination status:  OK
488 Termination:            Backup OK
489 28-Apr-2003 14:30 rufus-dir: Begin pruning Jobs.
490 28-Apr-2003 14:30 rufus-dir: No Jobs found to prune.
491 28-Apr-2003 14:30 rufus-dir: Begin pruning Files.
492 28-Apr-2003 14:30 rufus-dir: No Files found to prune.
493 28-Apr-2003 14:30 rufus-dir: End auto prune.
494 \end{verbatim}
495 \normalsize
496
497 If you don't see the output immediately, you can keep entering {\bf messages}
498 until the job terminates, or you can enter, {\bf autodisplay on} and your
499 messages will automatically be displayed as soon as they are ready. 
500
501 If you do an {\bf ls -l} of your {\bf /tmp} directory, you will see that you
502 have the following item: 
503
504 \footnotesize
505 \begin{verbatim}
506 -rw-r-----    1 kern     kern     39072153 Apr 28 14:30 TestVolume001
507 \end{verbatim}
508 \normalsize
509
510 This is the file Volume that you just wrote and it contains all the data of
511 the job just run. If you run additional jobs, they will be appended to this
512 Volume unless you specify otherwise. 
513
514 You might ask yourself if you have to label all the Volumes that Bacula is
515 going to use. The answer for disk Volumes, like the one we used, is no. It is
516 possible to have Bacula automatically label volumes. For tape Volumes, you
517 will most likely have to label each of the Volumes you want to use. 
518
519 If you would like to stop here, you can simply enter {\bf quit} in the Console
520 program, and you can stop Bacula with {\bf ./bacula stop}. To clean up, simply
521 delete the file {\bf /tmp/TestVolume001}, and you should also re-initialize
522 your database using: 
523
524 \footnotesize
525 \begin{verbatim}
526 ./drop_bacula_tables
527 ./make_bacula_tables
528 \end{verbatim}
529 \normalsize
530
531 Please note that this will erase all information about the previous jobs that
532 have run, and that you might want to do it now while testing but that normally
533 you will not want to re-initialize your database. 
534
535 If you would like to try restoring the files that you just backed up, read the
536 following section. 
537 \label{restoring}
538
539 \subsection*{Restoring Your Files}
540 \index[general]{Files!Restoring Your }
541 \index[general]{Restoring Your Files }
542 \addcontentsline{toc}{subsection}{Restoring Your Files}
543
544 If you have run the default configuration and the save of the Bacula source
545 code as demonstrated above, you can restore the backed up files in the Console
546 program by entering: 
547
548 \footnotesize
549 \begin{verbatim}
550 restore all
551 \end{verbatim}
552 \normalsize
553
554 where you will get: 
555
556 \footnotesize
557 \begin{verbatim}
558 First you select one or more JobIds that contain files
559 to be restored. You will be presented several methods
560 of specifying the JobIds. Then you will be allowed to
561 select which files from those JobIds are to be restored.
562 To select the JobIds, you have the following choices:
563      1: List last 20 Jobs run
564      2: List Jobs where a given File is saved
565      3: Enter list of comma separated JobIds to select
566      4: Enter SQL list command
567      5: Select the most recent backup for a client
568      6: Select backup for a client before a specified time
569      7: Enter a list of files to restore
570      8: Enter a list of files to restore before a specified time
571      9: Cancel
572 Select item:  (1-9):
573 \end{verbatim}
574 \normalsize
575
576 As you can see, there are a number of options, but for the current
577 demonstration, please enter {\bf 5} to do a restore of the last backup you
578 did, and you will get the following output: 
579
580 \footnotesize
581 \begin{verbatim}
582 Defined Clients:
583      1: rufus-fd
584 Item 1 selected automatically.
585 The defined FileSet resources are:
586      1: 1  Full Set  2003-04-28 14:22:33
587 Item 1 selected automatically.
588 +-------+-------+----------+---------------------+---------------+
589 | JobId | Level | JobFiles | StartTime           | VolumeName    |
590 +-------+-------+----------+---------------------+---------------+
591 | 1     | F     | 1444     | 2003-04-28 14:22:33 | TestVolume002 |
592 +-------+-------+----------+---------------------+---------------+
593 You have selected the following JobId: 1
594 Building directory tree for JobId 1 ...
595 1 Job inserted into the tree and marked for extraction.
596 The defined Storage resources are:
597      1: File
598 Item 1 selected automatically.
599 You are now entering file selection mode where you add and
600 remove files to be restored. All files are initially added.
601 Enter "done" to leave this mode.
602 cwd is: /
603 $
604 \end{verbatim}
605 \normalsize
606
607 where I have truncated the listing on the right side to make it more readable.
608 As you can see by starting at the top of the listing, Bacula knows what client
609 you have, and since there was only one, it selected it automatically, likewise
610 for the FileSet. Then Bacula produced a listing containing all the jobs that
611 form the current backup, in this case, there is only one, and the Storage
612 daemon was also automatically chosen. Bacula then took all the files that were
613 in Job number 1 and entered them into a {\bf directory tree} (a sort of in
614 memory representation of your filesystem). At this point, you can use the {\bf
615 cd} and {\bf ls} ro {\bf dir} commands to walk up and down the directory tree
616 and view what files will be restored. For example, if I enter {\bf cd
617 /home/kern/bacula/bacula-1.30} and then enter {\bf dir} I will get a listing
618 of all the files in the Bacula source directory. On your system, the path will
619 be somewhat different. For more information on this, please refer to the 
620 \ilink{Restore Command Chapter}{_ChapterStart13} of this manual for
621 more details. 
622
623 To exit this mode, simply enter: 
624
625 \footnotesize
626 \begin{verbatim}
627 done
628 \end{verbatim}
629 \normalsize
630
631 and you will get the following output: 
632
633 \footnotesize
634 \begin{verbatim}
635 Bootstrap records written to
636    /home/kern/bacula/testbin/working/restore.bsr
637 The restore job will require the following Volumes:
638    
639    TestVolume001
640 1444 files selected to restore.
641 Run Restore job
642 JobName:    RestoreFiles
643 Bootstrap:  /home/kern/bacula/testbin/working/restore.bsr
644 Where:      /tmp/bacula-restores
645 Replace:    always
646 FileSet:    Full Set
647 Client:     rufus-fd
648 Storage:    File
649 JobId:      *None*
650 When:       2003-04-28 14:53:54
651 OK to run? (yes/mod/no):
652 \end{verbatim}
653 \normalsize
654
655 If you answer {\bf yes} your files will be restored to {\bf
656 /tmp/bacula-restores}. If you want to restore the files to their original
657 locations, you must use the {\bf mod} option and explicitly set {\bf Where:}
658 to nothing (or to /). We recommend you go ahead and answer {\bf yes} and after
659 a brief moment, enter {\bf messages}, at which point you should get a listing
660 of all the files that were restored as well as a summary of the job that looks
661 similar to this: 
662
663 \footnotesize
664 \begin{verbatim}
665 28-Apr-2003 14:56 rufus-dir: Bacula 1.30 (28Apr03): 28-Apr-2003 14:56
666 JobId:                  2
667 Job:                    RestoreFiles.2003-04-28_14.56.06
668 Client:                 rufus-fd
669 Start time:             28-Apr-2003 14:56
670 End time:               28-Apr-2003 14:56
671 Files Restored:         1,444
672 Bytes Restored:         38,816,381
673 Rate:                   9704.1 KB/s
674 FD termination status:  OK
675 Termination:            Restore OK
676 28-Apr-2003 14:56 rufus-dir: Begin pruning Jobs.
677 28-Apr-2003 14:56 rufus-dir: No Jobs found to prune.
678 28-Apr-2003 14:56 rufus-dir: Begin pruning Files.
679 28-Apr-2003 14:56 rufus-dir: No Files found to prune.
680 28-Apr-2003 14:56 rufus-dir: End auto prune.
681 \end{verbatim}
682 \normalsize
683
684 After exiting the Console program, you can examine the files in {\bf
685 /tmp/bacula-restores}, which will contain a small directory tree with all the
686 files. Be sure to clean up at the end with: 
687
688 \footnotesize
689 \begin{verbatim}
690 rm -rf /tmp/bacula-restore
691 \end{verbatim}
692 \normalsize
693
694 \subsection*{Quitting the Console Program}
695 \index[general]{Program!Quitting the Console }
696 \index[general]{Quitting the Console Program }
697 \addcontentsline{toc}{subsection}{Quitting the Console Program}
698
699 Simply enter the command {\bf quit}. 
700 \label{SecondClient}
701
702 \subsection*{Adding a Second Client}
703 \index[general]{Client!Adding a Second }
704 \index[general]{Adding a Second Client }
705 \addcontentsline{toc}{subsection}{Adding a Second Client}
706
707 If you have gotten the example shown above to work on your system, you may be
708 ready to add a second Client (File daemon). That is you have a second machine
709 that you would like backed up. The only part you need installed on the other
710 machine is the binary {\bf bacula-fd} (or {\bf bacula-fd.exe} for Windows) and
711 its configuration file {\bf bacula-fd.conf}. You can start with the same {\bf
712 bacula-fd.conf} file that you are currently using and make one minor
713 modification to it to create the conf file for your second client. Change the
714 File daemon name from whatever was configured, {\bf rufus-fd} in the example
715 above, but your system will have a different name. The best is to change it to
716 the name of your second machine. For example: 
717
718 \footnotesize
719 \begin{verbatim}
720 ...
721 #
722 # "Global" File daemon configuration specifications
723 #
724 FileDaemon {                          # this is me
725   Name = rufus-fd
726   FDport = 9102                  # where we listen for the director
727   WorkingDirectory = /home/kern/bacula/working
728   Pid Directory = /var/run
729 }
730 ...
731 \end{verbatim}
732 \normalsize
733
734 would become: 
735
736 \footnotesize
737 \begin{verbatim}
738 ...
739 #
740 # "Global" File daemon configuration specifications
741 #
742 FileDaemon {                          # this is me
743   Name = matou-fd
744   FDport = 9102                  # where we listen for the director
745   WorkingDirectory = /home/kern/bacula/working
746   Pid Directory = /var/run
747 }
748 ...
749 \end{verbatim}
750 \normalsize
751
752 where I show just a portion of the file and have changed {\bf rufus-fd} to
753 {\bf matou-fd}. The names you use are your choice. For the moment, I recommend
754 you change nothing else. Later, you will want to change the password. 
755
756 Now you should install that change on your second machine. Then you need to
757 make some additions to your Director's configuration file to define the new
758 File daemon or Client. Starting from our original example which should be
759 installed on your system, you should add the following lines (essentially
760 copies of the existing data but with the names changed) to your Director's
761 configuration file {\bf bacula-dir.conf}. 
762
763 \footnotesize
764 \begin{verbatim}
765 #
766 # Define the main nightly save backup job
767 #   By default, this job will back up to disk in /tmp
768 Job {
769   Name = "Matou"
770   Type = Backup
771   Client = matou-fd
772   FileSet = "Full Set"
773   Schedule = "WeeklyCycle"
774   Storage = File
775   Messages = Standard
776   Pool = Default
777   Write Bootstrap = "/home/kern/bacula/working/matou.bsr"
778 }
779 # Client (File Services) to backup
780 Client {
781   Name = matou-fd
782   Address = matou
783   FDPort = 9102
784   Catalog = MyCatalog
785   Password = "xxxxx"                  # password for
786   File Retention = 30d                # 30 days
787   Job Retention = 180d                # six months
788   AutoPrune = yes                     # Prune expired Jobs/Files
789 }
790 \end{verbatim}
791 \normalsize
792
793 Then make sure that the Address parameter in the Storage resource is set to
794 the fully qualified domain name and not to something like "localhost". The
795 address specified is sent to the File daemon (client) and it must be a fully
796 qualified domain name. If you pass something like "localhost" it will not
797 resolve correctly and will result in a time out when the File daemon fails to
798 connect to the Storage daemon. 
799
800 That is all that is necessary. I copied the existing resource to create a
801 second Job (Matou) to backup the second client (matou-fd). It has the name
802 {\bf Matou}, the Client is named {\bf matou-fd}, and the bootstrap file name
803 is changed, but everything else is the same. This means that Matou will be
804 backed up on the same schedule using the same set of tapes. You may want to
805 change that later, but for now, let's keep it simple. 
806
807 The second change was to add a new Client resource that defines {\bf matou-fd}
808 and has the correct address {\bf matou}, but in real life, you may need a
809 fully qualified machine address or an IP address. I also kept the password the
810 same (shown as xxxxx for the example). 
811
812 At this point, if you stop Bacula and restart it, and start the Client on the
813 other machine, everything will be ready, and the prompts that you saw above
814 will now include the second machine. 
815
816 To make this a real production installation, you will possibly want to use
817 different Pool, or a different schedule. It is up to you to customize. In any
818 case, you should change the password in both the Director's file and the
819 Client's file for additional security. 
820
821 For some important tips on changing names and passwords, and a diagram of what
822 names and passwords must match, please see 
823 \ilink{Authorization Errors}{AuthorizationErrors} in the FAQ chapter
824 of this manual. 
825
826 \subsection*{When The Tape Fills}
827 \label{FullTape}
828 \index[general]{Fills!When The Tape }
829 \index[general]{When The Tape Fills }
830 \addcontentsline{toc}{subsection}{When The Tape Fills}
831
832 If you have scheduled your job, typically nightly, there will come a time when
833 the tape fills up and {\bf Bacula} cannot continue. In this case, Bacula will
834 send you a message similar to the following: 
835
836 \footnotesize
837 \begin{verbatim}
838 rufus-sd: block.c:337 === Write error errno=28: ERR=No space left
839           on device
840 \end{verbatim}
841 \normalsize
842
843 This indicates that Bacula got a write error because the tape is full. Bacula
844 will then search the Pool specified for your Job looking for an appendable
845 volume. In the best of all cases, you will have properly set your Retention
846 Periods and you will have all your tapes marked to be Recycled, and {\bf
847 Bacula} will automatically recycle the tapes in your pool requesting and
848 overwriting old Volumes. For more information on recycling, please see the 
849 \ilink{Recycling chapter}{_ChapterStart22} of this manual. If you
850 find that your Volumes were not properly recycled (usually because of a
851 configuration error), please see the 
852 \ilink{Manually Recycling Volumes}{manualrecycling} section of
853 the Recycling chapter. 
854
855 If like me, you have a very large set of Volumes and you label them with the
856 date the Volume was first writing, or you have not set up your Retention
857 periods, Bacula will not find a tape in the pool, and it will send you a
858 message similar to the following: 
859
860 \footnotesize
861 \begin{verbatim}
862 rufus-sd: Job kernsave.2002-09-19.10:50:48 waiting. Cannot find any
863           appendable volumes.
864 Please use the "label"  command to create a new Volume for:
865     Storage:      SDT-10000
866     Media type:   DDS-4
867     Pool:         Default
868 \end{verbatim}
869 \normalsize
870
871 Until you create a new Volume, this message will be repeated an hour later,
872 then two hours later, and so on doubling the interval each time up to a
873 maximum interval of 1 day. 
874
875 The obvious question at this point is: What do I do now? 
876
877 The answer is simple: first, using the Console program, close the tape drive
878 using the {\bf unmount} command. If you only have a single drive, it will be
879 automatically selected, otherwise, make sure you release the one specified on
880 the message (in this case {\bf STD-10000}). 
881
882 Next, you remove the tape from the drive and insert a new blank tape. Note, on
883 some older tape drives, you may need to write an end of file mark ({\bf mt \
884 -f \ /dev/nst0 \ weof}) to prevent the drive from running away when Bacula
885 attempts to read the label. 
886
887 Finally, you use the {\bf label} command in the Console to write a label to
888 the new Volume. The {\bf label} command will contact the Storage daemon to
889 write the software label, if it is successful, it will add the new Volume to
890 the Pool, then issue a {\bf mount} command to the Storage daemon. See the
891 previous sections of this chapter for more details on labeling tapes. 
892
893 The result is that Bacula will continue the previous Job writing the backup to
894 the new Volume. 
895
896 If you have a Pool of volumes and Bacula is cycling through them, instead of
897 the above message "Cannot find any appendable volumes.", Bacula may ask you
898 to mount a specific volume. In that case, you should attempt to do just that.
899 If you do not have the volume any more (for any of a number of reasons), you
900 can simply mount another volume from the same Pool, providing it is
901 appendable, and Bacula will use it. You can use the {\bf list volumes} command
902 in the console program to determine which volumes are appendable and which are
903 not. 
904
905 If like me, you have your Volume retention periods set correctly, but you have
906 no more free Volumes, you can relabel and reuse a Volume as follows: 
907
908 \begin{itemize}
909 \item Do a {\bf list volumes} in the Console and select the oldest  Volume for
910    relabeling.  
911 \item If you have setup your Retention periods correctly, the  Volume should
912    have VolStatus {\bf Purged}.  
913 \item If the VolStatus is not set to Purged, you will need to purge  the
914    database of Jobs that are written on that Volume. Do so  by using the command
915    {\bf purge jobs volume} in the Console.  If you have multiple Pools, you will
916 be prompted for the  Pool then enter the VolumeName (or MediaId) when
917 requested.  
918 \item Then simply use the {\bf relabel} command to relabel the  Volume. 
919    \end{itemize}
920
921 To manually relabel the Volume use the following additional steps: 
922
923 \begin{itemize}
924 \item To delete the Volume from the catalog use the {\bf delete volume} 
925    command in the Console and select the VolumeName (or MediaId) to be  deleted. 
926
927 \item Use the {\bf unmount} command in the Console to unmount the  old tape.  
928 \item Physically relabel the old Volume that you deleted so that it  can be
929    reused.  
930 \item Insert the old Volume in the tape drive.  
931 \item From a command line do: {\bf mt \ -f \ /dev/st0 \ rewind} and  {\bf mt \
932    -f \ /dev/st0 \ weof}, where you need to use the proper  tape drive name for
933    your system in place of {\bf /dev/st0}.  
934 \item Use the {\bf label} command in the Console to write a new  Bacula label
935    on your tape.  
936 \item Use the {\bf mount} command in the Console if it is not automatically 
937    done, so that Bacula starts using your newly labeled tape. 
938    \end{itemize}
939
940 \subsection*{Other Useful Console Commands}
941 \index[general]{Commands!Other Useful Console }
942 \index[general]{Other Useful Console Commands }
943 \addcontentsline{toc}{subsection}{Other Useful Console Commands}
944
945 \begin{description}
946
947 \item [status dir]
948    \index[console]{status dir }
949    Print a status of all running jobs and jobs  scheduled in the next 24 hours.  
950
951 \item [status]
952    \index[console]{status }
953    The console program will prompt you to select  a daemon type, then will
954 request the daemon's status.  
955
956 \item [status jobid=nn]
957    \index[console]{status jobid }
958    Print a status of JobId nn if it is running.  The Storage daemon is contacted
959 and requested to print a current  status of the job as well.  
960
961 \item [list pools]
962    \index[console]{list pools }
963    List the pools defined in the Catalog (normally  only Default is used).  
964
965 \item [list media]
966    \index[console]{list media }
967    Lists all the media defined in the Catalog.  
968
969 \item [list jobs]
970    \index[console]{list jobs }
971    Lists all jobs in the Catalog that have run.  
972
973 \item [list jobid=nn]
974    \index[console]{list jobid }
975    Lists JobId nn from the Catalog.  
976
977 \item [list jobtotals]
978    \index[console]{list jobtotals }
979    Lists totals for all jobs in the Catalog.  
980
981 \item [list files jobid=nn]
982    \index[console]{list files jobid }
983    List the files that were saved for JobId nn.  
984
985 \item [list jobmedia]
986    \index[console]{list jobmedia }
987    List the media information for each Job run.  
988
989 \item [messages]
990    \index[console]{messages }
991    Prints any messages that have been directed to the console.  
992
993 \item [unmount storage=storage-name]
994    \index[console]{unmount storage }
995    Unmounts the drive associated with the storage  device with the name {\bf
996 storage-name} if the drive is not currently being  used. This command is used
997 if you wish Bacula to free the drive so  that you can use it to label a tape. 
998
999
1000 \item [mount storage=storage-name]
1001    \index[sd]{mount storage }
1002    Causes the drive associated with the  storage device to be mounted again. When
1003 Bacula reaches the end of a volume and requests you to mount a  new volume,
1004 you must issue this command after you have placed the  new volume in the
1005 drive. In effect, it is the signal needed by  Bacula to know to start reading
1006 or writing the new volume.  
1007
1008 \item [quit]
1009    \index[sd]{quit }
1010    Exit or quit the console program. 
1011 \end{description}
1012
1013 Most of the commands given above, with the exception of {\bf list}, will
1014 prompt you for the necessary arguments if you simply enter the command name. 
1015
1016 \subsection*{Debug Daemon Output}
1017 \index[general]{Debug Daemon Output }
1018 \index[general]{Output!Debug Daemon }
1019 \addcontentsline{toc}{subsection}{Debug Daemon Output}
1020
1021 If you want debug output from the daemons as they are running, start the
1022 daemons from the install directory as follows: 
1023
1024 \footnotesize
1025 \begin{verbatim}
1026 ./bacula start -d20
1027 \end{verbatim}
1028 \normalsize
1029
1030 To stop the three daemons, enter the following from the install directory: 
1031
1032 \footnotesize
1033 \begin{verbatim}
1034 ./bacula stop
1035 \end{verbatim}
1036 \normalsize
1037
1038 The execution of {\bf bacula stop} may complain about pids not found. This is
1039 OK, especially if one of the daemons has died, which is very rare. 
1040
1041 To do a full system save, each File daemon must be running as root so that it
1042 will have permission to access all the files. None of the other daemons
1043 require root privileges. However, the Storage daemon must be able to open the
1044 tape drives. On many systems, only root can access the tape drives. Either run
1045 the Storage daemon as root, or change the permissions on the tape devices to
1046 permit non-root access. MySQL and PostgreSQL can be installed and run with any
1047 userid; root privilege is not necessary. 
1048
1049 \subsection*{Have Patience When Starting the Daemons or Mounting Blank Tapes}
1050 \index[general]{Have Patience When Starting the Daemons or Mounting Blank
1051 Tapes }
1052 \index[general]{Tapes!Have Patience When Starting the Daemons or Mounting
1053 Blank }
1054 \addcontentsline{toc}{subsection}{Have Patience When Starting the Daemons or
1055 Mounting Blank Tapes}
1056
1057 When you start the Bacula daemons, the Storage daemon attempts to open all
1058 defined storage devices and verify the currently mounted Volume (if
1059 configured). Until all the storage devices are verified, the Storage daemon
1060 will not accept connections from the Console program. If a tape was previously
1061 used, it will be rewound, and on some devices this can take several minutes.
1062 As a consequence, you may need to have a bit of patience when first contacting
1063 the Storage daemon after starting the daemons. If you can see your tape drive,
1064 once the lights stop flashing, the drive will be ready to be used. 
1065
1066 The same considerations apply if you have just mounted a blank tape in a drive
1067 such as an HP DLT. It can take a minute or two before the drive properly
1068 recognizes that the tape is blank. If you attempt to {\bf mount} the tape with
1069 the Console program during this recognition period, it is quite possible that
1070 you will hang your SCSI driver (at least on my RedHat Linux system). As a
1071 consequence, you are again urged to have patience when inserting blank tapes.
1072 Let the device settle down before attempting to access it. 
1073
1074 \subsection*{Difficulties Connecting from the FD to the SD}
1075 \index[general]{Difficulties Connecting from the FD to the SD }
1076 \index[general]{SD!Difficulties Connecting from the FD to the }
1077 \addcontentsline{toc}{subsection}{Difficulties Connecting from the FD to the
1078 SD}
1079
1080 If you are having difficulties getting one or more of your File daemons to
1081 connect to the Storage daemon, it is most likely because you have not used a
1082 fully qualified Internet address on the {\bf Address} directive in the
1083 Director's Storage resource. That is the resolver on the File daemon's machine
1084 (not on the Director's) must be able to resolve the name you supply into an IP
1085 address. An example of an address that is guaranteed not to work: {\bf
1086 localhost}. An example that may work: {\bf megalon}. An example that is more
1087 likely to work: {\bf magalon.mydomain.com}. On Win32 if you don't have a good
1088 resolver (often true on older Win98 systems), you might try using an IP
1089 address in place of a name. 
1090
1091 If your address is correct, then make sure that no other program is using the
1092 port 9103 on the Storage daemon's machine. The Bacula port number are
1093 authorized by IANA, and should not be used by other programs, but apparently
1094 some HP printers do use these port numbers. A {\bf netstat -a} on the Storage
1095 daemon's machine can determine who is using the 9103 port (used for FD to SD
1096 communications in Bacula). 
1097
1098 \subsection*{Daemon Command Line Options}
1099 \index[general]{Daemon Command Line Options }
1100 \index[general]{Options!Daemon Command Line }
1101 \addcontentsline{toc}{subsection}{Daemon Command Line Options}
1102
1103 Each of the three daemons (Director, File, Storage) accepts a small set of
1104 options on the command line. In general, each of the daemons as well as the
1105 Console program accepts the following options: 
1106
1107 \begin{description}
1108
1109 \item [-c \lt{}file\gt{}]
1110    \index[sd]{-c \lt{}file\gt{} }
1111    Define the file to use as a  configuration file. The default is the daemon
1112 name followed  by {\bf .conf} i.e. {\bf bacula-dir.conf} for the Director, 
1113 {\bf bacula-fd.conf} for the File daemon, and {\bf bacula-sd}  for the Storage
1114 daemon.  
1115
1116 \item [-d nn]
1117    \index[sd]{-d nn }
1118    Set the debug level to {\bf nn}. Higher levels  of debug cause more
1119 information to be displayed on STDOUT concerning  what the daemon is doing.  
1120
1121 \item [-f]
1122    Run the daemon in the foreground. This option is  needed to run the daemon
1123    under the debugger.  
1124
1125 \item [-s]
1126    Do not trap signals. This option is needed to run  the daemon under the
1127    debugger.  
1128
1129 \item [-t]
1130    Read the configuration file and print any error messages,  then immediately
1131    exit. Useful for syntax testing of  new configuration files.  
1132
1133 \item [-v]
1134    Be more verbose or more complete in printing error  and informational
1135    messages. Recommended.  
1136
1137 \item [-?]
1138    Print the version and list of options. 
1139    \end{description}
1140
1141 The Director has the following additional Director specific option: 
1142
1143 \begin{description}
1144
1145 \item [-r \lt{}job\gt{}]
1146    \index[fd]{-r \lt{}job\gt{} }
1147    Run the named job immediately. This is  for debugging and should not be used. 
1148 \end{description}
1149
1150 The File daemon has the following File daemon specific option: 
1151
1152 \begin{description}
1153
1154 \item [-i]
1155    Assume that the daemon is called from {\bf inetd}  or {\bf xinetd}. In this
1156    case, the daemon assumes that a connection  has already been made and that it
1157 is passed as STDIN. After the  connection terminates the daemon will exit. 
1158 \end{description}
1159
1160 The Storage daemon has no Storage daemon specific options. 
1161
1162 The Console program has no console specific options. 
1163
1164 \subsection*{Creating a Pool}
1165 \label{Pool}
1166 \index[general]{Pool!Creating a }
1167 \index[general]{Creating a Pool }
1168 \addcontentsline{toc}{subsection}{Creating a Pool}
1169
1170 Creating the Pool is automatically done when {\bf Bacula} starts, so if you
1171 understand Pools, you can skip to the next section. 
1172
1173 When you run a job, one of the things that Bacula must know is what Volumes to
1174 use to backup the FileSet. Instead of specifying a Volume (tape) directly, you
1175 specify which Pool of Volumes you want Bacula to consult when it wants a tape
1176 for writing backups. Bacula will select the first available Volume from the
1177 Pool that is appropriate for the Storage device you have specified for the Job
1178 being run. When a volume has filled up with data, {\bf Bacula} will change its
1179 VolStatus from {\bf Append} to {\bf Full}, and then {\bf Bacula} will use the
1180 next volume and so on. If no appendable Volume exists in the Pool, the
1181 Director will attempt to recycle an old Volume, if there are still no
1182 appendable Volumes available, {\bf Bacula} will send a message requesting the
1183 operator to create an appropriate Volume. 
1184
1185 {\bf Bacula} keeps track of the Pool name, the volumes contained in the Pool,
1186 and a number of attributes of each of those Volumes. 
1187
1188 When Bacula starts, it ensures that all Pool resource definitions have been
1189 recorded in the catalog. You can verify this by entering: 
1190
1191 \footnotesize
1192 \begin{verbatim}
1193 list pools
1194 \end{verbatim}
1195 \normalsize
1196
1197 to the console program, which should print something like the following: 
1198
1199 \footnotesize
1200 \begin{verbatim}
1201 *list pools
1202 Using default Catalog name=MySQL DB=bacula
1203 +--------+---------+---------+---------+----------+-------------+
1204 | PoolId | Name    | NumVols | MaxVols | PoolType | LabelFormat |
1205 +--------+---------+---------+---------+----------+-------------+
1206 | 1      | Default | 3       | 0       | Backup   | *           |
1207 | 2      | File    | 12      | 12      | Backup   | File        |
1208 +--------+---------+---------+---------+----------+-------------+
1209 *
1210 \end{verbatim}
1211 \normalsize
1212
1213 If you attempt to create the same Pool name a second time, {\bf Bacula} will
1214 print: 
1215
1216 \footnotesize
1217 \begin{verbatim}
1218 Error: Pool Default already exists.
1219 Once created, you may use the {\bf update} command to
1220 modify many of the values in the Pool record.
1221 \end{verbatim}
1222 \normalsize
1223
1224 \label{Labeling}
1225
1226 \subsection*{Labeling Your Volumes}
1227 \index[general]{Volumes!Labeling Your }
1228 \index[general]{Labeling Your Volumes }
1229 \addcontentsline{toc}{subsection}{Labeling Your Volumes}
1230
1231 Bacula requires that each Volume contains a software label. There are several
1232 strategies for labeling volumes. The one I use is to label them as they are
1233 needed by {\bf Bacula} using the console program. That is when Bacula needs a
1234 new Volume, and it does not find one in the catalog, it will send me an email
1235 message requesting that I add Volumes to the Pool. I then use the {\bf label}
1236 command in the Console program to label a new Volume and to define it in the
1237 Pool database, after which Bacula will begin writing on the new Volume.
1238 Alternatively, I can use the Console {\bf relabel} command to relabel a Volume
1239 that is no longer used providing it has VolStatus {\bf Purged}. 
1240
1241 Another strategy is to label a set of volumes at the start, then use them as
1242 {\bf Bacula} requests them. This is most often done if you are cycling through
1243 a set of tapes, for example using an autochanger. For more details on
1244 recycling, please see the 
1245 \ilink{Automatic Volume Recycling}{_ChapterStart22} chapter of
1246 this manual. 
1247
1248 If you run a Bacula job, and you have no labeled tapes in the Pool, Bacula
1249 will inform you, and you can create them "on-the-fly" so to speak. In my
1250 case, I label my tapes with the date, for example: {\bf DLT-18April02}. See
1251 below for the details of using the {\bf label} command. 
1252
1253 \subsection*{Labeling Volumes with the Console Program}
1254 \index[general]{Labeling Volumes with the Console Program }
1255 \index[general]{Program!Labeling Volumes with the Console }
1256 \addcontentsline{toc}{subsection}{Labeling Volumes with the Console Program}
1257
1258 Labeling volumes is normally done by using the console program. 
1259
1260 \begin{enumerate}
1261 \item ./bconsole  
1262 \item label 
1263    \end{enumerate}
1264
1265 If Bacula complains that you cannot label the tape because it is already
1266 labeled, simply {\bf unmount} the tape using the {\bf unmount} command in the
1267 console, then physically mount a blank tape and re-issue the {\bf label}
1268 command. 
1269
1270 Since the physical storage media is different for each device, the {\bf label}
1271 command will provide you with a list of the defined Storage resources such as
1272 the following: 
1273
1274 \footnotesize
1275 \begin{verbatim}
1276 The defined Storage resources are:
1277      1: File
1278      2: 8mmDrive
1279      3: DLTDrive
1280      4: SDT-10000
1281 Select Storage resource (1-4):
1282 \end{verbatim}
1283 \normalsize
1284
1285 At this point, you should have a blank tape in the drive corresponding to the
1286 Storage resource that you select. 
1287
1288 It will then ask you for the Volume name. 
1289
1290 \footnotesize
1291 \begin{verbatim}
1292 Enter new Volume name:
1293 \end{verbatim}
1294 \normalsize
1295
1296 If Bacula complains: 
1297
1298 \footnotesize
1299 \begin{verbatim}
1300 Media record for Volume xxxx already exists.
1301 \end{verbatim}
1302 \normalsize
1303
1304 It means that the volume name {\bf xxxx} that you entered already exists in
1305 the Media database. You can list all the defined Media (Volumes) with the {\bf
1306 list media} command. Note, the LastWritten column has been truncated for
1307 proper printing. 
1308
1309 \footnotesize
1310 \begin{verbatim}
1311 +---------------+---------+--------+----------------+-----/~/-+------------+-----+
1312 | VolumeName    | MediaTyp| VolStat| VolBytes       | LastWri | VolReten   | Recy|
1313 +---------------+---------+--------+----------------+---------+------------+-----+
1314 | DLTVol0002    | DLT8000 | Purged | 56,128,042,217 | 2001-10 | 31,536,000 |   0 |
1315 | DLT-07Oct2001 | DLT8000 | Full   | 56,172,030,586 | 2001-11 | 31,536,000 |   0 |
1316 | DLT-08Nov2001 | DLT8000 | Full   | 55,691,684,216 | 2001-12 | 31,536,000 |   0 |
1317 | DLT-01Dec2001 | DLT8000 | Full   | 55,162,215,866 | 2001-12 | 31,536,000 |   0 |
1318 | DLT-28Dec2001 | DLT8000 | Full   | 57,888,007,042 | 2002-01 | 31,536,000 |   0 |
1319 | DLT-20Jan2002 | DLT8000 | Full   | 57,003,507,308 | 2002-02 | 31,536,000 |   0 |
1320 | DLT-16Feb2002 | DLT8000 | Full   | 55,772,630,824 | 2002-03 | 31,536,000 |   0 |
1321 | DLT-12Mar2002 | DLT8000 | Full   | 50,666,320,453 | 1970-01 | 31,536,000 |   0 |
1322 | DLT-27Mar2002 | DLT8000 | Full   | 57,592,952,309 | 2002-04 | 31,536,000 |   0 |
1323 | DLT-15Apr2002 | DLT8000 | Full   | 57,190,864,185 | 2002-05 | 31,536,000 |   0 |
1324 | DLT-04May2002 | DLT8000 | Full   | 60,486,677,724 | 2002-05 | 31,536,000 |   0 |
1325 | DLT-26May02   | DLT8000 | Append |  1,336,699,620 | 2002-05 | 31,536,000 |   1 |
1326 +---------------+---------+--------+----------------+-----/~/-+------------+-----+
1327 \end{verbatim}
1328 \normalsize
1329
1330 Once Bacula has verified that the volume does not already exist, it will
1331 prompt you for the name of the Pool in which the Volume (tape) is to be
1332 created.  If there is only one Pool (Default), it will be automatically
1333 selected.
1334
1335 If the tape is successfully labeled, a Volume record will also be created in
1336 the Pool. That is the Volume name and all its other attributes will appear
1337 when you list the Pool. In addition, that Volume will be available for backup
1338 if the MediaType matches what is requested by the Storage daemon. 
1339
1340 When you labeled the tape, you answered very few questions about it --
1341 principally the Volume name, and perhaps the Slot. However, a Volume record in
1342 the catalog database (internally known as a Media record) contains quite a few
1343 attributes. Most of these attributes will be filled in from the default values
1344 that were defined in the Pool (i.e. the Pool holds most of the default
1345 attributes used when creating a Volume). 
1346
1347 It is also possible to add media to the pool without physically labeling the
1348 Volumes. This can be done with the {\bf add} command. For more information,
1349 please see the 
1350 \ilink{Console Chapter}{_ConsoleChapter} of this manual.