4 \chapter{Autochanger Unterst\"{u}tzung}
5 \label{AutochangersChapter}
6 \index[general]{Unterst\"{u}tzung!Autochanger }
7 \index[general]{Autochanger Unterst\"{u}tzung }
9 Bacula unterst\"{u}tzt Autochanger zum Lesen und Schreiben von Tapes.
10 Damit Bacula mit einem Autochanger arbeiten kann, muss eine Nummer von
11 Voraussetzungen erf\"{u}llt sein, die Details werden im folgenden gekl\"{a}rt.
14 \item Ein Script das den Autochanger, gem\"{a}{\ss} den von Bacula gesendeten Kommandos, steuert.
15 Bacula stellt solch ein Script in der {\bf depkgs} Distribution zur Verf\"{u}gung.
16 ==obsolete== This script works only with single drive autochangers.
18 \item Jedes Volume (Tape) das benutzt wird, muss sowohl im Katalog definiert sein,
19 als auch eine Slotnummer zugeteilt sein, nur so kann Bacula wissen, welches Volume
20 aktuell im Autochanger verf\"{u}gbar ist.
21 Normalerweise wird das mittels des {\bf label} Kommandos erreicht,
22 weiter unten wird genauer darauf eingegangen.
23 Volumes m\"{u}ssen manuell gelabelt werden, bevor sie benutzt werden k\"{o}nnen.
25 \item Die Konfigurationsdateien des Storage-Dienstes m\"{u}ssen angepasst werden,
26 damit Device-Eintr\"{a}ge Autochangern zugeordnet werden k\"{o}nnen,
27 sowie einige Parameter mehr.
29 \item Sie sollten auch die Storage-Definitionen in der Director-Dienst-Konfiguration anpassen,
30 so dass automatisch nachgefragt wird, welcher Slot genutzt werden soll, wenn ein Volume gelabelt wird.
32 \item Sie m\"{u}ssen sicherstellen, dass der Storage-Dienst (wenn er nicht als root ausgef\"{u}hrt wird)
33 Zugriffsrechte auf die Laufwerks- und auf das Autochanger-Kontroll-Device hat.
35 \item Sie m\"{u}ssen {\bf Autochanger = yes} in der Storage-Definitionen des Director-Dienstes setzen,
36 damit nach dem Slot gefragt wird wenn Sie Volumes labeln.
39 In version 1.37 und sp\"{a}ter, gibt es eine neue \ilink{Autochanger-Konfiguration}{AutochangerRes}
40 die erlaubt, bestimmte Device-Eintr\"{a}ge zu gruppieren um einen Autochanger mit mehrfachen Laufwerken
43 In version 1.37 and later, there is a new \ilink{Autochanger
44 resource}{AutochangerRes} that permits you to group Device resources thus
45 creating a multi-drive autochanger. If you have an autochanger,
46 you must use this new resource.
48 Bacula uses its own {\bf mtx-changer} script to interface with a program
49 that actually does the tape changing. Thus in principle, {\bf mtx-changer}
50 can be adapted to function with any autochanger program, or you can
51 call any other script or program. The current
52 version of {\bf mtx-changer} works with the {\bf mtx} program. However,
53 FreeBSD users have provided a script in the {\bf examples/autochangers}
54 directory that allows Bacula to use the {\bf chio} program.
56 Bacula also supports autochangers with barcode
57 readers. This support includes two Console commands: {\bf label barcodes}
58 and {\bf update slots}. For more details on these commands, see the "Barcode
59 Support" section below.
61 Current Bacula autochanger support does not include cleaning, stackers, or
62 silos. However, under certain conditions, you may be able to make Bacula
63 work with stackers (gravity feed and such). Support for multi-drive
64 autochangers requires the \ilink{Autochanger resource}{AutochangerRes}
65 introduced in version 1.37. This resource is also recommended for single
68 In principle, if {\bf mtx} will operate your changer correctly, then it is
69 just a question of adapting the {\bf mtx-changer} script (or selecting one
70 already adapted) for proper interfacing. You can find a list of autochangers
71 supported by {\bf mtx} at the following link:
72 \elink{http://mtx.opensource-sw.net/compatibility.php}
73 {http://mtx.opensource-sw.net/compatibility.php}.
74 The home page for the {\bf mtx} project can be found at:
75 \elink{http://mtx.opensource-sw.net/}{http://mtx.opensource-sw.net/}.
77 If you are having troubles, please use the {\bf auto} command in the {\bf
78 btape} program to test the functioning of your autochanger with Bacula. When
79 Bacula is running, please remember that for many distributions (e.g. FreeBSD,
80 Debian, ...) the Storage daemon runs as {\bf bacula.tape} rather than {\bf
81 root.root}, so you will need to ensure that the Storage daemon has sufficient
82 permissions to access the autochanger.
85 \section{Knowing What SCSI Devices You Have}
86 \index[general]{Have!Knowing What SCSI Devices You }
87 \index[general]{Knowing What SCSI Devices You Have }
88 \index[general]{SCSI devices}
89 \index[general]{devices!SCSI}
99 to see what SCSI devices you have available. You can also:
103 cat /proc/scsi/sg/device_hdr /proc/scsi/sg/devices
107 to find out how to specify their control address ({\bf /dev/sg0} for the
108 first, {\bf /dev/sg1} for the second, ...) on the {\bf Changer Device = }
111 For more detailed information on what SCSI devices you have please see
112 the \ilink{Linux SCSI Tricks}{SCSITricks} section of the Tape Testing
113 chapter of this manual.
115 Under FreeBSD, you can use:
123 To list the SCSI devices as well as the {\bf /dev/passn} that you will use on
124 the Bacula {\bf Changer Device = } directive.
126 Please check that your Storage daemon has permission to access this
129 The following tip for FreeBSD users comes from Danny Butroyd:
130 on reboot Bacula will NOT have permission to
131 control the device /dev/pass0 (assuming this is your changer device).
132 To get around this just edit the /etc/devfs.conf file and add the
133 following to the bottom:
136 own pass0 root:bacula
138 own nsa0.0 root:bacula
143 This gives the bacula group permission to write to the nsa0.0 device
144 too just to be on the safe side. To bring these changes into effect
147 /etc/rc.d/devfs restart
149 Basically this will stop you having to manually change permissions on these
150 devices to make Bacula work when operating the AutoChanger after a reboot.
153 \section{Example Scripts}
154 \index[general]{Scripts!Example }
155 \index[general]{Example Scripts }
157 Please read the sections below so that you understand how autochangers work
158 with Bacula. Although we supply a default {\bf mtx-changer} script, your
159 autochanger may require some additional changes. If you want to see examples
160 of configuration files and scripts, please look in the {\bf
161 \lt{}bacula-src\gt{}/examples/devices} directory where you will find an
162 example {\bf HP-autoloader.conf} Bacula Device resource, and several {\bf
163 mtx-changer} scripts that have been modified to work with different
169 \index[general]{Slots }
171 To properly address autochangers, Bacula must know which Volume is in each
172 {\bf slot} of the autochanger. Slots are where the changer cartridges reside
173 when not loaded into the drive. Bacula numbers these slots from one to the
174 number of cartridges contained in the autochanger.
176 Bacula will not automatically use a Volume in your autochanger unless it is
177 labeled and the slot number is stored in the catalog and the Volume is marked
178 as InChanger. For each Volume in your
179 changer, you will, using the Console program, assign a slot. This information
180 is kept in {\bf Bacula's} catalog database along with the other data for the
181 volume. If no slot is given, or the slot is set to zero, Bacula will not
182 attempt to use the autochanger even if all the necessary configuration records
183 are present. In addition, the console {\bf mount} command does not cause
184 Bacula to operate the autochanger, it only tells Bacula to read any tape that
187 You can check if the Slot number and InChanger flag are set by doing a:
192 in the Console program.
195 \section{Multiple Devices}
196 \index[general]{Devices!Multiple}
197 \index[general]{Multiple Devices}
199 Some autochangers have more than one read/write device (drive). The
200 new \ilink{Autochanger resource}{AutochangerRes} introduced in version
201 1.37 permits you to group Device resources, where each device
202 represents a drive. The Director may still reference the Devices (drives)
203 directly, but doing so, bypasses the proper functioning of the
204 drives together. Instead, the Director (in the Storage resource)
205 should reference the Autochanger resource name. Doing so permits
206 the Storage daemon to ensure that only one drive uses the mtx-changer
207 script at a time, and also that two drives don't reference the
210 Multi-drive requires the use of the {\bf
211 Drive Index} directive in the Device resource of the Storage daemon's
212 configuration file. Drive numbers or the Device Index are numbered beginning
213 at zero, which is the default. To use the second Drive in an autochanger, you
214 need to define a second Device resource and set the Drive Index to 1 for
215 that device. In general, the second device will have the same {\bf Changer
216 Device} (control channel) as the first drive, but a different {\bf Archive
219 As a default, Bacula jobs will prefer to write to a Volume that is
220 already mounted. If you have a multiple drive autochanger and you want
221 Bacula to write to more than one Volume in the same Pool at the same
222 time, you will need to set \ilink{Prefer Mounted Volumes} {PreferMountedVolumes}
223 in the Directors Job resource to {\bf no}. This will cause
224 the Storage daemon to maximize the use of drives.
227 \label{ConfigRecords}
228 \section{Device Configuration Records}
229 \index[general]{Records!Device Configuration }
230 \index[general]{Device Configuration Records }
232 Configuration of autochangers within Bacula is done in the Device resource of
233 the Storage daemon. Four records: {\bf Autochanger}, {\bf Changer Device},
234 {\bf Changer Command}, and {\bf Maximum Changer Wait} control how Bacula uses
237 These four records, permitted in {\bf Device} resources, are described in
238 detail below. Note, however, that the {\bf Changer Device} and the
239 {\bf Changer Command} directives are not needed in the Device resource
240 if they are present in the {\bf Autochanger} resource.
244 \item [Autochanger = {\it Yes|No} ]
245 \index[sd]{Autochanger }
246 The {\bf Autochanger} record specifies that the current device is or is not
247 an autochanger. The default is {\bf no}.
249 \item [Changer Device = \lt{}device-name\gt{}]
250 \index[sd]{Changer Device }
251 In addition to the Archive Device name, you must specify a {\bf Changer
252 Device} name. This is because most autochangers are controlled through a
253 different device than is used for reading and writing the cartridges. For
254 example, on Linux, one normally uses the generic SCSI interface for
255 controlling the autochanger, but the standard SCSI interface for reading and
256 writing the tapes. On Linux, for the {\bf Archive Device = /dev/nst0}, you
257 would typically have {\bf Changer Device = /dev/sg0}. Note, some of the more
258 advanced autochangers will locate the changer device on {\bf /dev/sg1}. Such
259 devices typically have several drives and a large number of tapes.
261 On FreeBSD systems, the changer device will typically be on {\bf /dev/pass0}
262 through {\bf /dev/passn}.
264 On Solaris, the changer device will typically be some file under {\bf
267 Please ensure that your Storage daemon has permission to access this
270 \item [Changer Command = \lt{}command\gt{}]
271 \index[sd]{Changer Command }
272 This record is used to specify the external program to call and what
273 arguments to pass to it. The command is assumed to be a standard program or
274 shell script that can be executed by the operating system. This command is
275 invoked each time that Bacula wishes to manipulate the autochanger. The
276 following substitutions are made in the {\bf command} before it is sent to
277 the operating system for execution:
282 %a = archive device name
283 %c = changer device name
284 %d = changer drive index base 0
287 %o = command (loaded, load, or unload)
294 An actual example for using {\bf mtx} with the {\bf mtx-changer} script (part
295 of the Bacula distribution) is:
299 Changer Command = "/etc/bacula/mtx-changer %c %o %S %a %d"
303 Where you will need to adapt the {\bf /etc/bacula} to be the actual path on
304 your system where the mtx-changer script resides. Details of the three
305 commands currently used by Bacula (loaded, load, unload) as well as the
306 output expected by Bacula are give in the {\bf Bacula Autochanger Interface}
309 \item [Maximum Changer Wait = \lt{}time\gt{}]
310 \index[sd]{Maximum Changer Wait }
311 This record is used to define the maximum amount of time that Bacula
312 will wait for an autoloader to respond to a command (e.g. load). The
313 default is set to 120 seconds. If you have a slow autoloader you may
314 want to set it longer.
316 If the autoloader program fails to respond in this time, it will be killed
317 and Bacula will request operator intervention.
319 \item [Drive Index = \lt{}number\gt{}]
320 \index[sd]{Drive Index }
321 This record allows you to tell Bacula to use the second or subsequent
322 drive in an autochanger with multiple drives. Since the drives are
323 numbered from zero, the second drive is defined by
332 To use the second drive, you need a second Device resource definition in the
333 Bacula configuration file. See the Multiple Drive section above in this
334 chapter for more information.
337 In addition, for proper functioning of the Autochanger, you must
338 define an Autochanger resource.
339 \input{autochangerres}
342 \section{An Example Configuration File}
343 \index[general]{Example Configuration File }
344 \index[general]{File!Example Configuration }
346 The following two resources implement an autochanger:
353 Changer Device = /dev/sg0
354 Changer Command = "/etc/bacula/mtx-changer %c %o %S %a %d"
360 Archive Device = /dev/nst0 # Normal archive device
363 AutomaticMount = yes;
369 where you will adapt the {\bf Archive Device}, the {\bf Changer Device}, and
370 the path to the {\bf Changer Command} to correspond to the values used on your
373 \section{A Multi-drive Example Configuration File}
374 \index[general]{Multi-drive Example Configuration File }
376 The following resources implement a multi-drive autochanger:
382 Device = Drive-1, Drive-2
383 Changer Device = /dev/sg0
384 Changer Command = "/etc/bacula/mtx-changer %c %o %S %a %d"
391 Archive Device = /dev/nst0 # Normal archive device
394 AutomaticMount = yes;
402 Archive Device = /dev/nst1 # Normal archive device
405 AutomaticMount = yes;
412 where you will adapt the {\bf Archive Device}, the {\bf Changer Device}, and
413 the path to the {\bf Changer Command} to correspond to the values used on your
416 \label{SpecifyingSlots}
417 \section{Specifying Slots When Labeling}
418 \index[general]{Specifying Slots When Labeling }
419 \index[general]{Labeling!Specifying Slots When }
421 If you add an {\bf Autochanger = yes} record to the Storage resource in your
422 Director's configuration file, the Bacula Console will automatically prompt
423 you for the slot number when the Volume is in the changer when
424 you {\bf add} or {\bf label} tapes for that Storage device. If your
425 {\bf mtx-changer} script is properly installed, Bacula will automatically
426 load the correct tape during the label command.
429 {\bf Autochanger = yes} in the Storage daemon's Device resource
430 as we have described above in
431 order for the autochanger to be used. Please see the
432 \ilink{Storage Resource}{Autochanger1} in the Director's chapter
434 \ilink{Device Resource}{Autochanger} in the Storage daemon
435 chapter for more details on these records.
437 Thus all stages of dealing with tapes can be totally automated. It is also
438 possible to set or change the Slot using the {\bf update} command in the
439 Console and selecting {\bf Volume Parameters} to update.
441 Even though all the above configuration statements are specified and correct,
442 Bacula will attempt to access the autochanger only if a {\bf slot} is non-zero
443 in the catalog Volume record (with the Volume name).
445 If your autochanger has barcode labels, you can label all the Volumes in
446 your autochanger one after another by using the {\bf label barcodes} command.
447 For each tape in the changer containing a barcode, Bacula will mount the tape
448 and then label it with the same name as the barcode. An appropriate Media
449 record will also be created in the catalog. Any barcode that begins with the
450 same characters as specified on the "CleaningPrefix=xxx" command, will be
451 treated as a cleaning tape, and will not be labeled. For example with:
453 Please note that Volumes must be pre-labeled to be automatically used in
454 the autochanger during a backup. If you do not have a barcode reader, this
455 is done manually (or via a script).
461 Cleaning Prefix = "CLN"
466 Any slot containing a barcode of CLNxxxx will be treated as a cleaning tape
467 and will not be mounted.
469 \section{Changing Cartridges}
470 \index[general]{Changing Cartridges }
471 If you wish to insert or remove cartridges in your autochanger or
472 you manually run the {\bf mtx} program, you must first tell Bacula
473 to release the autochanger by doing:
478 (change cartridges and/or run mtx)
483 If you do not do the unmount before making such a change, Bacula
484 will become completely confused about what is in the autochanger
485 and may stop function because it expects to have exclusive use
486 of the autochanger while it has the drive mounted.
490 \section{Dealing with Multiple Magazines}
491 \index[general]{Dealing with Multiple Magazines }
492 \index[general]{Magazines!Dealing with Multiple }
494 If you have several magazines or if you insert or remove cartridges from a
495 magazine, you should notify Bacula of this. By doing so, Bacula will as
496 a preference, use Volumes that it knows to be in the autochanger before
497 accessing Volumes that are not in the autochanger. This prevents unneeded
498 operator intervention.
500 If your autochanger has barcodes (machine readable tape labels), the task of
501 informing Bacula is simple. Every time, you change a magazine, or add or
502 remove a cartridge from the magazine, simply do
508 (insert new magazine)
514 in the Console program. This will cause Bacula to request the autochanger to
515 return the current Volume names in the magazine. This will be done without
516 actually accessing or reading the Volumes because the barcode reader does this
517 during inventory when the autochanger is first turned on. Bacula will ensure
518 that any Volumes that are currently marked as being in the magazine are marked
519 as no longer in the magazine, and the new list of Volumes will be marked as
520 being in the magazine. In addition, the Slot numbers of the Volumes will be
521 corrected in Bacula's catalog if they are incorrect (added or moved).
523 If you do not have a barcode reader on your autochanger, you have several
527 \item You can manually set the Slot and InChanger flag using the {\bf update
528 volume} command in the Console (quite painful).
530 \item You can issue a
538 command that will cause Bacula to read the label on each of the cartridges in
539 the magazine in turn and update the information (Slot, InChanger flag) in the
540 catalog. This is quite effective but does take time to load each cartridge
541 into the drive in turn and read the Volume label.
543 \item You can modify the mtx-changer script so that it simulates an
544 autochanger with barcodes. See below for more details.
548 \section{Simulating Barcodes in your Autochanger}
549 \index[general]{Autochanger!Simulating Barcodes in your }
550 \index[general]{Simulating Barcodes in your Autochanger }
552 You can simulate barcodes in your autochanger by making the {\bf mtx-changer}
553 script return the same information that an autochanger with barcodes would do.
554 This is done by commenting out the one and only line in the {\bf list)} case,
559 ${MTX} -f $ctl status | grep " *Storage Element [0-9]*:.*Full" | awk "{print \$3 \$4}" | sed "s/Full *\(:VolumeTag=\)*//"
563 at approximately line 99 by putting a \# in column one of that line, or by
564 simply deleting it. Then in its place add a new line that prints the contents
565 of a file. For example:
569 cat /etc/bacula/changer.volumes
573 Be sure to include a full path to the file, which can have any name. The
574 contents of the file must be of the following format:
585 Where the 1, 2, 3 are the slot numbers and Volume1, Volume2, ... are the
586 Volume names in those slots. You can have multiple files that represent the
587 Volumes in different magazines, and when you change magazines, simply copy the
588 contents of the correct file into your {\bf /etc/bacula/changer.volumes} file.
589 There is no need to stop and start Bacula when you change magazines, simply
590 put the correct data in the file, then run the {\bf update slots} command, and
591 your autochanger will appear to Bacula to be an autochanger with barcodes.
594 \section{The Full Form of the Update Slots Command}
595 \index[general]{Full Form of the Update Slots Command }
596 \index[general]{Command!Full Form of the Update Slots }
598 If you change only one cartridge in the magazine, you may not want to scan all
599 Volumes, so the {\bf update slots} command (as well as the {\bf update slots
600 scan} command) has the additional form:
604 update slots=n1,n2,n3-n4, ...
608 where the keyword {\bf scan} can be appended or not. The n1,n2, ... represent
609 Slot numbers to be updated and the form n3-n4 represents a range of Slot
610 numbers to be updated (e.g. 4-7 will update Slots 4,5,6, and 7).
612 This form is particularly useful if you want to do a scan (time expensive) and
613 restrict the update to one or two slots.
615 For example, the command:
619 update slots=1,6 scan
623 will cause Bacula to load the Volume in Slot 1, read its Volume label and
624 update the Catalog. It will do the same for the Volume in Slot 6. The command:
633 will read the barcoded Volume names for slots 1,2,3 and 6 and make the
634 appropriate updates in the Catalog. If you don't have a barcode reader or have
635 not modified the mtx-changer script as described above, the above command will
636 not find any Volume names so will do nothing.
639 \section{FreeBSD Issues}
640 \index[general]{Issues!FreeBSD }
641 \index[general]{FreeBSD Issues }
643 If you are having problems on FreeBSD when Bacula tries to select a tape, and
644 the message is {\bf Device not configured}, this is because FreeBSD has made
645 the tape device {\bf /dev/nsa1} disappear when there is no tape mounted in the
646 autochanger slot. As a consequence, Bacula is unable to open the device. The
647 solution to the problem is to make sure that some tape is loaded into the tape
648 drive before starting Bacula. This problem is corrected in Bacula versions
652 \ilink{ Tape Testing}{FreeBSDTapes} chapter of this manual for
653 {\bf important} information concerning your tape drive before doing the
655 \label{AutochangerTesting}
657 \section{Testing Autochanger and Adapting mtx-changer script}
658 \index[general]{Testing the Autochanger }
659 \index[general]{Adapting Your mtx-changer script}
662 Before attempting to use the autochanger with Bacula, it is preferable to
663 "hand-test" that the changer works. To do so, we suggest you do the
664 following commands (assuming that the {\bf mtx-changer} script is installed in
665 {\bf /etc/bacula/mtx-changer}):
669 \item [Make sure Bacula is not running.]
671 \item [/etc/bacula/mtx-changer \ /dev/sg0 \ list \ 0 \ /dev/nst0 \ 0]
672 \index[sd]{mtx-changer list}
674 This command should print:
686 or one number per line for each slot that is occupied in your changer, and
687 the number should be terminated by a colon ({\bf :}). If your changer has
688 barcodes, the barcode will follow the colon. If an error message is printed,
689 you must resolve the problem (e.g. try a different SCSI control device name
690 if {\bf /dev/sg0} is incorrect. For example, on FreeBSD systems, the
691 autochanger SCSI control device is generally {\bf /dev/pass2}.
693 \item [/etc/bacula/mtx-changer \ /dev/sg0 \ slots ]
694 \index[sd]{mtx-changer slots}
696 This command should return the number of slots in your autochanger.
698 \item [/etc/bacula/mtx-changer \ /dev/sg0 \ unload \ 1 \ /dev/nst0 \ 0 ]
699 \index[sd]{mtx-changer unload}
701 If a tape is loaded from slot 1, this should cause it to be unloaded.
703 \item [/etc/bacula/mtx-changer \ /dev/sg0 \ load \ 3 \ /dev/nst0 \ 0 ]
704 \index[sd]{mtx-changer load}
706 Assuming you have a tape in slot 3, it will be loaded into drive (0).
709 \item [/etc/bacula/mtx-changer \ /dev/sg0 \ loaded \ 0 \ /dev/nst0 \ 0]
710 \index[sd]{mtx-changer loaded}
713 Note, we have used an "illegal" slot number 0. In this case, it is simply
714 ignored because the slot number is not used. However, it must be specified
715 because the drive parameter at the end of the command is needed to select
718 \item [/etc/bacula/mtx-changer \ /dev/sg0 \ unload \ 3 /dev/nst0 \ 0]
720 will unload the tape into slot 3.
724 Once all the above commands work correctly, assuming that you have the right
725 {\bf Changer Command} in your configuration, Bacula should be able to operate
726 the changer. The only remaining area of problems will be if your autoloader
727 needs some time to get the tape loaded after issuing the command. After the
728 {\bf mtx-changer} script returns, Bacula will immediately rewind and read the
729 tape. If Bacula gets rewind I/O errors after a tape change, you will probably
730 need to insert a {\bf sleep 20} after the {\bf mtx} command, but be careful to
731 exit the script with a zero status by adding {\bf exit 0} after any additional
732 commands you add to the script. This is because Bacula checks the return
733 status of the script, which should be zero if all went well.
735 You can test whether or not you need a {\bf sleep} by putting the following
736 commands into a file and running it as a script:
741 /etc/bacula/mtx-changer /dev/sg0 unload 1 /dev/nst0 0
742 /etc/bacula/mtx-changer /dev/sg0 load 3 /dev/nst0 0
743 mt -f /dev/st0 rewind
748 If the above script runs, you probably have no timing problems. If it does not
749 run, start by putting a {\bf sleep 30} or possibly a {\bf sleep 60} in the
750 script just after the mtx-changer load command. If that works, then you should
751 move the sleep into the actual {\bf mtx-changer} script so that it will be
752 effective when Bacula runs.
754 A second problem that comes up with a small number of autochangers is that
755 they need to have the cartridge ejected before it can be removed. If this is
756 the case, the {\bf load 3} will never succeed regardless of how long you wait.
757 If this seems to be your problem, you can insert an eject just after the
758 unload so that the script looks like:
763 /etc/bacula/mtx-changer /dev/sg0 unload 1 /dev/nst0 0
764 mt -f /dev/st0 offline
765 /etc/bacula/mtx-changer /dev/sg0 load 3 /dev/nst0 0
766 mt -f /dev/st0 rewind
771 Obviously, if you need the {\bf offline} command, you should move it into the
772 mtx-changer script ensuring that you save the status of the {\bf mtx} command
773 or always force an {\bf exit 0} from the script, because Bacula checks the
774 return status of the script.
776 As noted earlier, there are several scripts in {\bf
777 \lt{}bacula-source\gt{}/examples/devices} that implement the above features,
778 so they may be a help to you in getting your script to work.
780 If Bacula complains "Rewind error on /dev/nst0. ERR=Input/output error." you
781 most likely need more sleep time in your {\bf mtx-changer} before returning to
782 Bacula after a load command has been completed.
786 \section{Using the Autochanger}
787 \index[general]{Using the Autochanger }
788 \index[general]{Autochanger!Using the }
790 Let's assume that you have properly defined the necessary Storage daemon
791 Device records, and you have added the {\bf Autochanger = yes} record to the
792 Storage resource in your Director's configuration file.
794 Now you fill your autochanger with say six blank tapes.
796 What do you do to make Bacula access those tapes?
798 One strategy is to prelabel each of the tapes. Do so by starting Bacula, then
799 with the Console program, enter the {\bf label} command:
804 Connecting to Director rufus:8101
805 1000 OK: rufus-dir Version: 1.26 (4 October 2002)
810 it will then print something like:
814 Using default Catalog name=BackupDB DB=bacula
815 The defined Storage resources are:
818 Select Storage resource (1-2): 1
822 I select the autochanger (1), and it prints:
826 Enter new Volume name: TestVolume1
827 Enter slot (0 for none): 1
831 where I entered {\bf TestVolume1} for the tape name, and slot {\bf 1} for the
839 Select the Pool (1-2): 1
843 I select the Default pool. This will be automatically done if you only have a
844 single pool, then Bacula will proceed to unload any loaded volume, load the
845 volume in slot 1 and label it. In this example, nothing was in the drive, so
850 Connecting to Storage daemon Autochanger at localhost:9103 ...
851 Sending label command ...
852 3903 Issuing autochanger "load slot 1" command.
853 3000 OK label. Volume=TestVolume1 Device=/dev/nst0
854 Media record for Volume=TestVolume1 successfully created.
855 Requesting mount Autochanger ...
856 3001 Device /dev/nst0 is mounted with Volume TestVolume1
862 You may then proceed to label the other volumes. The messages will change
863 slightly because Bacula will unload the volume (just labeled TestVolume1)
864 before loading the next volume to be labeled.
866 Once all your Volumes are labeled, Bacula will automatically load them as they
869 To "see" how you have labeled your Volumes, simply enter the {\bf list
870 volumes} command from the Console program, which should print something like
876 Using default Catalog name=BackupDB DB=bacula
880 Select the Pool (1-2): 1
881 +-------+----------+--------+---------+-------+--------+----------+-------+------+
882 | MedId | VolName | MedTyp | VolStat | Bites | LstWrt | VolReten | Recyc | Slot |
883 +-------+----------+--------+---------+-------+--------+----------+-------+------+
884 | 1 | TestVol1 | DDS-4 | Append | 0 | 0 | 30672000 | 0 | 1 |
885 | 2 | TestVol2 | DDS-4 | Append | 0 | 0 | 30672000 | 0 | 2 |
886 | 3 | TestVol3 | DDS-4 | Append | 0 | 0 | 30672000 | 0 | 3 |
888 +-------+----------+--------+---------+-------+--------+----------+-------+------+
894 \section{Barcode Support}
895 \index[general]{Support!Barcode }
896 \index[general]{Barcode Support }
898 Bacula provides barcode support with two Console commands, {\bf label
899 barcodes} and {\bf update slots}.
901 The {\bf label barcodes} will cause Bacula to read the barcodes of all the
902 cassettes that are currently installed in the magazine (cassette holder) using
903 the {\bf mtx-changer} {\bf list} command. Each cassette is mounted in turn and
904 labeled with the same Volume name as the barcode.
906 The {\bf update slots} command will first obtain the list of cassettes and
907 their barcodes from {\bf mtx-changer}. Then it will find each volume in turn
908 in the catalog database corresponding to the barcodes and set its Slot to
909 correspond to the value just read. If the Volume is not in the catalog, then
910 nothing will be done. This command is useful for synchronizing Bacula with the
911 current magazine in case you have changed magazines or in case you have moved
912 cassettes from one slot to another.
914 The {\bf Cleaning Prefix} statement can be used in the Pool resource to define
915 a Volume name prefix, which if it matches that of the Volume (barcode) will
916 cause that Volume to be marked with a VolStatus of {\bf Cleaning}. This will
917 prevent Bacula from attempting to write on the Volume.
921 \section{Bacula Autochanger Interface}
922 \index[general]{Interface!Bacula Autochanger }
923 \index[general]{Bacula Autochanger Interface }
925 Bacula calls the autochanger script that you specify on the {\bf Changer
926 Device} statement. Normally this script will be the {\bf mtx-changer} script
927 that we can provide, but it can in fact be any program. The only requirements
928 are that the "commands" that Bacula uses are {\bf loaded}, {\bf load}, {\bf
929 unload}, {\bf list}, and {\bf slots}. In addition,
930 each of those commands must return the information in the precise format as
935 - Currently the changer commands used are:
936 loaded -- returns number of the slot that is loaded, base 1,
937 in the drive or 0 if the drive is empty.
938 load -- loads a specified slot (note, some autochangers
939 require a 30 second pause after this command) into
941 unload -- unloads the device (returns cassette to its slot).
942 list -- returns one line for each cassette in the autochanger
943 in the format <slot>:<barcode>. Where
944 the {\bf slot} is the non-zero integer representing
945 the slot number, and {\bf barcode} is the barcode
946 associated with the cassette if it exists and if you
947 autoloader supports barcodes. Otherwise the barcode
949 slots -- returns total number of slots in the autochanger.
953 Bacula checks the exit status of the program called, and if it is zero, the
954 data is accepted. If the exit status is non-zero, Bacula ignores any
955 information returned and treats the drive as if it is not an autochanger.