4 \section*{Support des librairies}
5 \label{_ChapterStart18}
6 \index[general]{Support!Librairies}
7 \index[general]{Autochanger Support }
8 \addcontentsline{toc}{section}{Support des librairies}
10 \subsection*{G\'en\'eralit\'es sur les librairies}
11 \index[general]{G\'en\'eralit\'es!Librairies}
12 \index[general]{G\'en\'eralit\'es sur les librairies}
13 \addcontentsline{toc}{subsection}{G\'en\'eralit\'es sur les librairies}
15 Bacula supporte les librairies pour les op\'erations de lecture et \'ecriture.
16 Plusieurs conditions sont requises pour que Bacula puisse utiliser une librairie.
17 Celles-ci sont expliqu\'ees en d\'etail ci-dessous.
18 Mais voyons d'abord la liste de ces conditions :
21 \item Un script charg\'e de piloter la librairie en accord avec les commandes
22 envoy\'ees par Bacula est requis. Nous fournissons un tel script pr\'evu pour fonctionner
23 avec le programme {\bf mtx} disponible dans les paquets {\bf depkgs}.
24 \item Chaque volume \`a utiliser doit \^etre d\'efini dans le catalogue et avoir
25 un num\'ero de slot (NDT : emplacement dans la librairie) assign\'e, de sorte
26 que Bacula puisse savoir o\`u se trouve le volume dans la librairie. Cet
27 enregistrement se fait la plupart du temps gr\^ace \`a la commande {\bf label}.
28 Voyez ci-dessous pour plus de d\'etails. Vous devez \'etiqueter manuellement
29 vos cartouches avant de pouvoir les utiliser.
30 \item Vous devez avoir modifi\'e le fichier de configuration de votre Storage
31 Daemon afin que la ressource Device identifie votre p\'eriph\'erique en tant
32 que librairie. Quelques autres param\`etres doivent \^etre d\'efinis.
33 \item Si vous n'ex\'ecutez pas le Storage Daemon en tant que root, vous devez
34 vous assurer qu'il d\'etient les droits requis pour acc\'eder au lecteur et au
35 bras robotis\'e de la librairie.
36 \item Vous devez placer la directive {\bf Autochanger = yes} dans la
37 ressource Storage de votre fichier bacula-dir.conf, de sorte que vous soyez
38 interrog\'e au sujet du slot \`a chaque \'etiquetage de cartouche.
41 Dans les versions ult\'erieures \`a 1.37, la nouvelle directive
42 \ilink{Autochanger resource}{AutochangerRes} permet de grouper les ressources
43 Device pour cr\'eer des librairies avec plusieurs lecteurs. Si vous avez une
44 librairie, vous devez utiliser cette ressource.
46 Bacula utilise son propre script {\bf mtx-changer} pour interagir avec un
47 programme qui effectue r\'eellement les changement de cartouches. Ainsi,
48 {\bf mtx-changer} peut \^etre adapt\'e pour fonctionner avec n'importe quel
49 programme de prise en chgarge de librairie. La version actuelle de
50 {\bf mtx-changer} fonctionne avec le programme {\bf mtx} . Cependant,
51 des utilisateurs de FreeBSD ont r\'ealis\'e un script, disponible dans
52 le r\'epertoire {\bf examples/autochangers}, qui permet \`a Bacula de fonctionner
53 avec le programme {\bf chio}.
55 Bacula supporte aussi les librairies \'equip\'ees de lecteurs de codes barres.
56 Ce support inclut deux commandes de la console Bacula : {\bf label barcodes}
57 et {\bf update slots}. Pour plus de d\'etails au sujet de ces commandes,
58 voyez la section "Support des lecteurs de codes barres" plus loin.
60 Le support des librairies dans Bacula n'inclue pas, pour le moment, la gestion
61 du nettoyage des lecteurs, ni celle des bacs de cartouches ou des silos.
62 Cependant, sous certaines conditions, vous pouvez parvenir \`a le faire
63 fonctionner avec des stackers (tels que gravity feed et apparent\'es).
64 (NDT : le dernier paragraphe n'est pas clair. Voici la vo :
65 Current Bacula autochanger support does not include cleaning, stackers, or
66 silos. However, under certain conditions, you may be able to make Bacula
67 work with stackers (gravity feed and such).)
69 Le support des librairies \`a plusieurs lecteurs requiert la ressource
70 \ilink{Autochanger resource}{AutochangerRes}, qui est aussi recommand\'ee
71 pour les librairies \`a un seul lecteur.
73 En principe, si {\bf mtx} fonctionne correctement avec votre librairie, ce
74 n'est qu'une question d'avaptation du script {\bf mtx-changer} pour que
75 Bacula s'interface correctement avec la librairie. Vous pouvez trouver une
76 liste des librairies support\'ees par {\bf mtx} en suivant le lien suivant :
77 \elink{http://mtx.badtux.net/compatibility.php}{http://mtx.badtux.net/compatibility.php}.
78 Le sit officiel du projet {\bf mtx} se trouve ici :
79 \elink{http://mtx.badtux.net/}{http://mtx.badtux.net/}.
81 Si vous avez des difficult\'es, veuillez utiliser la commande {\bf auto} du
82 programme {\bf btape} pour tester le fonctionnement de votre librairie
83 avec Bacula. Lorsque Bacula fonctionne, souvenez vous que pour beaucoup de
84 distributions (par exemple FreeBSD, Debian,...), le Storage Daemon est
85 ex\'ecut\'e en tant que {\bf bacula.tape} plut\^ot que {\bf root.root}, aussi
86 vous devrez vous assurer que le Storage Daemon dispose de droits suffisants pour
87 acc\'eder \`a la librairie.
90 \subsection*{D\'eterminer vos p\'eriph\'eriques SCSI}
91 \index[general]{D\'eterminer!p\'eriph\'eriques SCSI}
92 \index[general]{D\'eterminer vos p\'eriph\'eriques SCSI}
93 \index[general]{P\'eriph\'eriques}
94 \index[general]{p\'eriph\'eriques!SCSI}
95 \addcontentsline{toc}{subsection}{D\'eterminer vos p\'eriph\'eriques SCSI}
97 Sous Linux, vous pouvez lire le fichier /proc/scsi/scsi :
105 pour conna\^itre vos p\'eriph\'eriques SCSI. Vous pouvez aussi examiner les fichiers
106 /proc/scsi/sg/device_hdr et /proc/scsi/sg/devices :
110 cat /proc/scsi/sg/device_hdr /proc/scsi/sg/devices
114 pour d\'eterminer comment sp\'ecifier leur nom de p\'eriph\'erique ({\bf /dev/sg0}
115 pour le premier, {\bf /dev/sg1} pour le second, ...) au niveau de
116 la directive {\bf Changer Device}
118 Sous FreeBSD, vous disposez de la commande :
126 pour afficher la liste des p\'eriph\'eriques SCSI ainsi que le {\bf /dev/passn}
127 que vous utiliserez pour renseigner la directive {\bf Changer Device}
129 Assurez-vous que votre Storage Daemon dispose bien des privil\`eges requis
130 pour acc\'eder \`a ce p\'eriph\'erique.
132 L'astuce suivante, destin\'ee aux utilisateurs de FreeBSD, provient de
133 Danny Butroyd. Au red\'emarrage, Bacula n'aura PLUS les permissions
134 requises pour contr\^oler le p\'eriph\'erique /dev/pass0. Pour vous
135 affanchir de cette difficult\'e, \'editez le fichier /etc/devfs.conf et
140 own pass0 root:bacula
142 own nsa0.0 root:bacula
147 Nous avons ainsi donn\'e au groupe Bacula la permission d'\'ecrire
148 sur le p\'eriph\'erique nsa0.0. Pour activer ces modifications, ex\'ecutez :
149 /etc/rc.d/devfs restart
151 Vous n'aurez plus \`a modifier les permissions sur ces p\'eriph\'eriques
152 pour que Bacula continue d'utiliser la librairie apr\`es un red\'emarrage.
156 \subsection*{Exemples de scripts}
157 \index[general]{Scripts!Exemples }
158 \index[general]{Exemples de scripts }
159 \addcontentsline{toc}{subsection}{Exemples de scripts}
161 Veuillez lire les sections ci-dessous pour bien comprendre comment
162 les librairies fonctionnent avec Bacula. Bien que nous fournissions
163 un script {\bf mtx-changer} par d\'efaut, il se peut que votre librairie
164 n\'ecessite quelques am\'enagements de ce script. Si vous voulez voir des
165 exemples de fichiers de configuration et de scripts, jetez un oeil
166 au r\'epertoire \lt{}bacula-src\gt{}/examples/devices} o\`u vous
167 trouverez un exemple de ressource Device Bacula : {\bf HP-autoloader.conf}
168 ainsi que plusieurs scripts {\bf mtx-changer} modifi\'es pour fonctionner
169 avec diverses librairies.
174 \index[general]{Slots }
175 \addcontentsline{toc}{subsection}{Slots}
177 Pour utiliser convenablement une librairie, Bacula doit savoir quel volume
178 se trouve dans quel {\bf slot} de la librairie. LE slots sont les
179 emplacements o\`u sont rang\'ees les cartouches lorsqu'elles ne sont pas dans un
180 lecteur. Bacula num\'erote ces slots de un jusqu'au nombre de cartouches
181 contenues dans la librairie.
183 Bacula n'utilisera pas automatiquement une cartouche pr\'esente dans la librairie
184 si elle ne porte pas d'\'etiquette (label) Bacula et si son num\'ero de slot n'est pas
185 r\'ef\'erenc\'e dans le catalogue. Vous devez, \`a l'aide de la console, assigner un
186 slot \`a chaque cartouche pr\'esente dans la librairie. Cette information est
187 conserv\'ee dans le catalogue avec les autres donn\'ees relatives au volume.
188 Si le slot n'est pas pr\'ecis\'e, ou s'il est \'egal \`a z\'ero, alors Bacula ne tentera
189 pas d'utiliser la librairie, m\^eme si tous les enregistrements de configuration
190 sont pr\'esents. De m\^eme, la commande {\bf mount} de la console Bacula ne
191 provoque pas non plus l'utilisation de la librairie, mais se contente d'ordonner
192 \`a Bacula de lire toute cartouche \'eventuellement pr\'esente dans le lecteur.
194 Vous pouvez contr\^oler le num\'ero de slot et le drapeau InChanger avec la commande :
203 \subsection*{Lecteurs multiples}
204 \index[general]{Lecteurs!Multiples }
205 \index[general]{Lecteurs ultiples}
206 \addcontentsline{toc}{subsection}{Lecteurs multiple}
208 Certaines librairies comportent plusieurs p\'eriph\'eriques de lecture/\'ectriture
209 (lecteurs). La nouvelle \ilink{ressource Autochanger}{AutochangerRes}
210 apparue avec la version 1.37 vous permet de grouper des ressources Devices
211 (repr\'esentant chacune un lecteur). Le Director est toujours en mesure
212 d'adresser directement un lecteur, mais ce faisant, il outrepasse
213 le fonctionnement propre aux groupements de lecteurs. Il est pr\'ef\'erable
214 que la Ressource Storage du Director d\'efinisse une ressource
215 Autochanger, permettant ainsi au Storage Daemon de s'assurer qu'un seul
216 lecteur \`a la fois utilise le script mtx-changer, et que deux lecteurs ne tentent
217 pas de lire le m\^eme volume.
219 Les librairies \`a lecteurs multiples n\'ecessitent d'utiliser la directive
220 {\bf Drive Index} dans la ressource Device du Storage Daemon. Les
221 lecteurs sont num\'erot\'es \`a partir de z\'ero, ce qui constitue la valeur par
222 d\'efaut. Pour utiliser un deuxi\`eme lecteur dans une librairie, vous devez
223 d\'efinir une seconde ressource Device et lui attribuer le Drive Index 1.
224 En g\'en\'eral, le second p\'eriph\'erique aura le m\^eme {\bf Changer Device}
225 (canal de contr\^ole) que le premier, mais une {\bf Archive Device} diff\'erente.
227 \label{ConfigRecords}
228 \subsection*{Directives de la ressource Device}
229 \index[general]{Directives!ressource Device}
230 \index[general]{Directives de la ressource Device}
231 \addcontentsline{toc}{subsection}{Directives de la ressource Device}
233 La configuration des librairies s'effectue dans Bacula au niveau de le ressource
234 Device du Storage Daemon. Quatre directives permettent de d\'efinir l'usage de
235 la librairie par Bacula : {\bf Autochanger}, {\bf Changer Device},
236 {\bf Changer Command} et {\bf Maximum Changer Wait
238 Ces quatre directives sont d\'ecrites en d\'etail ci-dessous. Notez cependant
239 que les directives {\bf Changer Device} et {\bf Changer Command} ne sont pas
240 requises dans la ressource Device si elles figurent dans la ressource
245 \item [Autochanger = {\it Yes|No} ]
246 \index[sd]{Autochanger}
247 La directive {\bf Autochanger} stipule que le p\'eriph\'erique ainsi d\'efini est, ou
248 n'est pas, une librairie. La valeur par d\'efaut est {\bf no}.
250 \item [Changer Device = \lt{}device-name\gt{}]
251 \index[sd]{Changer Device}
252 En plus du nom d'Archive Device, vous devez sp\'ecifier un nom de
253 librairie {\bf Changer Device}, ceci parce que la plupart des librairies
254 sont control\'ees via un pseudo-fichier diff\'erent de celui utilis\'e pour
255 lire et \'ecrire sur les cartouches. Par exemple, sur les syst\`emes Linux,
256 on utilise g\'en\'eralement l'interface SCSI g\'en\'erique pour contr\^oler le bras
257 de la librairie, soit {\bf Changer Device = /dev/sg0} et l'interface SCSI
258 standard pour lire et \'ecrire sur les bandes, soit {\bf Archive Device = /dev/nst0}.
259 Notez que certaines librairies \'evolu\'ees localiseront le bras sur
260 {\bf /dev/sg1}. De telles librairies ont souvent plusieurs lecteurs et un
261 nombre important de cartouches.
263 Sur FreeBSD, on sp\'ecifiera typiquement {\bf Changer Device = /dev/pass0} ou
264 {\bf Changer Device = /dev/passn}.
266 Sur Solaris, ce sera {\bf Changer Device = /dev/rdsk}.
268 Assurez vous que votre Storage Daemon poss\`ede les permissions d'acc\'eder \`a
271 \item [Changer Command = \lt{}command\gt{}]
272 \index[sd]{Changer Command }
273 Cette directive est utilis\'ee pour sp\'ecifier le programme externe \`a appeler
274 et les arguments \`a lui fournir. La commande est suppos\'ee \^etre un programme
275 ou un script shell standard qui peut \^etre ex\'ecut\'e par le syst\`eme. cette
276 commande est invoqu\'ee chaque fois que Bacula manipule le bras de la librairie.
277 Les substitutions suivantes sont effectu\'ees dans la ligne {\bf command}
278 avant qu'elle ne soit envoy\'ee au syst\`eme d'exploitation pour ex\'ecution.
283 %a = archive device name
284 %c = changer device name
285 %d = changer drive index base 0
288 %o = command (loaded, load, or unload)
295 Voici un exemple d'utilisation de {\bf mtx} avec le script {\bf mtx-changer} :
299 Changer Command = "/etc/bacula/mtx-changer %c %o %S %a %d"
303 O\`u vous devrez adapter le chemin {\bf /etc/bacula} pour qu'il co\''incide \`a
304 la r\'ealit\'e de votre installation. Les d\'etails des trois commandes (loaded,
305 load, unload) utilis\'ees par Bacula ainsi que la sortie qui en est attendue
306 sont donn\'es dans la section {\bf Interface entre Bacula et les librairies}
309 \item [Maximum Changer Wait = \lt{}time\gt{}]
310 \index[sd]{Maximum Changer Wait}
311 Cet enregistrement sert \`a d\'efinir le d\'elai maximal durant lequel Bacula
312 attendra la r\'eponse d'une librairie \`a une commande (par exemple, load).
313 La valeur par d\'efaut est 120 secondes. Si votre librairie est lente, vous
314 pouvez avoir int\'er\^et \`a allonger ce d\'elai.
316 Au del\`a de ce d\'elai, le programme de chargement est tu\'e et Bacula
317 sollicite l'intervention d'un op\'erateur.
319 \item [Drive Index = \lt{}number\gt{}]
320 \index[sd]{Drive Index}
321 Cette directive vous permet d'indiquer \`a Bacula d'utiliser le second
322 lecteur et les \'eventuels suivants dans une librairie qui en contient
323 plusieurs. Etant donn\'e que les lecteurs sont num\'erot\'es \`a partir de
324 z\'ero, le second est d\'efini par :
332 Pour utiliser le second lecteur, vous devez avoir une seconde d\'efinition
333 de ressource Device dans le fichier bacula-sd.conf. Voyez la section
334 concernant les lecteurs multiples plus haut dans ce chapitre pour plus
335 de plus amples informations.
338 De plus, pour un fonctionnement correct de la librairie, vous devez d\'efinir
339 une ressource Autochanger.
340 \input{autochangerres}
343 \subsection*{Un exemple de fichier de configuration}
344 \index[general]{exemple fichier configuration}
345 \index[general]{fichier!exemple configuration}
346 \addcontentsline{toc}{subsection}{Un exemple de fichier de configuration}
348 Les deux ressource suivantes impl\'ementent une librairie :
355 Changer Device = /dev/sg0
356 Changer Command = "/etc/bacula/mtx-changer %c %o %S %a %d"
362 Archive Device = /dev/nst0 # Normal archive device
365 AutomaticMount = yes;
371 where you will adapt the {\bf Archive Device}, the {\bf Changer Device}, and
372 the path to the {\bf Changer Command} to correspond to the values used on your
375 \subsection*{A Multi-drive Example Configuration File}
376 \index[general]{Multi-drive Example Configuration File }
377 \addcontentsline{toc}{subsection}{A Multi-drive Example Configuration File}
379 The following resources implement a multi-drive autochanger:
385 Device = Drive-1, Drive-2
386 Changer Device = /dev/sg0
387 Changer Command = "/etc/bacula/mtx-changer %c %o %S %a %d"
394 Archive Device = /dev/nst0 # Normal archive device
397 AutomaticMount = yes;
405 Archive Device = /dev/nst1 # Normal archive device
408 AutomaticMount = yes;
415 where you will adapt the {\bf Archive Device}, the {\bf Changer Device}, and
416 the path to the {\bf Changer Command} to correspond to the values used on your
419 \label{SpecifyingSlots}
420 \subsection*{Specifying Slots When Labeling}
421 \index[general]{Specifying Slots When Labeling }
422 \index[general]{Labeling!Specifying Slots When }
423 \addcontentsline{toc}{subsection}{Specifying Slots When Labeling}
425 If you add an {\bf Autochanger = yes} record to the Storage resource in your
426 Director's configuration file, the Bacula Console will automatically prompt
427 you for the slot number when the Volume is in the changer when
428 you {\bf add} or {\bf label} tapes for that Storage device. If your
429 {\bf mtx-changer} script is properly installed, Bacula will automatically
430 load the correct tape during the label command.
433 {\bf Autochanger = yes} in the Storage daemon's Device resource
434 as we have described above in
435 order for the autochanger to be used. Please see the
436 \ilink{Storage Resource}{Autochanger1} in the Director's chapter
438 \ilink{Device Resource}{Autochanger} in the Storage daemon
439 chapter for more details on these records.
441 Thus all stages of dealing with tapes can be totally automated. It is also
442 possible to set or change the Slot using the {\bf update} command in the
443 Console and selecting {\bf Volume Parameters} to update.
445 Even though all the above configuration statements are specified and correct,
446 Bacula will attempt to access the autochanger only if a {\bf slot} is non-zero
447 in the catalog Volume record (with the Volume name).
449 If your autochanger has barcode labels, you can label all the Volumes in
450 your autochanger one after another by using the {\bf label barcodes} command.
451 For each tape in the changer containing a barcode, Bacula will mount the tape
452 and then label it with the same name as the barcode. An appropriate Media
453 record will also be created in the catalog. Any barcode that begins with the
454 same characters as specified on the "CleaningPrefix=xxx" command, will be
455 treated as a cleaning tape, and will not be labeled. For example with:
457 Please note that Volumes must be pre-labeled to be automatically used in
458 the autochanger during a backup. If you do not have a barcode reader, this
459 is done manually (or via a script).
465 Cleaning Prefix = "CLN"
470 Any slot containing a barcode of CLNxxxx will be treated as a cleaning tape
471 and will not be mounted.
474 \subsection*{Dealing with Multiple Magazines}
475 \index[general]{Dealing with Multiple Magazines }
476 \index[general]{Magazines!Dealing with Multiple }
477 \addcontentsline{toc}{subsection}{Dealing with Multiple Magazines}
479 If you have several magazines or if you insert or remove cartridges from a
480 magazine, you should notify Bacula of this. By doing so, Bacula will as
481 a preference, use Volumes that it knows to be in the autochanger before
482 accessing Volumes that are not in the autochanger. This prevents unneeded
483 operator intervention.
485 If your autochanger has barcodes (machine readable tape labels), the task of
486 informing Bacula is simple. Every time, you change a magazine, or add or
487 remove a cartridge from the magazine, simply do
493 (insert new magazine)
499 in the Console program. This will cause Bacula to request the autochanger to
500 return the current Volume names in the magazine. This will be done without
501 actually accessing or reading the Volumes because the barcode reader does this
502 during inventory when the autochanger is first turned on. Bacula will ensure
503 that any Volumes that are currently marked as being in the magazine are marked
504 as no longer in the magazine, and the new list of Volumes will be marked as
505 being in the magazine. In addition, the Slot numbers of the Volumes will be
506 corrected in Bacula's catalog if they are incorrect (added or moved).
508 If you do not have a barcode reader on your autochanger, you have several
512 \item You can manually set the Slot and InChanger flag using the {\bf update
513 volume} command in the Console (quite painful).
515 \item You can issue a
523 command that will cause Bacula to read the label on each of the cartridges in
524 the magazine in turn and update the information (Slot, InChanger flag) in the
525 catalog. This is quite effective but does take time to load each cartridge
526 into the drive in turn and read the Volume label.
528 \item You can modify the mtx-changer script so that it simulates an
529 autochanger with barcodes. See below for more details.
533 \subsection*{Simulating Barcodes in your Autochanger}
534 \index[general]{Autochanger!Simulating Barcodes in your }
535 \index[general]{Simulating Barcodes in your Autochanger }
536 \addcontentsline{toc}{subsection}{Simulating Barcodes in your Autochanger}
538 You can simulate barcodes in your autochanger by making the {\bf mtx-changer}
539 script return the same information that an autochanger with barcodes would do.
540 This is done by commenting out the one and only line in the {\bf list)} case,
545 ${MTX} -f $ctl status | grep " *Storage Element [0-9]*:.*Full" | awk "{print \$3 \$4}" | sed "s/Full *\(:VolumeTag=\)*//"
549 at approximately line 99 by putting a \# in column one of that line, or by
550 simply deleting it. Then in its place add a new line that prints the contents
551 of a file. For example:
555 cat /etc/bacula/changer.volumes
559 Be sure to include a full path to the file, which can have any name. The
560 contents of the file must be of the following format:
571 Where the 1, 2, 3 are the slot numbers and Volume1, Volume2, ... are the
572 Volume names in those slots. You can have multiple files that represent the
573 Volumes in different magazines, and when you change magazines, simply copy the
574 contents of the correct file into your {\bf /etc/bacula/changer.volumes} file.
575 There is no need to stop and start Bacula when you change magazines, simply
576 put the correct data in the file, then run the {\bf update slots} command, and
577 your autochanger will appear to Bacula to be an autochanger with barcodes.
580 \subsection*{The Full Form of the Update Slots Command}
581 \index[general]{Full Form of the Update Slots Command }
582 \index[general]{Command!Full Form of the Update Slots }
583 \addcontentsline{toc}{subsection}{Full Form of the Update Slots Command}
585 If you change only one cartridge in the magazine, you may not want to scan all
586 Volumes, so the {\bf update slots} command (as well as the {\bf update slots
587 scan} command) has the additional form:
591 update slots=n1,n2,n3-n4, ...
595 where the keyword {\bf scan} can be appended or not. The n1,n2, ... represent
596 Slot numbers to be updated and the form n3-n4 represents a range of Slot
597 numbers to be updated (e.g. 4-7 will update Slots 4,5,6, and 7).
599 This form is particularly useful if you want to do a scan (time expensive) and
600 restrict the update to one or two slots.
602 For example, the command:
606 update slots=1,6 scan
610 will cause Bacula to load the Volume in Slot 1, read its Volume label and
611 update the Catalog. It will do the same for the Volume in Slot 6. The command:
620 will read the barcoded Volume names for slots 1,2,3 and 6 and make the
621 appropriate updates in the Catalog. If you don't have a barcode reader or have
622 not modified the mtx-changer script as described above, the above command will
623 not find any Volume names so will do nothing.
626 \subsection*{FreeBSD Issues}
627 \index[general]{Issues!FreeBSD }
628 \index[general]{FreeBSD Issues }
629 \addcontentsline{toc}{subsection}{FreeBSD Issues}
631 If you are having problems on FreeBSD when Bacula tries to select a tape, and
632 the message is {\bf Device not configured}, this is because FreeBSD has made
633 the tape device {\bf /dev/nsa1} disappear when there is no tape mounted in the
634 autochanger slot. As a consequence, Bacula is unable to open the device. The
635 solution to the problem is to make sure that some tape is loaded into the tape
636 drive before starting Bacula. This problem is corrected in Bacula versions
640 \ilink{ Tape Testing}{FreeBSDTapes} chapter of this manual for
641 {\bf important} information concerning your tape drive before doing the
643 \label{AutochangerTesting}
645 \subsection*{Testing the Autochanger and Adapting Your mtx-changer Script}
646 \index[general]{Testing the Autochanger and Adapting Your mtx-changer Script }
647 \index[general]{Script!Testing the Autochanger and Adapting Your mtx-changer }
648 \addcontentsline{toc}{subsection}{Testing the Autochanger and Adapting Your
651 Before attempting to use the autochanger with Bacula, it is preferable to
652 "hand-test" that the changer works. To do so, we suggest you do the
653 following commands (assuming that the {\bf mtx-changer} script is installed in
654 {\bf /etc/bacula/mtx-changer}):
658 \item [Make sure Bacula is not running.]
660 \item [/etc/bacula/mtx-changer \ /dev/sg0 \ list \ 0 \ /dev/nst0 \ 0]
661 \index[sd]{mtx-changer list}
663 This command should print:
675 or one number per line for each slot that is occupied in your changer, and
676 the number should be terminated by a colon ({\bf :}). If your changer has
677 barcodes, the barcode will follow the colon. If an error message is printed,
678 you must resolve the problem (e.g. try a different SCSI control device name
679 if {\bf /dev/sg0} is incorrect. For example, on FreeBSD systems, the
680 autochanger SCSI control device is generally {\bf /dev/pass2}.
682 \item [/etc/bacula/mtx-changer \ /dev/sg0 \ slots \ 0 \ /dev/nst0 \ 0]
683 \index[sd]{mtx-changer slots}
685 This command should return the number of slots in your autochanger.
687 \item [/etc/bacula/mtx-changer \ /dev/sg0 \ unload \ ]
688 \index[sd]{mtx-changer unload}
690 If a tape is loaded, this should cause it to be unloaded.
692 \item [/etc/bacula/mtx-changer \ /dev/sg0 \ load \ 3 \ /dev/nst0 \ 0 ]
693 \index[sd]{mtx-changer load}
695 Assuming you have a tape in slot 3, it will be loaded into the read slot (0).
698 \item [/etc/bacula/mtx-changer \ /dev/sg0 \ loaded \ 0 \ /dev/nst0 \ 0]
699 \index[sd]{mtx-changer loaded}
703 \item [/etc/bacula/mtx-changer \ /dev/sg0 \ unload]
706 Once all the above commands work correctly, assuming that you have the right
707 {\bf Changer Command} in your configuration, Bacula should be able to operate
708 the changer. The only remaining area of problems will be if your autoloader
709 needs some time to get the tape loaded after issuing the command. After the
710 {\bf mtx-changer} script returns, Bacula will immediately rewind and read the
711 tape. If Bacula gets rewind I/O errors after a tape change, you will probably
712 need to insert a {\bf sleep 20} after the {\bf mtx} command, but be careful to
713 exit the script with a zero status by adding {\bf exit 0} after any additional
714 commands you add to the script. This is because Bacula checks the return
715 status of the script, which should be zero if all went well.
717 You can test whether or not you need a {\bf sleep} by putting the following
718 commands into a file and running it as a script:
723 /etc/bacula/mtx-changer /dev/sg0 unload
724 /etc/bacula/mtx-changer /dev/sg0 load 3
725 mt -f /dev/st0 rewind
730 If the above script runs, you probably have no timing problems. If it does not
731 run, start by putting a {\bf sleep 30} or possibly a {\bf sleep 60} in the
732 script just after the mtx-changer load command. If that works, then you should
733 move the sleep into the actual {\bf mtx-changer} script so that it will be
734 effective when Bacula runs.
736 A second problem that comes up with a small number of autochangers is that
737 they need to have the cartridge ejected before it can be removed. If this is
738 the case, the {\bf load 3} will never succeed regardless of how long you wait.
739 If this seems to be your problem, you can insert an eject just after the
740 unload so that the script looks like:
745 /etc/bacula/mtx-changer /dev/sg0 unload
746 mt -f /dev/st0 offline
747 /etc/bacula/mtx-changer /dev/sg0 load 3
748 mt -f /dev/st0 rewind
753 Obviously, if you need the {\bf offline} command, you should move it into the
754 mtx-changer script ensuring that you save the status of the {\bf mtx} command
755 or always force an {\bf exit 0} from the script, because Bacula checks the
756 return status of the script.
758 As noted earlier, there are several scripts in {\bf
759 \lt{}bacula-source\gt{}/examples/devices} that implement the above features,
760 so they may be a help to you in getting your script to work.
762 If Bacula complains "Rewind error on /dev/nst0. ERR=Input/output error." you
763 most likely need more sleep time in your {\bf mtx-changer} before returning to
764 Bacula after a load command has been completed.
768 \subsection*{Using the Autochanger}
769 \index[general]{Using the Autochanger }
770 \index[general]{Autochanger!Using the }
771 \addcontentsline{toc}{subsection}{Using the Autochanger}
773 Let's assume that you have properly defined the necessary Storage daemon
774 Device records, and you have added the {\bf Autochanger = yes} record to the
775 Storage resource in your Director's configuration file.
777 Now you fill your autochanger with say six blank tapes.
779 What do you do to make Bacula access those tapes?
781 One strategy is to prelabel each of the tapes. Do so by starting Bacula, then
782 with the Console program, enter the {\bf label} command:
787 Connecting to Director rufus:8101
788 1000 OK: rufus-dir Version: 1.26 (4 October 2002)
793 it will then print something like:
797 Using default Catalog name=BackupDB DB=bacula
798 The defined Storage resources are:
801 Select Storage resource (1-2): 1
805 I select the autochanger (1), and it prints:
809 Enter new Volume name: TestVolume1
810 Enter slot (0 for none): 1
814 where I entered {\bf TestVolume1} for the tape name, and slot {\bf 1} for the
822 Select the Pool (1-2): 1
826 I select the Default pool. This will be automatically done if you only have a
827 single pool, then Bacula will proceed to unload any loaded volume, load the
828 volume in slot 1 and label it. In this example, nothing was in the drive, so
833 Connecting to Storage daemon Autochanger at localhost:9103 ...
834 Sending label command ...
835 3903 Issuing autochanger "load slot 1" command.
836 3000 OK label. Volume=TestVolume1 Device=/dev/nst0
837 Media record for Volume=TestVolume1 successfully created.
838 Requesting mount Autochanger ...
839 3001 Device /dev/nst0 is mounted with Volume TestVolume1
845 You may then proceed to label the other volumes. The messages will change
846 slightly because Bacula will unload the volume (just labeled TestVolume1)
847 before loading the next volume to be labeled.
849 Once all your Volumes are labeled, Bacula will automatically load them as they
852 To "see" how you have labeled your Volumes, simply enter the {\bf list
853 volumes} command from the Console program, which should print something like
859 Using default Catalog name=BackupDB DB=bacula
863 Select the Pool (1-2): 1
864 +-------+----------+--------+---------+-------+--------+----------+-------+------+
865 | MedId | VolName | MedTyp | VolStat | Bites | LstWrt | VolReten | Recyc | Slot |
866 +-------+----------+--------+---------+-------+--------+----------+-------+------+
867 | 1 | TestVol1 | DDS-4 | Append | 0 | 0 | 30672000 | 0 | 1 |
868 | 2 | TestVol2 | DDS-4 | Append | 0 | 0 | 30672000 | 0 | 2 |
869 | 3 | TestVol3 | DDS-4 | Append | 0 | 0 | 30672000 | 0 | 3 |
871 +-------+----------+--------+---------+-------+--------+----------+-------+------+
877 \subsection*{Barcode Support}
878 \index[general]{Support!Barcode }
879 \index[general]{Barcode Support }
880 \addcontentsline{toc}{subsection}{Barcode Support}
882 Bacula provides barcode support with two Console commands, {\bf label
883 barcodes} and {\bf update slots}.
885 The {\bf label barcodes} will cause Bacula to read the barcodes of all the
886 cassettes that are currently installed in the magazine (cassette holder) using
887 the {\bf mtx-changer} {\bf list} command. Each cassette is mounted in turn and
888 labeled with the same Volume name as the barcode.
890 The {\bf update slots} command will first obtain the list of cassettes and
891 their barcodes from {\bf mtx-changer}. Then it will find each volume in turn
892 in the catalog database corresponding to the barcodes and set its Slot to
893 correspond to the value just read. If the Volume is not in the catalog, then
894 nothing will be done. This command is useful for synchronizing Bacula with the
895 current magazine in case you have changed magazines or in case you have moved
896 cassettes from one slot to another.
898 The {\bf Cleaning Prefix} statement can be used in the Pool resource to define
899 a Volume name prefix, which if it matches that of the Volume (barcode) will
900 cause that Volume to be marked with a VolStatus of {\bf Cleaning}. This will
901 prevent Bacula from attempting to write on the Volume.
905 \subsection*{Bacula Autochanger Interface}
906 \index[general]{Interface!Bacula Autochanger }
907 \index[general]{Bacula Autochanger Interface }
908 \addcontentsline{toc}{subsection}{Bacula Autochanger Interface}
910 Bacula calls the autochanger script that you specify on the {\bf Changer
911 Device} statement. Normally this script will be the {\bf mtx-changer} script
912 that we can provide, but it can in fact be any program. The only requirements
913 are that the "commands" that Bacula uses are {\bf loaded}, {\bf load}, {\bf
914 unload}, {\bf list}, and {\bf slots}. In addition,
915 each of those commands must return the information in the precise format as
920 - Currently the changer commands used are:
921 loaded -- returns number of the slot that is loaded, base 1,
922 in the drive or 0 if the drive is empty.
923 load -- loads a specified slot (note, some autochangers
924 require a 30 second pause after this command) into
926 unload -- unloads the device (returns cassette to its slot).
927 list -- returns one line for each cassette in the autochanger
928 in the format <slot>:<barcode>. Where
929 the {\bf slot} is the non-zero integer representing
930 the slot number, and {\bf barcode} is the barcode
931 associated with the cassette if it exists and if you
932 autoloader supports barcodes. Otherwise the barcode
934 slots -- returns total number of slots in the autochanger.
938 Bacula checks the exit status of the program called, and if it is zero, the
939 data is accepted. If the exit status is non-zero, Bacula ignores any
940 information returned and treats the drive as if it is not an autochanger.