4 \section*{Autochanger Support}
5 \label{_ChapterStart18}
6 \index[general]{Support!Autochanger }
7 \index[general]{Autochanger Support }
8 \addcontentsline{toc}{section}{Autochanger Support}
10 \subsection*{Autochangers -- General}
11 \index[general]{General!Autochangers -- }
12 \index[general]{Autochangers -- General }
13 \addcontentsline{toc}{subsection}{Autochangers -- General}
15 Bacula provides autochanger support for reading and writing tapes. In
16 order to work with an autochanger, Bacula requires three things, each of
17 which is explained in more detail after this list:
20 \item A script that actually controls the autochanger according to commands
21 sent by Bacula. We furnish such a script that works with {\bf mtx} found in
22 the {\bf depkgs} distribution. This script works only with single drive
24 \item That each Volume (tape) to be used must be defined in the Catalog and
25 have a Slot number assigned to it so that Bacula knows where the Volume is in
26 the autochanger. This is generally done with the {\bf label} command. See
27 below for more details. You must pre-label the tapes manually before
29 \item Modifications to your Storage daemon's Device configuration resource to
30 identify that the device is a changer, as well as a few other parameters.
31 \item You should also modify your Storage resource definition in the
32 Director's configuration file so that you are automatically prompted for the
33 Slot when labeling a Volume.
34 \item You need to ensure that your Storage daemon (if not running as root)
35 has access permissions to both the tape drive and the control device.
36 \item You need to have {\bf Autochanger = yes} in your Storage resource
37 in your bacula-dir.conf file so that you will be prompted for the
38 slot number when you label Volumes.
41 In version 1.37, there is a new \ilink{Autochanger
42 resource}{AutochangerRes} that permits you to group Device resources thus
43 creating a multi-drive autochanger. If you have a multi-drive autochanger,
44 you must use this new resource. If you have a single drive autochanger,
45 it is recommended, but not required.
47 Bacula uses its own {\bf mtx-changer} script to interface with a program
48 that actually does the tape changing. Thus in principle, {\bf mtx-changer}
49 can be adapted to function with any autochanger program. The current
50 version of {\bf mtx-changer} works with the {\bf mtx} program. However,
51 FreeBSD users have provided a script in the {\bf examples/autochangers}
52 directory that allows Bacula to use the {\bf chio} program.
54 Bacula also supports autochangers with barcode
55 readers. This support includes two Console commands: {\bf label barcodes}
56 and {\bf update slots}. For more details on these commands, see the "Barcode
57 Support" section below.
59 Current Bacula autochanger support does not include cleaning, stackers, or
60 silos. However, under certain conditions, you may be able to make Bacula
61 work with stackers (gravity feed and such). Support for multi-drive
62 autochangers requires the \ilink{Autochanger resource}{AutochangerRes}
63 introduced in version 1.37. This resource is also recommended for single
66 In principle, if {\bf mtx} will operate your changer correctly, then it is
67 just a question of adapting the {\bf mtx-changer} script (or selecting one
68 already adapted) for proper interfacing. You can find a list of autochangers
69 supported by {\bf mtx} at the following link:
70 \elink{http://mtx.badtux.net/compatibility.php}
71 {http://mtx.badtux.net/compatibility.php}.
72 The home page for the {\bf mtx} project can be found at:
73 \elink{http://mtx.badtux.net/}{http://mtx.badtux.net/}.
75 If you are having troubles, please use the {\bf auto} command in the {\bf
76 btape} program to test the functioning of your autochanger with Bacula. When
77 Bacula is running, please remember that for many distributions (e.g. FreeBSD,
78 Debian, ...) the Storage daemon runs as {\bf bacula.tape} rather than {\bf
79 root.root}, so you will need to ensure that the Storage daemon has sufficient
80 permissions to access the autochanger.
83 \subsection*{Knowing What SCSI Devices You Have}
84 \index[general]{Have!Knowing What SCSI Devices You }
85 \index[general]{Knowing What SCSI Devices You Have }
86 \index[general]{SCSI devices}
87 \index[general]{devices!SCSI}
88 \addcontentsline{toc}{subsection}{Knowing What SCSI Devices You Have}
98 to see what SCSI devices you have available. You can also:
102 cat /proc/scsi/sg/device_hdr /proc/scsi/sg/devices
106 to find out how to specify their control address ({\bf /dev/sg0} for the
107 first, {\bf /dev/sg1} for the second, ...) on the {\bf Changer Device = }
110 Under FreeBSD, you can use:
118 To list the SCSI devices as well as the {\bf /dev/passn} that you will use on
119 the Bacula {\bf Changer Device = } directive.
121 Please check that your Storage daemon has permission to access this
126 \subsection*{Example Scripts}
127 \index[general]{Scripts!Example }
128 \index[general]{Example Scripts }
129 \addcontentsline{toc}{subsection}{Example Scripts}
131 Please read the sections below so that you understand how autochangers work
132 with Bacula. Although we supply a default {\bf mtx-changer} script, your
133 autochanger may require some additional changes. If you want to see examples
134 of configuration files and scripts, please look in the {\bf
135 \lt{}bacula-src\gt{}/examples/devices} directory where you will find an
136 example {\bf HP-autoloader.conf} Bacula Device resource, and several {\bf
137 mtx-changer} scripts that have been modified to work with different
143 \index[general]{Slots }
144 \addcontentsline{toc}{subsection}{Slots}
146 To properly address autochangers, Bacula must know which Volume is in each
147 {\bf slot} of the autochanger. Slots are where the changer cartridges reside
148 when not loaded into the drive. Bacula numbers these slots from one to the
149 number of cartridges contained in the autochanger.
151 Bacula will not automatically use a Volume in your autochanger unless it is
152 labeled and the slot number is stored in the catalog and the Volume is marked
153 as InChanger. For each Volume in your
154 changer, you will, using the Console program, assign a slot. This information
155 is kept in {\bf Bacula's} catalog database along with the other data for the
156 volume. If no slot is given, or the slot is set to zero, Bacula will not
157 attempt to use the autochanger even if all the necessary configuration records
158 are present. In addition, the console {\bf mount} command does not cause
159 Bacula to operate the autochanger, it only tells Bacula to read any tape that
162 You can check if the Slot number and InChanger flag are set by doing a:
167 in the Console program.
170 \subsection*{Multiple Devices}
171 \index[general]{Devices!Multiple }
172 \index[general]{Multiple Devices }
173 \addcontentsline{toc}{subsection}{Multiple Devices}
175 Some autochangers have more than one read/write device (drive). The
177 \ilink{Autochanger resource}{AutochangerRes} introduced in version
178 1.37 permits you to group Device resources, where each device
179 represents a drive. The Director may still reference the Devices (drives)
180 directly, but doing so, bypasses the proper functioning of the
181 drives together. Instead, the Director (in the Storage resource)
182 should reference the Autochanger resource name. Doing so permits
183 the Storage daemon to ensure that only one drive uses the mtx-changer
184 script at a time, and also that two drives don't reference the
187 Multi-drive requires the use of the {\bf
188 Drive Index} directive in the Device resource of the Storage daemon's
189 configuration file. Drive numbers or the Device Index are numbered beginning
190 at zero, which is the default. To use the second Drive in an autochanger, you
191 need to define a second Device resource and set the Drive Index to 1 for
192 that device. In general, the second device will have the same {\bf Changer
193 Device} (control channel) as the first drive, but a different {\bf Archive
196 \label{ConfigRecords}
197 \subsection*{Device Configuration Records}
198 \index[general]{Records!Device Configuration }
199 \index[general]{Device Configuration Records }
200 \addcontentsline{toc}{subsection}{Device Configuration Records}
202 Configuration of autochangers within Bacula is done in the Device resource of
203 the Storage daemon. Four records: {\bf Autochanger}, {\bf Changer Device},
204 {\bf Changer Command}, and {\bf Maximum Changer Wait} control how Bacula uses
207 These four records, permitted in {\bf Device} resources, are described in
208 detail below. Note, however, that the {\bf Changer Device} and the
209 {\bf Changer Command} directives are not needed in the Device resource
210 if they are present in the {\bf Autochanger} resource.
214 \item [Autochanger = {\it Yes|No} ]
215 \index[sd]{Autochanger }
216 The {\bf Autochanger} record specifies that the current device is or is not
217 an autochanger. The default is {\bf no}.
219 \item [Changer Device = \lt{}device-name\gt{}]
220 \index[sd]{Changer Device }
221 In addition to the Archive Device name, you must specify a {\bf Changer
222 Device} name. This is because most autochangers are controlled through a
223 different device than is used for reading and writing the cartridges. For
224 example, on Linux, one normally uses the generic SCSI interface for
225 controlling the autochanger, but the standard SCSI interface for reading and
226 writing the tapes. On Linux, for the {\bf Archive Device = /dev/nst0}, you
227 would typically have {\bf Changer Device = /dev/sg0}. Note, some of the more
228 advanced autochangers will locate the changer device on {\bf /dev/sg1}. Such
229 devices typically have several drives and a large number of tapes.
231 On FreeBSD systems, the changer device will typically be on {\bf /dev/pass0}
232 through {\bf /dev/passn}.
234 On Solaris, the changer device will typically be some file under {\bf
237 Please ensure that your Storage daemon has permission to access this
240 \item [Changer Command = \lt{}command\gt{}]
241 \index[sd]{Changer Command }
242 This record is used to specify the external program to call and what
243 arguments to pass to it. The command is assumed to be a standard program or
244 shell script that can be executed by the operating system. This command is
245 invoked each time that Bacula wishes to manipulate the autochanger. The
246 following substitutions are made in the {\bf command} before it is sent to
247 the operating system for execution:
252 %a = archive device name
253 %c = changer device name
254 %d = changer drive index base 0
257 %o = command (loaded, load, or unload)
264 An actual example for using {\bf mtx} with the {\bf mtx-changer} script (part
265 of the Bacula distribution) is:
269 Changer Command = "/etc/bacula/mtx-changer %c %o %S %a %d"
273 Where you will need to adapt the {\bf /etc/bacula} to be the actual path on
274 your system where the mtx-changer script resides. Details of the three
275 commands currently used by Bacula (loaded, load, unload) as well as the
276 output expected by Bacula are give in the {\bf Bacula Autochanger Interface}
279 \item [Maximum Changer Wait = \lt{}time\gt{}]
280 \index[sd]{Maximum Changer Wait }
281 This record is used to define the maximum amount of time that Bacula
282 will wait for an autoloader to respond to a command (e.g. load). The
283 default is set to 120 seconds. If you have a slow autoloader you may
284 want to set it longer.
286 If the autoloader program fails to respond in this time, it will be killed
287 and Bacula will request operator intervention.
289 \item [Drive Index = \lt{}number\gt{}]
290 \index[sd]{Drive Index }
291 This record allows you to tell Bacula to use the second or subsequent
292 drive in an autochanger with multiple drives. Since the drives are
293 numbered from zero, the second drive is defined by
302 To use the second drive, you need a second Device resource definition in the
303 Bacula configuration file. See the Multiple Drive section above in this
304 chapter for more information.
307 In addition, for proper functioning of the Autochanger, you must
308 define an Autochanger resource.
309 \input{autochangerres}
312 \subsection*{An Example Configuration File}
313 \index[general]{Example Configuration File }
314 \index[general]{File!Example Configuration }
315 \addcontentsline{toc}{subsection}{Example Configuration File}
317 The following two resources implement an autochanger:
324 Changer Device = /dev/sg0
325 Changer Command = "/etc/bacula/mtx-changer %c %o %S %a %d"
331 Archive Device = /dev/nst0 # Normal archive device
334 AutomaticMount = yes;
336 Mount Anonymous Volumes = no;
341 where you will adapt the {\bf Archive Device}, the {\bf Changer Device}, and
342 the path to the {\bf Changer Command} to correspond to the values used on your
345 \subsection*{A Multi-drive Example Configuration File}
346 \index[general]{Multi-drive Example Configuration File }
347 \addcontentsline{toc}{subsection}{A Multi-drive Example Configuration File}
349 The following resources implement a multi-drive autochanger:
355 Device = Drive-1, Drive-2
356 Changer Device = /dev/sg0
357 Changer Command = "/etc/bacula/mtx-changer %c %o %S %a %d"
364 Archive Device = /dev/nst0 # Normal archive device
367 AutomaticMount = yes;
369 Mount Anonymous Volumes = no;
376 Archive Device = /dev/nst1 # Normal archive device
379 AutomaticMount = yes;
381 Mount Anonymous Volumes = no;
387 where you will adapt the {\bf Archive Device}, the {\bf Changer Device}, and
388 the path to the {\bf Changer Command} to correspond to the values used on your
391 \label{SpecifyingSlots}
392 \subsection*{Specifying Slots When Labeling}
393 \index[general]{Specifying Slots When Labeling }
394 \index[general]{Labeling!Specifying Slots When }
395 \addcontentsline{toc}{subsection}{Specifying Slots When Labeling}
397 If you add an {\bf Autochanger = yes} record to the Storage resource in your
398 Director's configuration file, the Bacula Console will automatically prompt
399 you for the slot number when the Volume is in the changer when
400 you {\bf add} or {\bf label} tapes for that Storage device. If your
401 {\bf mtx-changer} script is properly installed, Bacula will automatically
402 load the correct tape during the label command.
405 {\bf Autochanger = yes} in the Storage daemon's Device resource
406 as we have described above in
407 order for the autochanger to be used. Please see the
408 \ilink{Storage Resource}{Autochanger1} in the Director's chapter
410 \ilink{Device Resource}{Autochanger} in the Storage daemon
411 chapter for more details on these records.
413 Thus all stages of dealing with tapes can be totally automated. It is also
414 possible to set or change the Slot using the {\bf update} command in the
415 Console and selecting {\bf Volume Parameters} to update.
417 Even though all the above configuration statements are specified and correct,
418 Bacula will attempt to access the autochanger only if a {\bf slot} is non-zero
419 in the catalog Volume record (with the Volume name).
421 If your autochanger has barcode labels, you can label all the Volumes in
422 your autochanger one after another by using the {\bf label barcodes} command.
423 For each tape in the changer containing a barcode, Bacula will mount the tape
424 and then label it with the same name as the barcode. An appropriate Media
425 record will also be created in the catalog. Any barcode that begins with the
426 same characters as specified on the "CleaningPrefix=xxx" command, will be
427 treated as a cleaning tape, and will not be labeled. For example with:
429 Please note that Volumes must be pre-labeled to be automatically used in
430 the autochanger during a backup. If you do not have a barcode reader, this
431 is done manually (or via a script).
437 Cleaning Prefix = "CLN"
442 Any slot containing a barcode of CLNxxxx will be treated as a cleaning tape
443 and will not be mounted.
447 \subsection*{Dealing with Multiple Magazines}
448 \index[general]{Dealing with Multiple Magazines }
449 \index[general]{Magazines!Dealing with Multiple }
450 \addcontentsline{toc}{subsection}{Dealing with Multiple Magazines}
452 If you have several magazines or if you insert or remove cartridges from a
453 magazine, you should notify Bacula of this. By doing so, Bacula will as
454 a preference, use Volumes that it knows to be in the autochanger before
455 accessing Volumes that are not in the autochanger. This prevents unneeded
456 operator intervention.
458 If your autochanger has barcodes (machine readable tape labels), the task of
459 informing Bacula is simple. Every time, you change a magazine, or add or
460 remove a cartridge from the magazine, simply do
468 in the Console program. This will cause Bacula to request the autochanger to
469 return the current Volume names in the magazine. This will be done without
470 actually accessing or reading the Volumes because the barcode reader does this
471 during inventory when the autochanger is first turned on. Bacula will ensure
472 that any Volumes that are currently marked as being in the magazine are marked
473 as no longer in the magazine, and the new list of Volumes will be marked as
474 being in the magazine. In addition, the Slot numbers of the Volumes will be
475 corrected in Bacula's catalog if they are incorrect (added or moved).
477 If you do not have a barcode reader on your autochanger, you have several
481 \item You can manually set the Slot and InChanger flag using the {\bf update
482 volume} command in the Console (quite painful).
483 \item You can issue a
491 command that will cause Bacula to read the label on each of the cartridges in
492 the magazine in turn and update the information (Slot, InChanger flag) in the
493 catalog. This is quite effective but does take time to load each cartridge
494 into the drive in turn and read the Volume label.
495 \item You can modify the mtx-changer script so that it simulates an
496 autochanger with barcodes. See below for more details.
501 \subsection*{Simulating Barcodes in your Autochanger}
502 \index[general]{Autochanger!Simulating Barcodes in your }
503 \index[general]{Simulating Barcodes in your Autochanger }
504 \addcontentsline{toc}{subsection}{Simulating Barcodes in your Autochanger}
506 You can simulate barcodes in your autochanger by making the {\bf mtx-changer}
507 script return the same information that an autochanger with barcodes would do.
508 This is done by commenting out the one and only line in the {\bf list)} case,
513 ${MTX} -f $ctl status | grep " *Storage Element [0-9]*:.*Full" | awk "{print \$3 \$4}" | sed "s/Full *\(:VolumeTag=\)*//"
517 at approximately line 99 by putting a \# in column one of that line, or by
518 simply deleting it. Then in its place add a new line that prints the contents
519 of a file. For example:
523 cat /etc/bacula/changer.volumes
527 Be sure to include a full path to the file, which can have any name. The
528 contents of the file must be of the following format:
539 Where the 1, 2, 3 are the slot numbers and Volume1, Volume2, ... are the
540 Volume names in those slots. You can have multiple files that represent the
541 Volumes in different magazines, and when you change magazines, simply copy the
542 contents of the correct file into your {\bf /etc/bacula/changer.volumes} file.
543 There is no need to stop and start Bacula when you change magazines, simply
544 put the correct data in the file, then run the {\bf update slots} command, and
545 your autochanger will appear to Bacula to be an autochanger with barcodes.
548 \subsection*{The Full Form of the Update Slots Command}
549 \index[general]{Full Form of the Update Slots Command }
550 \index[general]{Command!Full Form of the Update Slots }
551 \addcontentsline{toc}{subsection}{Full Form of the Update Slots Command}
553 If you change only one cartridge in the magazine, you may not want to scan all
554 Volumes, so the {\bf update slots} command (as well as the {\bf update slots
555 scan} command) has the additional form:
559 update slots=n1,n2,n3-n4, ...
563 where the keyword {\bf scan} can be appended or not. The n1,n2, ... represent
564 Slot numbers to be updated and the form n3-n4 represents a range of Slot
565 numbers to be updated (e.g. 4-7 will update Slots 4,5,6, and 7).
567 This form is particularly useful if you want to do a scan (time expensive) and
568 restrict the update to one or two slots.
570 For example, the command:
574 update slots=1,6 scan
578 will cause Bacula to load the Volume in Slot 1, read its Volume label and
579 update the Catalog. It will do the same for the Volume in Slot 6. The command:
588 will read the barcoded Volume names for slots 1,2,3 and 6 and make the
589 appropriate updates in the Catalog. If you don't have a barcode reader or have
590 not modified the mtx-changer script as described above, the above command will
591 not find any Volume names so will do nothing.
594 \subsection*{FreeBSD Issues}
595 \index[general]{Issues!FreeBSD }
596 \index[general]{FreeBSD Issues }
597 \addcontentsline{toc}{subsection}{FreeBSD Issues}
599 If you are having problems on FreeBSD when Bacula tries to select a tape, and
600 the message is {\bf Device not configured}, this is because FreeBSD has made
601 the tape device {\bf /dev/nsa1} disappear when there is no tape mounted in the
602 autochanger slot. As a consequence, Bacula is unable to open the device. The
603 solution to the problem is to make sure that some tape is loaded into the tape
604 drive before starting Bacula. This problem is corrected in Bacula versions
608 \ilink{ Tape Testing}{FreeBSDTapes} chapter of this manual for
609 {\bf important} information concerning your tape drive before doing the
611 \label{AutochangerTesting}
613 \subsection*{Testing the Autochanger and Adapting Your mtx-changer Script}
614 \index[general]{Testing the Autochanger and Adapting Your mtx-changer Script }
615 \index[general]{Script!Testing the Autochanger and Adapting Your mtx-changer }
616 \addcontentsline{toc}{subsection}{Testing the Autochanger and Adapting Your
619 Before attempting to use the autochanger with Bacula, it is preferable to
620 "hand-test" that the changer works. To do so, we suggest you do the
621 following commands (assuming that the {\bf mtx-changer} script is installed in
622 {\bf /etc/bacula/mtx-changer}):
626 \item [Make sure Bacula is not running.]
627 \index[sd]{Make sure Bacula is not running. }
629 \item [/etc/bacula/mtx-changer \ /dev/sg0 \ list \ 0 \ /dev/nst0 \ 0]
630 \index[sd]{/etc/bacula/mtx-changer \ /dev/sg0 \ list \ 0 \ /dev/nst0 \ 0
632 This command should print:
644 or one number per line for each slot that is occupied in your changer, and
645 the number should be terminated by a colon ({\bf :}). If your changer has
646 barcodes, the barcode will follow the colon. If an error message is printed,
647 you must resolve the problem (e.g. try a different SCSI control device name
648 if {\bf /dev/sg0} is incorrect. For example, on FreeBSD systems, the
649 autochanger SCSI control device is generally {\bf /dev/pass2}.
651 \item [/etc/bacula/mtx-changer \ /dev/sg0 \ slots \ 0 \ /dev/nst0 \ 0]
652 \index[sd]{/etc/bacula/mtx-changer \ /dev/sg0 \ slots \ 0 \ /dev/nst0 \ 0
654 This command should return the number of slots in your autochanger.
656 \item [/etc/bacula/mtx-changer \ /dev/sg0 \ unload \ ]
657 \index[sd]{/etc/bacula/mtx-changer \ /dev/sg0 \ unload \ }
658 If a tape is loaded, this should cause it to be unloaded.
660 \item [/etc/bacula/mtx-changer \ /dev/sg0 \ load \ 3 \ /dev/nst0 \ 0 ]
661 \index[sd]{/etc/bacula/mtx-changer \ /dev/sg0 \ load \ 3 \ /dev/nst0 \ 0
663 Assuming you have a tape in slot 3, it will be loaded into the read slot (0).
666 \item [/etc/bacula/mtx-changer \ /dev/sg0 \ loaded \ 0 \ /dev/nst0 \ 0]
667 \index[sd]{/etc/bacula/mtx-changer \ /dev/sg0 \ loaded \ 0 \ /dev/nst0 \
671 \item [/etc/bacula/mtx-changer \ /dev/sg0 \ unload]
672 \index[sd]{/etc/bacula/mtx-changer \ /dev/sg0 \ unload }
675 Once all the above commands work correctly, assuming that you have the right
676 {\bf Changer Command} in your configuration, Bacula should be able to operate
677 the changer. The only remaining area of problems will be if your autoloader
678 needs some time to get the tape loaded after issuing the command. After the
679 {\bf mtx-changer} script returns, Bacula will immediately rewind and read the
680 tape. If Bacula gets rewind I/O errors after a tape change, you will probably
681 need to insert a {\bf sleep 20} after the {\bf mtx} command, but be careful to
682 exit the script with a zero status by adding {\bf exit 0} after any additional
683 commands you add to the script. This is because Bacula checks the return
684 status of the script, which should be zero if all went well.
686 You can test whether or not you need a {\bf sleep} by putting the following
687 commands into a file and running it as a script:
692 /etc/bacula/mtx-changer /dev/sg0 unload
693 /etc/bacula/mtx-changer /dev/sg0 load 3
694 mt -f /dev/st0 rewind
699 If the above script runs, you probably have no timing problems. If it does not
700 run, start by putting a {\bf sleep 30} or possibly a {\bf sleep 60} in the
701 script just after the mtx-changer load command. If that works, then you should
702 move the sleep into the actual {\bf mtx-changer} script so that it will be
703 effective when Bacula runs.
705 A second problem that comes up with a small number of autochangers is that
706 they need to have the cartridge ejected before it can be removed. If this is
707 the case, the {\bf load 3} will never succeed regardless of how long you wait.
708 If this seems to be your problem, you can insert an eject just after the
709 unload so that the script looks like:
714 /etc/bacula/mtx-changer /dev/sg0 unload
715 mt -f /dev/st0 offline
716 /etc/bacula/mtx-changer /dev/sg0 load 3
717 mt -f /dev/st0 rewind
722 Obviously, if you need the {\bf offline} command, you should move it into the
723 mtx-changer script ensuring that you save the status of the {\bf mtx} command
724 or always force an {\bf exit 0} from the script, because Bacula checks the
725 return status of the script.
727 As noted earlier, there are several scripts in {\bf
728 \lt{}bacula-source\gt{}/examples/devices} that implement the above features,
729 so they may be a help to you in getting your script to work.
731 If Bacula complains "Rewind error on /dev/nst0. ERR=Input/output error." you
732 most likely need more sleep time in your {\bf mtx-changer} before returning to
733 Bacula after a load command has been completed.
737 \subsection*{Using the Autochanger}
738 \index[general]{Using the Autochanger }
739 \index[general]{Autochanger!Using the }
740 \addcontentsline{toc}{subsection}{Using the Autochanger}
742 Let's assume that you have properly defined the necessary Storage daemon
743 Device records, and you have added the {\bf Autochanger = yes} record to the
744 Storage resource in your Director's configuration file.
746 Now you fill your autochanger with say six blank tapes.
748 What do you do to make Bacula access those tapes?
750 One strategy is to prelabel each of the tapes. Do so by starting Bacula, then
751 with the Console program, enter the {\bf label} command:
756 Connecting to Director rufus:8101
757 1000 OK: rufus-dir Version: 1.26 (4 October 2002)
762 it will then print something like:
766 Using default Catalog name=BackupDB DB=bacula
767 The defined Storage resources are:
770 Select Storage resource (1-2): 1
774 I select the autochanger (1), and it prints:
778 Enter new Volume name: TestVolume1
779 Enter slot (0 for none): 1
783 where I entered {\bf TestVolume1} for the tape name, and slot {\bf 1} for the
791 Select the Pool (1-2): 1
795 I select the Default pool. This will be automatically done if you only have a
796 single pool, then Bacula will proceed to unload any loaded volume, load the
797 volume in slot 1 and label it. In this example, nothing was in the drive, so
802 Connecting to Storage daemon Autochanger at localhost:9103 ...
803 Sending label command ...
804 3903 Issuing autochanger "load slot 1" command.
805 3000 OK label. Volume=TestVolume1 Device=/dev/nst0
806 Media record for Volume=TestVolume1 successfully created.
807 Requesting mount Autochanger ...
808 3001 Device /dev/nst0 is mounted with Volume TestVolume1
814 You may then proceed to label the other volumes. The messages will change
815 slightly because Bacula will unload the volume (just labeled TestVolume1)
816 before loading the next volume to be labeled.
818 Once all your Volumes are labeled, Bacula will automatically load them as they
821 To "see" how you have labeled your Volumes, simply enter the {\bf list
822 volumes} command from the Console program, which should print something like
828 Using default Catalog name=BackupDB DB=bacula
832 Select the Pool (1-2): 1
833 +-------+----------+--------+---------+-------+--------+----------+-------+------+
834 | MedId | VolName | MedTyp | VolStat | Bites | LstWrt | VolReten | Recyc | Slot |
835 +-------+----------+--------+---------+-------+--------+----------+-------+------+
836 | 1 | TestVol1 | DDS-4 | Append | 0 | 0 | 30672000 | 0 | 1 |
837 | 2 | TestVol2 | DDS-4 | Append | 0 | 0 | 30672000 | 0 | 2 |
838 | 3 | TestVol3 | DDS-4 | Append | 0 | 0 | 30672000 | 0 | 3 |
840 +-------+----------+--------+---------+-------+--------+----------+-------+------+
846 \subsection*{Barcode Support}
847 \index[general]{Support!Barcode }
848 \index[general]{Barcode Support }
849 \addcontentsline{toc}{subsection}{Barcode Support}
851 Bacula provides barcode support with two Console commands, {\bf label
852 barcodes} and {\bf update slots}.
854 The {\bf label barcodes} will cause Bacula to read the barcodes of all the
855 cassettes that are currently installed in the magazine (cassette holder) using
856 the {\bf mtx-changer} {\bf list} command. Each cassette is mounted in turn and
857 labeled with the same Volume name as the barcode.
859 The {\bf update slots} command will first obtain the list of cassettes and
860 their barcodes from {\bf mtx-changer}. Then it will find each volume in turn
861 in the catalog database corresponding to the barcodes and set its Slot to
862 correspond to the value just read. If the Volume is not in the catalog, then
863 nothing will be done. This command is useful for synchronizing Bacula with the
864 current magazine in case you have changed magazines or in case you have moved
865 cassettes from one slot to another.
867 The {\bf Cleaning Prefix} statement can be used in the Pool resource to define
868 a Volume name prefix, which if it matches that of the Volume (barcode) will
869 cause that Volume to be marked with a VolStatus of {\bf Cleaning}. This will
870 prevent Bacula from attempting to write on the Volume.
874 \subsection*{Bacula Autochanger Interface}
875 \index[general]{Interface!Bacula Autochanger }
876 \index[general]{Bacula Autochanger Interface }
877 \addcontentsline{toc}{subsection}{Bacula Autochanger Interface}
879 Bacula calls the autochanger script that you specify on the {\bf Changer
880 Device} statement. Normally this script will be the {\bf mtx-changer} script
881 that we can provide, but it can in fact be any program. The only requirements
882 are that the "commands" that Bacula uses are {\bf loaded}, {\bf load}, {\bf
883 unload}, {\bf list}, and {\bf slots}. In addition,
884 each of those commands must return the information in the precise format as
889 - Currently the changer commands used are:
890 loaded -- returns number of the slot that is loaded in
891 the drive or 0 if the drive is empty.
892 load -- loads a specified slot (note, some autochangers
893 require a 30 second pause after this command) into
895 unload -- unloads the device (returns cassette to its slot).
896 list -- returns one line for each cassette in the autochanger
897 in the format <slot>:<barcode>. Where
898 the {\bf slot} is the non-zero integer representing
899 the slot number, and {\bf barcode} is the barcode
900 associated with the cassette if it exists and if you
901 autoloader supports barcodes. Otherwise the barcode
903 slots -- returns total number of slots in the autochanger.
907 Bacula checks the exit status of the program called, and if it is zero, the
908 data is accepted. If the exit status is non-zero, Bacula ignores any
909 information returned and treats the drive as if it is not an autochanger.