order to work with an autochanger, Bacula requires a number of things, each of
which is explained in more detail after this list:
-\begin{itemize}
+\begin{bsysitemize}
\item A script that actually controls the autochanger according to commands
sent by Bacula. We furnish such a script that works with {\bf mtx} found in
- the {\bf depkgs} distribution.
+ the {\bf depkgs} distribution.
\item That each Volume (tape) to be used must be defined in the Catalog and
have a Slot number assigned to it so that Bacula knows where the Volume is
before using them.
\item Modifications to your Storage daemon's Device configuration resource to
- identify that the device is a changer, as well as a few other parameters.
+ identify that the device is a changer, as well as a few other parameters.
\item You should also modify your Storage resource definition in the
Director's configuration file so that you are automatically prompted for the
- Slot when labeling a Volume.
+ Slot when labeling a Volume.
\item You need to ensure that your Storage daemon (if not running as root)
has access permissions to both the tape drive and the control device.
\item You need to have {\bf Autochanger = yes} in your Storage resource
in your bacula-dir.conf file so that you will be prompted for the
slot number when you label Volumes.
-\end{itemize}
+\end{bsysitemize}
In version 1.37 and later, there is a new \ilink{Autochanger
resource}{AutochangerRes} that permits you to group Device resources thus
creating a multi-drive autochanger. If you have an autochanger,
-you {\bf must} use this new resource.
+you {\bf must} use this new resource.
Bacula uses its own {\bf mtx-changer} script to interface with a program
that actually does the tape changing. Thus in principle, {\bf mtx-changer}
Bacula also supports autochangers with barcode
readers. This support includes two Console commands: {\bf label barcodes}
and {\bf update slots}. For more details on these commands, see the "Barcode
-Support" section below.
+Support" section below.
Current Bacula autochanger support does not include cleaning, stackers, or
silos. Stackers and silos are not supported because Bacula expects to
be able to access the Slots randomly.
However, if you are very careful to setup Bacula to access the Volumes
in the autochanger sequentially, you may be able to make Bacula
-work with stackers (gravity feed and such).
+work with stackers (gravity feed and such).
Support for multi-drive
autochangers requires the \ilink{Autochanger resource}{AutochangerRes}
In principle, if {\bf mtx} will operate your changer correctly, then it is
just a question of adapting the {\bf mtx-changer} script (or selecting one
already adapted) for proper interfacing. You can find a list of autochangers
-supported by {\bf mtx} at the following link:
+supported by {\bf mtx} at the following link:
\elink{http://mtx.opensource-sw.net/compatibility.php}
{http://mtx.opensource-sw.net/compatibility.php}.
-The home page for the {\bf mtx} project can be found at:
-\elink{http://mtx.opensource-sw.net/}{http://mtx.opensource-sw.net/}.
+The home page for the {\bf mtx} project can be found at:
+\elink{http://mtx.opensource-sw.net/}{http://mtx.opensource-sw.net/}.
Note, we have feedback from some users that there are certain
incompatibilities between the Linux kernel and mtx. For example between
Bacula is running, please remember that for many distributions (e.g. FreeBSD,
Debian, ...) the Storage daemon runs as {\bf bacula.tape} rather than {\bf
root.root}, so you will need to ensure that the Storage daemon has sufficient
-permissions to access the autochanger.
+permissions to access the autochanger.
Some users have reported that the the Storage daemon blocks under certain
circumstances in trying to mount a volume on a drive that has a different
\index[general]{SCSI devices}
\index[general]{devices!SCSI}
-Under Linux, you can
+Under Linux, you can
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
cat /proc/scsi/scsi
-\end{verbatim}
+\end{lstlisting}
\normalsize
-to see what SCSI devices you have available. You can also:
+to see what SCSI devices you have available. You can also:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
cat /proc/scsi/sg/device_hdr /proc/scsi/sg/devices
-\end{verbatim}
+\end{lstlisting}
\normalsize
to find out how to specify their control address ({\bf /dev/sg0} for the
first, {\bf /dev/sg1} for the second, ...) on the {\bf Changer Device = }
-Bacula directive.
+Bacula directive.
You can also use the excellent {\bf lsscsi} tool.
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
$ lsscsi -g
[1:0:2:0] tape SEAGATE ULTRIUM06242-XXX 1619 /dev/st0 /dev/sg9
[1:0:14:0] mediumx STK L180 0315 /dev/sch0 /dev/sg10
[2:0:3:0] tape HP Ultrium 3-SCSI G24S /dev/st1 /dev/sg11
[3:0:0:0] enclosu HP A6255A HP04 - /dev/sg3
[3:0:1:0] disk HP 36.4G ST336753FC HP00 /dev/sdd /dev/sg4
-\end{verbatim}
+\end{lstlisting}
\normalsize
For more detailed information on what SCSI devices you have please see
-the \ilink{Linux SCSI Tricks}{SCSITricks} section of the Tape Testing
-chapter of this manual.
+the \bsysxrlink{Linux SCSI Tricks}{SCSITricks}{problems}{section} of the
+ \bsysxrlink{Tape Testing}{TapeTestingChapter}{problems}{chapter} of the
+ \problemsman{}.
-Under FreeBSD, you can use:
+Under FreeBSD, you can use:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
camcontrol devlist
-\end{verbatim}
+\end{lstlisting}
\normalsize
To list the SCSI devices as well as the {\bf /dev/passn} that you will use on
-the Bacula {\bf Changer Device = } directive.
+the Bacula {\bf Changer Device = } directive.
Please check that your Storage daemon has permission to access this
device.
The following tip for FreeBSD users comes from Danny Butroyd:
-on reboot Bacula will NOT have permission to
-control the device /dev/pass0 (assuming this is your changer device).
-To get around this just edit the /etc/devfs.conf file and add the
-following to the bottom:
+on reboot Bacula will NOT have permission to
+control the device /dev/pass0 (assuming this is your changer device).
+To get around this just edit the /etc/devfs.conf file and add the
+following to the bottom:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
own pass0 root:bacula
perm pass0 0666
own nsa0.0 root:bacula
perm nsa0.0 0666
-\end{verbatim}
+\end{lstlisting}
\normalsize
-This gives the bacula group permission to write to the nsa0.0 device
-too just to be on the safe side. To bring these changes into effect
+This gives the bacula group permission to write to the nsa0.0 device
+too just to be on the safe side. To bring these changes into effect
just run:-
/etc/rc.d/devfs restart
-Basically this will stop you having to manually change permissions on these
+Basically this will stop you having to manually change permissions on these
devices to make Bacula work when operating the AutoChanger after a reboot.
\label{scripts}
\lt{}bacula-src\gt{}/examples/devices} directory where you will find an
example {\bf HP-autoloader.conf} Bacula Device resource, and several {\bf
mtx-changer} scripts that have been modified to work with different
-autochangers.
+autochangers.
\label{Slots}
To properly address autochangers, Bacula must know which Volume is in each
{\bf slot} of the autochanger. Slots are where the changer cartridges reside
when not loaded into the drive. Bacula numbers these slots from one to the
-number of cartridges contained in the autochanger.
+number of cartridges contained in the autochanger.
Bacula will not automatically use a Volume in your autochanger unless it is
labeled and the slot number is stored in the catalog and the Volume is marked
volume. If no slot is given, or the slot is set to zero, Bacula will not
attempt to use the autochanger even if all the necessary configuration records
are present. When doing a {\bf mount} command on an autochanger, you must
-specify which slot you want mounted. If the drive is loaded with a tape
+specify which slot you want mounted. If the drive is loaded with a tape
from another slot, it will unload it and load the correct tape, but
normally, no tape will be loaded because an {\bf unmount} command causes
Bacula to unload the tape in the drive.
-
+
You can check if the Slot number and InChanger flag are set by doing a:
-\begin{verbatim}
+\begin{lstlisting}
list Volumes
-\end{verbatim}
+\end{lstlisting}
in the Console program.
Some autochangers have more than one read/write device (drive). The
new \ilink{Autochanger resource}{AutochangerRes} introduced in version
-1.37 permits you to group Device resources, where each device
+1.37 permits you to group Device resources, where each device
represents a drive. The Director may still reference the Devices (drives)
directly, but doing so, bypasses the proper functioning of the
drives together. Instead, the Director (in the Storage resource)
-should reference the Autochanger resource name. Doing so permits
+should reference the Autochanger resource name. Doing so permits
the Storage daemon to ensure that only one drive uses the mtx-changer
script at a time, and also that two drives don't reference the
same Volume.
need to define a second Device resource and set the Drive Index to 1 for
that device. In general, the second device will have the same {\bf Changer
Device} (control channel) as the first drive, but a different {\bf Archive
-Device}.
+Device}.
As a default, Bacula jobs will prefer to write to a Volume that is
already mounted. If you have a multiple drive autochanger and you want
Configuration of autochangers within Bacula is done in the Device resource of
the Storage daemon. Four records: {\bf Autochanger}, {\bf Changer Device},
{\bf Changer Command}, and {\bf Maximum Changer Wait} control how Bacula uses
-the autochanger.
+the autochanger.
These four records, permitted in {\bf Device} resources, are described in
-detail below. Note, however, that the {\bf Changer Device} and the
+detail below. Note, however, that the {\bf Changer Device} and the
{\bf Changer Command} directives are not needed in the Device resource
if they are present in the {\bf Autochanger} resource.
\item [Autochanger = {\it Yes|No} ]
\index[sd]{Autochanger }
The {\bf Autochanger} record specifies that the current device is or is not
-an autochanger. The default is {\bf no}.
+an autochanger. The default is {\bf no}.
\item [Changer Device = \lt{}device-name\gt{}]
\index[sd]{Changer Device }
writing the tapes. On Linux, for the {\bf Archive Device = /dev/nst0}, you
would typically have {\bf Changer Device = /dev/sg0}. Note, some of the more
advanced autochangers will locate the changer device on {\bf /dev/sg1}. Such
-devices typically have several drives and a large number of tapes.
+devices typically have several drives and a large number of tapes.
On FreeBSD systems, the changer device will typically be on {\bf /dev/pass0}
-through {\bf /dev/passn}.
+through {\bf /dev/passn}.
On Solaris, the changer device will typically be some file under {\bf
-/dev/rdsk}.
+/dev/rdsk}.
Please ensure that your Storage daemon has permission to access this
device.
shell script that can be executed by the operating system. This command is
invoked each time that Bacula wishes to manipulate the autochanger. The
following substitutions are made in the {\bf command} before it is sent to
-the operating system for execution:
+the operating system for execution:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
%% = %
%a = archive device name
%c = changer device name
%s = Slot base 0
%S = Slot base 1
%v = Volume name
-\end{verbatim}
+\end{lstlisting}
\normalsize
An actual example for using {\bf mtx} with the {\bf mtx-changer} script (part
-of the Bacula distribution) is:
+of the Bacula distribution) is:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Changer Command = "/etc/bacula/mtx-changer %c %o %S %a %d"
-\end{verbatim}
+\end{lstlisting}
\normalsize
Where you will need to adapt the {\bf /etc/bacula} to be the actual path on
your system where the mtx-changer script resides. Details of the three
commands currently used by Bacula (loaded, load, unload) as well as the
-output expected by Bacula are give in the {\bf Bacula Autochanger Interface}
-section below.
+output expected by Bacula are give in the {\bf Bacula Autochanger Interface}
+section below.
\item [Maximum Changer Wait = \lt{}time\gt{}]
\index[sd]{Maximum Changer Wait }
want to set it longer.
If the autoloader program fails to respond in this time, it will be killed
-and Bacula will request operator intervention.
+and Bacula will request operator intervention.
\item [Drive Index = \lt{}number\gt{}]
\index[sd]{Drive Index }
numbered from zero, the second drive is defined by
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Device Index = 1
-
-\end{verbatim}
+
+\end{lstlisting}
\normalsize
To use the second drive, you need a second Device resource definition in the
Bacula configuration file. See the Multiple Drive section above in this
-chapter for more information.
+chapter for more information.
\end{description}
-In addition, for proper functioning of the Autochanger, you must
+In addition, for proper functioning of the Autochanger, you must
define an Autochanger resource.
\input{autochangerres}
\index[general]{Example Configuration File }
\index[general]{File!Example Configuration }
-The following two resources implement an autochanger:
+The following two resources implement an autochanger:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Autochanger {
Name = "Autochanger"
Device = DDS-4
AutomaticMount = yes;
AlwaysOpen = yes;
}
-\end{verbatim}
+\end{lstlisting}
\normalsize
where you will adapt the {\bf Archive Device}, the {\bf Changer Device}, and
the path to the {\bf Changer Command} to correspond to the values used on your
-system.
+system.
\section{A Multi-drive Example Configuration File}
\index[general]{Multi-drive Example Configuration File }
-The following resources implement a multi-drive autochanger:
+The following resources implement a multi-drive autochanger:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Autochanger {
Name = "Autochanger"
Device = Drive-1, Drive-2
AlwaysOpen = yes;
}
-\end{verbatim}
+\end{lstlisting}
\normalsize
where you will adapt the {\bf Archive Device}, the {\bf Changer Device}, and
the path to the {\bf Changer Command} to correspond to the values used on your
-system.
+system.
\label{SpecifyingSlots}
\section{Specifying Slots When Labeling}
you {\bf add} or {\bf label} tapes for that Storage device. If your
{\bf mtx-changer} script is properly installed, Bacula will automatically
load the correct tape during the label command.
-
+
You must also set
-{\bf Autochanger = yes} in the Storage daemon's Device resource
+{\bf Autochanger = yes} in the Storage daemon's Device resource
as we have described above in
-order for the autochanger to be used. Please see the
+order for the autochanger to be used. Please see the
\ilink{Storage Resource}{Autochanger1} in the Director's chapter
-and the
+and the
\ilink{Device Resource}{Autochanger} in the Storage daemon
-chapter for more details on these records.
+chapter for more details on these records.
Thus all stages of dealing with tapes can be totally automated. It is also
possible to set or change the Slot using the {\bf update} command in the
-Console and selecting {\bf Volume Parameters} to update.
+Console and selecting {\bf Volume Parameters} to update.
Even though all the above configuration statements are specified and correct,
Bacula will attempt to access the autochanger only if a {\bf slot} is non-zero
-in the catalog Volume record (with the Volume name).
+in the catalog Volume record (with the Volume name).
If your autochanger has barcode labels, you can label all the Volumes in
your autochanger one after another by using the {\bf label barcodes} command.
and then label it with the same name as the barcode. An appropriate Media
record will also be created in the catalog. Any barcode that begins with the
same characters as specified on the "CleaningPrefix=xxx" command, will be
-treated as a cleaning tape, and will not be labeled. For example with:
+treated as a cleaning tape, and will not be labeled. For example with:
Please note that Volumes must be pre-labeled to be automatically used in
the autochanger during a backup. If you do not have a barcode reader, this
is done manually (or via a script).
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Pool {
Name ...
Cleaning Prefix = "CLN"
}
-\end{verbatim}
+\end{lstlisting}
\normalsize
Any slot containing a barcode of CLNxxxx will be treated as a cleaning tape
to release the autochanger by doing:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
unmount
(change cartridges and/or run mtx)
mount
-\end{verbatim}
+\end{lstlisting}
\normalsize
If you do not do the unmount before making such a change, Bacula
magazine, you should notify Bacula of this. By doing so, Bacula will as
a preference, use Volumes that it knows to be in the autochanger before
accessing Volumes that are not in the autochanger. This prevents unneeded
-operator intervention.
+operator intervention.
If your autochanger has barcodes (machine readable tape labels), the task of
informing Bacula is simple. Every time, you change a magazine, or add or
-remove a cartridge from the magazine, simply do
+remove a cartridge from the magazine, simply do
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
unmount
(remove magazine)
(insert new magazine)
update slots
mount
-\end{verbatim}
+\end{lstlisting}
\normalsize
in the Console program. This will cause Bacula to request the autochanger to
that any Volumes that are currently marked as being in the magazine are marked
as no longer in the magazine, and the new list of Volumes will be marked as
being in the magazine. In addition, the Slot numbers of the Volumes will be
-corrected in Bacula's catalog if they are incorrect (added or moved).
+corrected in Bacula's catalog if they are incorrect (added or moved).
If you do not have a barcode reader on your autochanger, you have several
-alternatives.
+alternatives.
\begin{enumerate}
\item You can manually set the Slot and InChanger flag using the {\bf update
- volume} command in the Console (quite painful).
+ volume} command in the Console (quite painful).
-\item You can issue a
+\item You can issue a
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
update slots scan
-\end{verbatim}
+\end{lstlisting}
\normalsize
command that will cause Bacula to read the label on each of the cartridges in
the magazine in turn and update the information (Slot, InChanger flag) in the
- catalog. This is quite effective but does take time to load each cartridge
- into the drive in turn and read the Volume label.
+ catalog. This is quite effective but does take time to load each cartridge
+ into the drive in turn and read the Volume label.
\item You can modify the mtx-changer script so that it simulates an
- autochanger with barcodes. See below for more details.
+ autochanger with barcodes. See below for more details.
\end{enumerate}
\label{simulating}
You can simulate barcodes in your autochanger by making the {\bf mtx-changer}
script return the same information that an autochanger with barcodes would do.
This is done by commenting out the one and only line in the {\bf list)} case,
-which is:
+which is:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
${MTX} -f $ctl status | grep " *Storage Element [0-9]*:.*Full" | awk "{print \$3 \$4}" | sed "s/Full *\(:VolumeTag=\)*//"
-\end{verbatim}
+\end{lstlisting}
\normalsize
at approximately line 99 by putting a \# in column one of that line, or by
simply deleting it. Then in its place add a new line that prints the contents
-of a file. For example:
+of a file. For example:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
cat /etc/bacula/changer.volumes
-\end{verbatim}
+\end{lstlisting}
\normalsize
Be sure to include a full path to the file, which can have any name. The
-contents of the file must be of the following format:
+contents of the file must be of the following format:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
1:Volume1
2:Volume2
3:Volume3
...
-\end{verbatim}
+\end{lstlisting}
\normalsize
Where the 1, 2, 3 are the slot numbers and Volume1, Volume2, ... are the
contents of the correct file into your {\bf /etc/bacula/changer.volumes} file.
There is no need to stop and start Bacula when you change magazines, simply
put the correct data in the file, then run the {\bf update slots} command, and
-your autochanger will appear to Bacula to be an autochanger with barcodes.
+your autochanger will appear to Bacula to be an autochanger with barcodes.
\label{updateslots}
\section{The Full Form of the Update Slots Command}
If you change only one cartridge in the magazine, you may not want to scan all
Volumes, so the {\bf update slots} command (as well as the {\bf update slots
-scan} command) has the additional form:
+scan} command) has the additional form:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
update slots=n1,n2,n3-n4, ...
-\end{verbatim}
+\end{lstlisting}
\normalsize
where the keyword {\bf scan} can be appended or not. The n1,n2, ... represent
Slot numbers to be updated and the form n3-n4 represents a range of Slot
-numbers to be updated (e.g. 4-7 will update Slots 4,5,6, and 7).
+numbers to be updated (e.g. 4-7 will update Slots 4,5,6, and 7).
This form is particularly useful if you want to do a scan (time expensive) and
-restrict the update to one or two slots.
+restrict the update to one or two slots.
-For example, the command:
+For example, the command:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
update slots=1,6 scan
-\end{verbatim}
+\end{lstlisting}
\normalsize
will cause Bacula to load the Volume in Slot 1, read its Volume label and
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
update slots=1-3,6
-\end{verbatim}
+\end{lstlisting}
\normalsize
will read the barcoded Volume names for slots 1,2,3 and 6 and make the
appropriate updates in the Catalog. If you don't have a barcode reader or have
not modified the mtx-changer script as described above, the above command will
-not find any Volume names so will do nothing.
+not find any Volume names so will do nothing.
\label{FreeBSD}
\section{FreeBSD Issues}
autochanger slot. As a consequence, Bacula is unable to open the device. The
solution to the problem is to make sure that some tape is loaded into the tape
drive before starting Bacula. This problem is corrected in Bacula versions
-1.32f-5 and later.
+1.32f-5 and later.
-Please see the
-\ilink{ Tape Testing}{FreeBSDTapes} chapter of this manual for
+Please see the
+\bsysxrlink{Tape Testing}{FreeBSDTapes}{problems}{chapter} of the \problemsman{} for
{\bf important} information concerning your tape drive before doing the
-autochanger testing.
+autochanger testing.
\label{AutochangerTesting}
\section{Testing Autochanger and Adapting mtx-changer script}
Before attempting to use the autochanger with Bacula, it is preferable to
"hand-test" that the changer works. To do so, we suggest you do the
following commands (assuming that the {\bf mtx-changer} script is installed in
-{\bf /etc/bacula/mtx-changer}):
+{\bf /etc/bacula/mtx-changer}):
\begin{description}
\item [/etc/bacula/mtx-changer \ /dev/sg0 \ list \ 0 \ /dev/nst0 \ 0]
\index[sd]{mtx-changer list}
-This command should print:
+This command should print:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
1:
2:
3:
...
-
-\end{verbatim}
+
+\end{lstlisting}
\normalsize
or one number per line for each slot that is occupied in your changer, and
-the number should be terminated by a colon ({\bf :}). If your changer has
+the number should be terminated by a colon ({\bf :}). If your changer has
barcodes, the barcode will follow the colon. If an error message is printed,
you must resolve the problem (e.g. try a different SCSI control device name
if {\bf /dev/sg0} is incorrect). For example, on FreeBSD systems, the
-autochanger SCSI control device is generally {\bf /dev/pass2}.
+autochanger SCSI control device is generally {\bf /dev/pass2}.
\item [/etc/bacula/mtx-changer \ /dev/sg0 \ listall \ 0 \ /dev/nst0 \ 0]
\index[sd]{mtx-changer listall}
-This command should print:
+This command should print:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Drive content: D:Drive num:F:Slot loaded:Volume Name
D:0:F:2:vol2 or D:Drive num:E
- D:1:F:42:vol42
+ D:1:F:42:vol42
D:3:E
Slot content:
I:10:F:vol10 I:Slot num:F:Volume Name
I:11:E or I:Slot num:E
I:12:F:vol40
-
-\end{verbatim}
+
+\end{lstlisting}
\normalsize
\item [/etc/bacula/mtx-changer \ /dev/sg0 \ transfer \ 1 \ 2]
\item [/etc/bacula/mtx-changer \ /dev/sg0 \ slots ]
\index[sd]{mtx-changer slots}
-This command should return the number of slots in your autochanger.
+This command should return the number of slots in your autochanger.
\item [/etc/bacula/mtx-changer \ /dev/sg0 \ unload \ 1 \ /dev/nst0 \ 0 ]
\index[sd]{mtx-changer unload}
- If a tape is loaded from slot 1, this should cause it to be unloaded.
+ If a tape is loaded from slot 1, this should cause it to be unloaded.
\item [/etc/bacula/mtx-changer \ /dev/sg0 \ load \ 3 \ /dev/nst0 \ 0 ]
\index[sd]{mtx-changer load}
Assuming you have a tape in slot 3, it will be loaded into drive (0).
-
+
\item [/etc/bacula/mtx-changer \ /dev/sg0 \ loaded \ 0 \ /dev/nst0 \ 0]
\index[sd]{mtx-changer loaded}
-It should print "3"
+It should print "3"
Note, we have used an "illegal" slot number 0. In this case, it is simply
ignored because the slot number is not used. However, it must be specified
because the drive parameter at the end of the command is needed to select
need to insert a {\bf sleep 20} after the {\bf mtx} command, but be careful to
exit the script with a zero status by adding {\bf exit 0} after any additional
commands you add to the script. This is because Bacula checks the return
-status of the script, which should be zero if all went well.
+status of the script, which should be zero if all went well.
You can test whether or not you need a {\bf sleep} by putting the following
-commands into a file and running it as a script:
+commands into a file and running it as a script:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
#!/bin/sh
/etc/bacula/mtx-changer /dev/sg0 unload 1 /dev/nst0 0
/etc/bacula/mtx-changer /dev/sg0 load 3 /dev/nst0 0
mt -f /dev/st0 rewind
mt -f /dev/st0 weof
-\end{verbatim}
+\end{lstlisting}
\normalsize
If the above script runs, you probably have no timing problems. If it does not
-run, start by putting a {\bf sleep 30} or possibly a {\bf sleep 60} in the
+run, start by putting a {\bf sleep 30} or possibly a {\bf sleep 60} in the
script just after the mtx-changer load command. If that works, then you should
move the sleep into the actual {\bf mtx-changer} script so that it will be
-effective when Bacula runs.
+effective when Bacula runs.
A second problem that comes up with a small number of autochangers is that
they need to have the cartridge ejected before it can be removed. If this is
the case, the {\bf load 3} will never succeed regardless of how long you wait.
If this seems to be your problem, you can insert an eject just after the
-unload so that the script looks like:
+unload so that the script looks like:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
#!/bin/sh
/etc/bacula/mtx-changer /dev/sg0 unload 1 /dev/nst0 0
mt -f /dev/st0 offline
/etc/bacula/mtx-changer /dev/sg0 load 3 /dev/nst0 0
mt -f /dev/st0 rewind
mt -f /dev/st0 weof
-\end{verbatim}
+\end{lstlisting}
\normalsize
Obviously, if you need the {\bf offline} command, you should move it into the
mtx-changer script ensuring that you save the status of the {\bf mtx} command
or always force an {\bf exit 0} from the script, because Bacula checks the
-return status of the script.
+return status of the script.
As noted earlier, there are several scripts in {\bf
\lt{}bacula-source\gt{}/examples/devices} that implement the above features,
-so they may be a help to you in getting your script to work.
+so they may be a help to you in getting your script to work.
If Bacula complains "Rewind error on /dev/nst0. ERR=Input/output error." you
most likely need more sleep time in your {\bf mtx-changer} before returning to
Let's assume that you have properly defined the necessary Storage daemon
Device records, and you have added the {\bf Autochanger = yes} record to the
-Storage resource in your Director's configuration file.
+Storage resource in your Director's configuration file.
-Now you fill your autochanger with say six blank tapes.
+Now you fill your autochanger with say six blank tapes.
-What do you do to make Bacula access those tapes?
+What do you do to make Bacula access those tapes?
One strategy is to prelabel each of the tapes. Do so by starting Bacula, then
-with the Console program, enter the {\bf label} command:
+with the Console program, enter the {\bf label} command:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
./bconsole
Connecting to Director rufus:8101
1000 OK: rufus-dir Version: 1.26 (4 October 2002)
*label
-\end{verbatim}
+\end{lstlisting}
\normalsize
-it will then print something like:
+it will then print something like:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Using default Catalog name=BackupDB DB=bacula
The defined Storage resources are:
1: Autochanger
2: File
Select Storage resource (1-2): 1
-\end{verbatim}
+\end{lstlisting}
\normalsize
-I select the autochanger (1), and it prints:
+I select the autochanger (1), and it prints:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Enter new Volume name: TestVolume1
Enter slot (0 for none): 1
-\end{verbatim}
+\end{lstlisting}
\normalsize
where I entered {\bf TestVolume1} for the tape name, and slot {\bf 1} for the
-slot. It then asks:
+slot. It then asks:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Defined Pools:
1: Default
2: File
Select the Pool (1-2): 1
-\end{verbatim}
+\end{lstlisting}
\normalsize
I select the Default pool. This will be automatically done if you only have a
single pool, then Bacula will proceed to unload any loaded volume, load the
volume in slot 1 and label it. In this example, nothing was in the drive, so
-it printed:
+it printed:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Connecting to Storage daemon Autochanger at localhost:9103 ...
Sending label command ...
3903 Issuing autochanger "load slot 1" command.
3001 Device /dev/nst0 is mounted with Volume TestVolume1
You have messages.
*
-\end{verbatim}
+\end{lstlisting}
\normalsize
You may then proceed to label the other volumes. The messages will change
slightly because Bacula will unload the volume (just labeled TestVolume1)
-before loading the next volume to be labeled.
+before loading the next volume to be labeled.
Once all your Volumes are labeled, Bacula will automatically load them as they
-are needed.
+are needed.
To "see" how you have labeled your Volumes, simply enter the {\bf list
volumes} command from the Console program, which should print something like
-the following:
+the following:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
*{\bf list volumes}
Using default Catalog name=BackupDB DB=bacula
Defined Pools:
| 3 | TestVol3 | DDS-4 | Append | 0 | 0 | 30672000 | 0 | 3 |
| ... |
+-------+----------+--------+---------+-------+--------+----------+-------+------+
-\end{verbatim}
+\end{lstlisting}
\normalsize
\label{Barcodes}
The {\bf label barcodes} will cause Bacula to read the barcodes of all the
cassettes that are currently installed in the magazine (cassette holder) using
the {\bf mtx-changer} {\bf list} command. Each cassette is mounted in turn and
-labeled with the same Volume name as the barcode.
+labeled with the same Volume name as the barcode.
The {\bf update slots} command will first obtain the list of cassettes and
their barcodes from {\bf mtx-changer}. Then it will find each volume in turn
The {\bf status slots storage=xxx} command displays autochanger content.
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Slot | Volume Name | Status | Type | Pool | Loaded |
------+-----------------+----------+-------------------+----------------+---------|
1 | 00001 | Append | DiskChangerMedia | Default | 0 |
2 | 00002 | Append | DiskChangerMedia | Default | 0 |
3*| 00003 | Append | DiskChangerMedia | Scratch | 0 |
4 | | | | | 0 |
-\end{verbatim}
+\end{lstlisting}
\normalsize
If you see a {\bf *} near the slot number, you have to run {\bf update slots}
Bacula uses, which are {\bf loaded}, {\bf load}, {\bf
unload}, {\bf list}, and {\bf slots}. In addition,
each of those commands must return the information in the precise format as
-specified below:
+specified below:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
- Currently the changer commands used are:
loaded -- returns number of the slot that is loaded, base 1,
in the drive or 0 if the drive is empty.
autoloader supports barcodes. Otherwise the barcode
field is blank.
slots -- returns total number of slots in the autochanger.
-\end{verbatim}
+\end{lstlisting}
\normalsize
Bacula checks the exit status of the program called, and if it is zero, the