Autochanger Resource
The Autochanger resource supports single or multiple drive autochangers by grouping one or more Device resources into one unit called an autochanger in Bacula (often referred to as a “tape library” by autochanger manufacturers).
If you have an Autochanger, and you want it to function correctly, you must have an Autochanger resource in your Storage conf file, and your Director’s Storage directives that want to use an Autochanger must refer to the Autochanger resource name.
Name = <Autochanger-Name> Specifies the Name of the Autochanger. This name is used in the Director’s Storage resource definition to refer to the autochanger. This directive is required.
Device = <Device-name1, device-name2, … > Specifies the names of the Device resource or resources that correspond to the autochanger device. If you have a multiple device autochanger, you must specify multiple Device names, each one referring to a separate Device resource that contains a Drive Index specification that corresponds to the drive number base zero. You may specify multiple device names on a single line separated by commas, and/or you may specify multiple Device directives. This directive is required.
Changer Device = <name-string> The specified <name-string> gives the system file name of the autochanger device name. If specified in this resource, the Changer Device name is not needed in the Device resource. If it is specified in the Device resource (see above), it will take precedence over one specified in the Autochanger resource.
Changer Command = <name-string> The <name-string> specifies an external program to be called that will automatically change volumes as required by Bacula. Most frequently, you will specify the Bacula supplied mtx-changer script as follows. If it is specified here, it does not need to be specified in the Device resource. If it is also specified in the Device resource, it will take precedence over the one specified in the Autochanger resource.
The following is an example of a valid Autochanger resource definition:
Autochanger {
Name = "LTO-8-changer"
Device = LTO-8-1, LTO-8-2, LTO-8-3
Changer Device = /dev/sg0
Changer Command = "/opt/bacula/scripts/mtx-changer %c %o %S %a %d"
}
Device {
Name = "LTO-8-1"
Drive Index = 0
Media Type = LTO-8
Autochanger = yes
Archive Device = /dev/nst0
Label Media = no
Automatic mount = yes
...
}
Device {
Name = "LTO-8-2"
Drive Index = 1
Media Type = LTO-8
Autochanger = yes
Archive Device = /dev/nst1
Label Media = no
Automatic mount = yes
...
}
Device {
Name = "LTO-8-3"
Drive Index = 2
Media Type = LTO-8
Autochanger = yes
Autoselect = no
Archive Device = /dev/nst2
Label Media = no
Automatic mount = yes
...
}
It is important to include the Autochanger = yes directive in each Device definition that belongs to an Autochanger. A device definition should not belong to more than one Autochanger resource. Also, your Device directive in the Storage resource of the Director’s conf file should have the Autochanger’s resource name rather than a name of one of the Devices.
If you have a drive that physically belongs to an Autochanger but you don’t want to have it automatically used when Bacula references the Autochanger for backups, for example, you want to reserve it for restores, you can add the directive:
Autoselect = no
to the Device resource for that drive. In that case, Bacula will not automatically select that drive when accessing the Autochanger. You can, still use the drive by referencing it by the Device name directly rather than the Autochanger name. An example of such a definition is shown above for the Device LTO-8-3, which will not be selected when the name LTO-8-changer is used in a Storage definition, but will be used if LTO-8-3 is used.
Specifying Slots When Labeling
If you add an Autochanger = yes record to the Storage resource in your Director’s configuration file, the Bacula Console will automatically prompt you for the slot number when the Volume is in the changer when you add or label tapes for that Storage device. If your mtx-changer script is properly installed, Bacula will automatically load the correct tape during the label command.
You must also set Autochanger = yes in the Storage daemon’s Device resource as we have described above in order for the autochanger to be used. See the Storage Resource in the Director’s chapter and the Device Resource in the Storage daemon 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 update the command in the Console and selecting 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 slot is non-zero 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 label barcodes command. For each tape in the changer containing a barcode, Bacula will mount the tape 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:
Pool {
Name ...
Cleaning Prefix = "CLN"
}
any slot containing a barcode of CLNxxxx
will be treated as a
cleaning tape and will not be mounted.
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).
Changing Cartridges
If you wish to insert or remove cartridges in your autochanger or you manually run the mtx program, you must first tell Bacula to release the autochanger by doing:
unmount
Change cartridges and/or run mtx
mount
If you do not do the unmount before making such a change, Bacula will become completely confused about what is in the autochanger and may stop function because it expects to have exclusive use of the autochanger while it has the drive mounted.
Dealing with Multiple Magazines
If you have several magazines or if you insert or remove cartridges from a 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.
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
unmount
Remove magazine
Insert new magazine
update slots
mount
in the Console program. This will cause Bacula to request the autochanger to return the current Volume names in the magazine. This will be done without actually accessing or reading the Volumes because the barcode reader does this during inventory when the autochanger is first turned on. Bacula will ensure 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).
If you do not have a barcode reader on your autochanger, you have several alternatives.
You can manually set the Slot and InChanger flag using the update volume command in the Console (quite painful).
You can issue a
update slots scan
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.
You can modify the script so that it simulates an autochanger with barcodes. See below for more details.
Simulating Barcodes in Autochanger
You can simulate barcodes in your autochanger by making the 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 list) case, which is:
:math: cat ${TMPFILE} | grep " Storage Element [0-9]*:.*Full" | awk "{print \$3 \$4}" | sed "s/Full *\(:VolumeTag=\)*//"
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:
cat /etc/bacula/changer.volumes
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:
1:Volume1
2:Volume2
3:Volume3 ...
Where the 1, 2, 3 are the slot numbers and Volume1, Volume2, … are the Volume names in those slots. You can have multiple files that represent the Volumes in different magazines, and when you change magazines, simply copy the contents of the correct file into your /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 update slots the command, and your autochanger will appear to Bacula to be an autochanger with barcodes. [blb:updateslots]
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 update slots command (as well as the update slots scan command) has the additional form:
update slots=n1,n2,n3-n4, ...
where the keyword 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).
This form is particularly useful if you want to do a scan (time expensive) and restrict the update to one or two slots.
For example, the command:
update slots=1,6 scan
will cause Bacula to load the Volume in Slot 1, read its Volume label and update the Catalog. It will do the same for the Volume in Slot 6. The command:
update slots=1-3,6
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.
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 mtx-changer script is installed in /opt/bacula/scripts/mtx-changer):
Make sure Bacula is not running.
/opt/bacula/scripts/mtx-changer /dev/sg0 list 0 /dev/nst0 0 This command should print:
1: 2: 3: ...or one number per line for each slot that is occupied in your changer, and the number should be terminated by a colon (:). 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 /dev/sg0 is incorrect). For example, on FreeBSD systems, the autochangerSCSI
control device is generally /dev/pass2.
/opt/bacula/scripts/mtx-changer /dev/sg0 listall 0 /dev/nst0 0 This command should print:
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:3:E Slot content: S:1:F:vol1 S:Slot num:F:Volume Name S:2:E or S:Slot num:E S:3:F:vol4 Import/Export tray slots: I:10:F:vol10 I:Slot num:F:Volume Name I:11:E or I:Slot num:E I:12:F:vol40
- /opt/bacula/scripts/mtx-changer /dev/sg0 transfer
This command should transfer a volume from source (1) to destination (2)
- /opt/bacula/scripts/mtx-changer /dev/sg0 slots
This command should return the number of slots in your autochanger.
- /opt/bacula/scripts/mtx-changer /dev/sg0 unload 1 /dev/nst0 0
If a tape is loaded from slot 1, this should cause it to be unloaded.
- /opt/bacula/scripts/mtx-changer /dev/sg0 load 3 /dev/nst0 0
Assuming you have a tape in slot 3, it will be loaded into drive (0).
- /opt/bacula/scripts/mtx-changer /dev/sg0 loaded 0 /dev/nst0 0
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 the correct drive.
- /opt/bacula/scripts/mtx-changer/dev/sg0unload3 /dev/nst00
will unload the tape into slot 3.
Once all the above commands work correctly, assuming that you have the right Changer Command in your configuration, Bacula should be able to operate the changer. The only remaining area of problems will be if your autoloader needs some time to get the tape loaded after issuing the command. After the mtx-changer script returns, Bacula will immediately rewind and read the tape. If Bacula gets rewind I/O errors after a tape change, you will probably need to insert a sleep 20 after the mtx command, but be careful to exit the script with a zero status by adding 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.
You can test whether or not you need a sleep by putting the following commands into a file and running it as a script:
#!/bin/sh
/opt/bacula/scripts/mtx-changer /dev/sg0 unload 1 /dev/nst0 0
/opt/bacula/scripts/mtx-changer /dev/sg0 load 3 /dev/nst0 0
mt -f/dev/st0 rewind
mt -f /dev/st0 weof
If the above script runs, you probably have no timing problems. If it does not run, start by putting a sleep 30 or possibly a sleep 60 in the script just after the mtx-changer load command. If that works, then you should move the sleep into the actual mtx-changer script so that it will be 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 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:
#!/bin/sh
/opt/bacula/scripts/mtx-changer /dev/sg0 unload 1 /dev/nst0 0
mt -f /dev/st0 offline
/opt/bacula/scripts/mtx-changer /dev/sg0 load 3 /dev/nst0 0
mt -f /dev/st0 rewind
mt -f /dev/st0 weof
Obviously, if you need the offline command, you should move it into the mtx-changer script ensuring that you save the status of the mtx command or always force an exit 0 from the script, because Bacula checks the return status of the script.
As noted earlier, there are several scripts in <bacula-source>/examples/devices that implement the above features, 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 mtx-changer before returning to Bacula after a load command has been completed.
Using the Autochanger
Let’s assume that you have properly defined the necessary Storage daemon Device records, and you have added the Autochanger = yes record to the Storage resource in your Director’s configuration file.
Now you fill your autochanger with say six blank 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 label command:
/opt/bacula/bin/bconsole
Connecting to Director bacula-dir:9101
1000 OK: 10002 bacula-dir Version: 16.0.5 (05 April 2023)
Enter a period to cancel a command.
*label
it will then print something like:
Using Catalog "BaculaCatalog"
The defined Storage resources are:
1: TapeAutochanger
2: DiskAutochanger
Select Storage resource (1-2):1
I select the TapeAutochanger (1), and it prints:
Connecting to Storage daemon DiskAutochanger at baculasd:9103 ...
Enter autochanger drive[0]:
Enter new Volume name: LTO-8-Tape1
Enter slot (0 or Enter for none): 1
where I entered TestVolume1 for the tape name, and slot 1 for the slot. It then asks:
Defined Pools:
1: Tape-pool
2: DiskBackup365d
Select the Pool (1-2): 1
I select the Tape-pool 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:
Connecting to Storage daemon TapeAutochanger at baculasd:9103 ...
Sending label command ...
3903 Issuing autochanger "load slot 1" command.
3000 OK label. Volume=TestVolume1 Device=/dev/nst0
Media record for Volume=TestVolume1 successfully created.
Requesting mount Autochanger ...
3001 Device /dev/nst0 is mounted with Volume TestVolume1
You have messages. \*
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.
Once all your Volumes are labeled, Bacula will automatically load them as they are needed.
To “see” how you have labeled your Volumes, simply enter the list volumes command from the Console program, which should print something like the following:
* list volumes
Using Catalog "BaculaCatalog"
Defined Pools:
1: Tape-pool
2: DiskBackup365d
Select the Pool (1-2): 1
+-------+-------------+--------+---------+-------+--------+----------+-------+------+
| MedId | VolName | MedTyp | VolStat | Bites | LstWrt | VolReten | Recyc | Slot |
+-------+-------------+--------+---------+-------+--------+----------+-------+------+
| 1 | LTO-8-Tape1 | LTO-8 | Append | 0 | 0 | 30672000 | 0 | 1 |
| 2 | LTO-8-Tape1 | LTO-8 | Append | 0 | 0 | 30672000 | 0 | 2 |
| 3 | LTO-8-Tape1 | LTO-8 | Append | 0 | 0 | 30672000 | 0 | 3 |
| ... |
+-------+-------------+--------+---------+-------+--------+----------+-------+------+
Barcode Support
Bacula provides barcode support with two Console commands, label barcodes and update slots.
The label barcodes will cause Bacula to read the barcodes of all the cassettes that are currently installed in the magazine (cassette holder) using the mtx-changer list command. Each cassette is mounted in turn and labeled with the same Volume name as the barcode.
The update slots command will first obtain the list of cassettes and their barcodes from mtx-changer. Then it will find each volume in turn in the catalog database corresponding to the barcodes and set its slot to correspond to the value just read. If the Volume is not in the catalog, then nothing will be done. This command is useful for synchronizing Bacula with the current magazine in case you have changed magazines or in case you have moved cassettes from one slot to another. If the autochanger is empty, nothing will be done.
The Cleaning Prefix statement can be used in the Pool resource to define a Volume name prefix, which if it matches that of the Volume (barcode) will cause that Volume to be marked with a VolStatus of Cleaning. This will prevent Bacula from attempting to write on the Volume.
Use bconsole to Display Autochanger Content
The status slots storage=xxx command displays autochanger content.
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 |
If you see a “*” near the slot number, you have to run update slots command to synchronize autochanger content with your catalog.
Setting Up a Tape Autochanger Using Bweb
Bacula Autochanger Interface
Bacula calls the autochanger script that you specify on the Changer Command statement. Normally this script will be the mtx-changer script that we provide, but it can in fact be any program. The only requirement for the script is that it must understand the commands that Bacula uses, which are loaded, load, unload, list, and slots. In addition, each of those commands must return the information in the precise format as specified below:
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.
load loads a specified slot (note, some autochangers require a 30 second pause after this command) into the drive.
upload unloads the device (returns cassette to its slot).
list returns one line for each cassette in the autochanger in the format <slot>:<barcode>. Where the is the non-zero integer representing the slot number, and is the barcode associated with the cassette if it exists and if you autoloader supports barcodes. Otherwise the barcode field is blank.
slot returns total number of slots in the autochanger.
Bacula checks the exit status of the program called, and if it is zero, the data is accepted. If the exit status is non-zero, Bacula will print an error message and request the tape be manually mounted on the drive.
Autochanger Support
Bacula provides autochanger support for reading and writing tapes. In order to work with an autochanger, Bacula requires a number of things, each of which is explained in more detail after this list:
A script that actually controls the autochanger according to commands sent by Bacula. We furnish such a script that works with found mtx in most linux distributions.
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 in the autochanger. This is generally done with the label command, but can also done after the tape is labeled using the update slots command. See below for more details. You must pre-label the tapes manually before using them.
Modifications to your Storage daemon’s Device configuration resource to identify that the device is a changer, as well as a few other parameters.
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.
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.
You need to have 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.
The Autochanger resource permits you to group Device resources thus creating a multi-drive autochanger. If you have a tape library with multiple drives, you must use this resource.
Bacula uses its own mtx-changer script to interface with a program that actually does the tape changing. Thus in principle, mtx-changer can be adapted to function with any autochanger program, or you can call any other script or program. The current version of mtx-changer works with the mtx program. FreeBSD users have provided a script in the examples/autochangers directory that allows Bacula to use the chio program.
Bacula also supports autochangers with barcode readers. This support includes two Console commands: label barcodes and update slots . For more details on these commands, see the “Barcode 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).
In principle, mtx if will operate your changer correctly, then it is just a question of adapting the mtx-changer script (or selecting one already adapted) for proper interfacing.
If you are having troubles, please use the auto command in the btape program to test the functioning of your autochanger with Bacula. When Bacula is running, please remember that for many distributions (e.g. FreeBSD, Debian, …) the Storage daemon runs as bacula.tape rather than root.root, so you will need to ensure that the Storage daemon has sufficient 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 volume loaded. As best we can determine, this is simply a
matter of waiting a bit. The drive was previously in use writing a
Volume, and sometimes the drive will remain BLOCKED
for a good deal
of time (up to 7 minutes on a slow drive) waiting for the cassette to
rewind and to unload before the drive can be used with a different
Volume.
Knowing What SCSI Devices You Have
Under Linux, you can
cat /proc/scsi/scsi
to see what SCSI
devices you have available. You can also:
cat /proc/scsi/sg/device_hdr /proc/scsi/sg/devices
to find out how to specify their control address (/dev/sg0 for the first, /dev/sg1 for the second, …) on the Changer Device = Bacula directive.
You can also use the excellent lsscsi tool.
$ 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
For more detailed information on what SCSI
devices you have please
see the Linux SCSI Tricks problems section of the of the
Tape Testing section of the Bacula Enterprise
Problems Resolution Guide.
Under FreeBSD, you can use:
camcontrol devlist
To list the SCSI
devices as well as the /dev/passn that you will use on the
Bacula Changer Device directive.
Please check that your Storage daemon has permission to access this device.
The tip for FreeBSD users: 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:
own pass0 root:bacula
perm pass0 0666
own nsa0.0 root:bacula
perm nsa0.0 0666
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 devices to make Bacula work when operating the AutoChanger after a reboot.
The mtx-changer script
Please read the sections below so that you understand how autochangers work with Bacula. Although we supply a default mtx-changer script, your autochanger may require some additional changes.
Slots
To properly address autochangers, Bacula must know which Volume is in each 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.
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 as InChanger. This is because it must know where each volume is (slot) to be able to load the volume.
For each Volume in your changer, you will, using the Console program, assign a slot. This information is kept in Bacula’s catalog database along with the other data for the 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 mount command on an autochanger, you must 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 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:
list Volumes
in the Console program.
Multiple Devices
Some autochangers have more than one read/write device (drive). The Autochanger resource 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 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.
Multi-drive requires the use of the Drive Index directive in the resource of the Storage daemon’s configuration file. Drive numbers or the Device Index are numbered beginning at zero (0), which is the default. To use the second Drive in an autochanger, you need to define a second resource and set the **Drive Index** to 1 for that device. In general, the second device will have the same Changer Device (control channel) as the first drive, but a different Archive Device.
As a default, Bacula jobs will prefer to write to a Volume that is already mounted and available for writing. If you have a multiple drive autochanger and you want Bacula to write to more than one Volume in the same Pool at the same time, you will probably set MaximumConcurrentJobs to 1 in each tape device. This will cause the Storage daemon to maximize the use of drives.
Device Configuration Records
Configuration of autochangers within Bacula is done in the Device resource of the Storage daemon. Four records: Autochanger, Changer Device, Changer Command, and Maximum Changer Wait control how Bacula uses the autochanger.
These four records, permitted in resources, are described in detail below. Note, however, that the Changer Device and the Changer Command directives are not needed in the resource if they are present in the Autochanger resource.
Autochanger = <yes|no> The Autochanger record specifies that the current device is or is not an autochanger. The default is no.
Changer Device = <device-name> In addition to the Archive Device name, you must specify a Changer Device name.
This is because most autochangers are controlled through a different
device than is used for reading and writing the cartridges. For
example, on Linux, one normally uses the generic SCSI
interface
for controlling the autochanger, but the standard SCSI
interface
for reading and writing the tapes. On Linux, for the Archive Device=/dev/nst0 ,
you would typically have Changer Device =/dev/sg0 . Note, some of
the more advanced autochangers will locate the changer device on /dev/sg1.
Such devices typically have several drives and a large number of
tapes.
On FreeBSD systems, the changer device will typically be on /dev/pass0 through /dev/passn.
On Solaris, the changer device will typically be some file under /dev/rdsk.
Please ensure that your Storage daemon has permission to access this device.
Changer Command = <command> This record is used to specify the external program to call and what arguments to pass to it. The command is assumed to be a standard program or 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 command before it is sent to the operating system for execution:
%% = %
%a = archive device name
%c = changer device name
%d = changer drive index base 0
%f = Client’s name
%i = JobId
%j = Job name
%l = archive control channel name
%o = command (loaded, load, or unload)
%s = Slot base 0
%S = Slot base 1
%v = Volume name
%V = Volume name from dcr->VolCatInfo first
An actual example for using with the script (part of the Bacula distribution) is:
Changer Command = "/opt/bacula/scripts/mtx-changer
Where you will need to adapt the /opt/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 Bacula Autochanger Interface section below.
Maximum Changer Wait = <time> This record is used to define the maximum amount of time that Bacula will wait for an autoloader to respond to a command (e.g. load). The default is 5 minutes. If you have a slow autoloader you may 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.
Drive Index = <number> This record allows you to tell Bacula to use the second or subsequent drive in an autochanger with multiple drives. Since the drives are numbered from zero, the second drive is defined by
Drive Index = 1
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.
In addition, for proper functioning of the Autochanger, you must define an Autochanger resource.
Note
If your tape hardware and operating system are relatively new (<10 years), they will cooperate smoothly.
See also
Go back to:
Go to:
Go back to Storage Daemon Resource Types page.
Go back to the Technical Reference for Storage Daemon.
Go back to the main Technical Reference page.