In a recent article, I wrote about how to setup the various tools, such as mtx-changer, to allow your tape library to work with Bacula. In this article, I'll show how I integrated this tape library into my existing Bacula configuration.
Given the previous work, I will assume you have mtx-changer working will with your tape library.
The configuration
Here are a few extracts from my bacula-dir.conf file which relate to the tape library:
# Definition of DLT tape storage device
Storage {
Name = DigitalTapeLibrary
Address = bacula.example.org
SDPort = 9103
Password = "VeryComplexPassword"
Device = "DEC TL800"
Media Type = DLT
}
And from bacula-sd.conf:
Autochanger {
Name = "DEC TL800"
Device = "DEC TZ89"
Description = Digital DLT MiniLibrary - TL891
Changer Device = /dev/pass4
Changer Command = "/usr/local/sbin/mtx-changer %c %o %S %a %d"
}
Device {
Name = "DEC TZ89"
Description = Digital DLT MiniLibrary - TL891
Media Type = DLT
Archive Device = /dev/nsa1
Autochanger = yes
Drive Index = 0
Offline On Unmount = no
Hardware End of Medium = no
BSF at EOM = yes
Backward Space Record = no
Fast Forward Space File = no
TWO EOF = yes
Spool Directory = /home/bacula/spooling-lib
Maximum Spool Size = 11759496889
Maximum Job Spool Size = 11759496889 # 10GB
}
Labelling the tapes
Here is the command to label my barcodes
*label barcodes storage="DigitalTapeLibrary"
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
Connecting to Storage daemon DigitalTapeLibrary at bacula.unixathome.org:9103 ...
3306 Issuing autochanger "slots" command.
Device "DEC TL800" has 0 slots.
No slots in changer to scan.
*
Eh? What's that?
Fixing permission issues
Oh oh! My configuration was wrong. I was using the wrong devices. My configuration (correct as show above) was incorrctly using /dev/pass1, instead of the real device /dev/pass4. This can be seen here:
$ sudo camcontrol devlist
Password:
<QUANTUM DLT7000 1E48> at scbus0 target 5 lun 0 (sa0,pass0)
<DEC TL800 (C) DEC 0326> at scbus1 target 0 lun 0 (pass4,ch0)
<DEC TZ89 (C) DEC 1837> at scbus1 target 5 lun 0 (pass3,sa1)
<HL-DT-ST DVDRAM GSA-H10A JL02> at scbus2 target 0 lun 0 (cd0,pass1)
<USB 2.0 Storage Device 0100> at scbus5 target 0 lun 0 (da0,pass2)
ch0 is the line in question.
After correcting the entry in bacula-sd.conf and restarting bacula-sd, I tried again. But, you should know, that this problem will come back to haunt me. I do know that if the external tape drive is conntected at boot time, the tape changer is /dev/pass1. If it connected after boot, it gets /dev/pass4. I want to fix that. They need to be specific devices for this to work.
$ sudo /usr/local/etc/rc.d/bacula-sd restart
Stopping bacula_sd.
Waiting for PIDS: 46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621,
46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621,
46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621,
46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621,
46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621,
46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621, 46621.
Starting bacula_sd.
All this waiting is for the tape to rewind and unmount. After making the change, I tried again:
*label barcodes storage="DigitalTapeLibrary"
Connecting to Storage daemon DigitalTapeLibrary at bacula.unixathome.org:9103 ...
3306 Issuing autochanger "slots" command.
Device "DEC TL800" has 0 slots.
No slots in changer to scan.
Still no good. OK, it must be something else. I rechecked the configuration and found it to be correct. The permissions on mtx-changer were correct:
$ ls -l /usr/local/sbin/mtx-changer
-rwxr-xr-- 1 root operator 5221 Oct 30 00:52 /usr/local/sbin/mtx-changer
Is Bacula in the operator group?
$ id bacula
uid=910(bacula) gid=910(bacula) groups=910(bacula),5(operator)
Yes, so Bacula can run mtx-changer. OK, what about the tape changer?
$ ls -l /dev/pass4
crw------- 1 root operator 0, 171 Jan 17 15:19 /dev/pass4
Hah! There's the issue. No operator permissions on that device. On FreeBSD, you can set these permissions via configuration. I added the following line to /etc/devfs.conf:
perm pass4 0660
Then I restarted devfs, and rechecked the permissions:
$ /etc/rc.d/devfs restart
$ ls -l /dev/pass4
crw-rw---- 1 root operator 0, 171 Jan 17 15:19 /dev/pass4
Ahh good! Progress. Now, let us try the command correctly, using su to run the command as the bacula user:
# su -m bacula -c '/usr/local/sbin/mtx-changer /dev/pass4 slots'
touch: /var/db/bacula/mtx.log: Permission denied
/usr/local/sbin/mtx-changer: cannot create /var/db/bacula/mtx.log: Permission de nied
/usr/local/sbin/mtx-changer: cannot create /var/db/bacula/mtx.log: Permission de nied
10
# ls -l /var/db/bacula/mtx.log
-rw-r--r-- 1 root bacula 2480 Jan 17 17:53 /var/db/bacula/mtx.log
Now we see the correct number of slots, and another permissions issue comes to light. This one is easily fixed with:
# chmod g+w /var/db/bacula/mtx.log
# ls -l /var/db/bacula/mtx.log
-rw-rw-r-- 1 root bacula 2480 Jan 17 17:53 /var/db/bacula/mtx.log
# su -m bacula -c '/usr/local/sbin/mtx-changer /dev/pass4 slots'
10
Now, let's try bconsole again:
*label barcodes storage="DigitalTapeLibrary"
Connecting to Storage daemon DigitalTapeLibrary at bacula.unixathome.org:9103 ...
3306 Issuing autochanger "slots" command.
Device "DEC TL800" has 10 slots.
Connecting to Storage daemon DigitalTapeLibrary at bacula.unixathome.org:9103 ...
3306 Issuing autochanger "list" command.
The following Volumes will be labeled:
Slot Volume
==============
1 DGG472
2 DGG440
3 DGG443
4 DGG467
5 DGG469
6 DGG442
7 DGG457
8 DGG441
9 DGG471
10 DGG465
Do you want to label these Volumes? (yes|no):
Good. Very good. Let us proceed. My replies are in bold
Do you want to label these Volumes? (yes|no): yes
Defined Pools:
1: Default
2: FilePool
Select the Pool (1-2): 1
Media record for Slot 1 Volume "DGG472" already exists.
Connecting to Storage daemon DigitalTapeLibrary at bacula.unixathome.org:9103 ...
Sending label command for Volume "DGG440" Slot 2 ...
3301 Issuing autochanger "loaded? drive 0" command.
3302 Autochanger "loaded? drive 0", result: nothing loaded.
3304 Issuing autochanger "load slot 2, drive 0" command.
3305 Autochanger "load slot 2, drive 0", status is OK.
3000 OK label. VolBytes=64512 DVD=0 Volume="DGG440" Device="DEC TZ89" (/dev/nsa1)
Catalog record for Volume "DGG440", Slot 2 successfully created.
