The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]
Integrating the Tape Library with an existing Bacula installation 19 January 2010
Need more help on this topic? Click here
This article has no comments
Show me similar articles

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.
Media record for Slot 3 Volume "DGG443" already exists.
Sending label command for Volume "DGG467" Slot 4 ...
3307 Issuing autochanger "unload slot 2, drive 0" command.
3304 Issuing autochanger "load slot 4, drive 0" command.
3305 Autochanger "load slot 4, drive 0", status is OK.
3000 OK label. VolBytes=64512 DVD=0 Volume="DGG467" Device="DEC TZ89" (/dev/nsa1)
Catalog record for Volume "DGG467", Slot 4  successfully created.
Sending label command for Volume "DGG469" Slot 5 ...
3307 Issuing autochanger "unload slot 4, drive 0" command.
3304 Issuing autochanger "load slot 5, drive 0" command.
3305 Autochanger "load slot 5, drive 0", status is OK.
3000 OK label. VolBytes=64512 DVD=0 Volume="DGG469" Device="DEC TZ89" (/dev/nsa1)
Catalog record for Volume "DGG469", Slot 5  successfully created.
Sending label command for Volume "DGG442" Slot 6 ...
3307 Issuing autochanger "unload slot 5, drive 0" command.
3304 Issuing autochanger "load slot 6, drive 0" command.
3305 Autochanger "load slot 6, drive 0", status is OK.
3000 OK label. VolBytes=64512 DVD=0 Volume="DGG442" Device="DEC TZ89" (/dev/nsa1)
Catalog record for Volume "DGG442", Slot 6  successfully created.
Sending label command for Volume "DGG457" Slot 7 ...
3307 Issuing autochanger "unload slot 6, drive 0" command.
3304 Issuing autochanger "load slot 7, drive 0" command.
3305 Autochanger "load slot 7, drive 0", status is OK.
3000 OK label. VolBytes=64512 DVD=0 Volume="DGG457" Device="DEC TZ89" (/dev/nsa1)
Catalog record for Volume "DGG457", Slot 7  successfully created.
Sending label command for Volume "DGG441" Slot 8 ...
3307 Issuing autochanger "unload slot 7, drive 0" command.
3304 Issuing autochanger "load slot 8, drive 0" command.
3305 Autochanger "load slot 8, drive 0", status is OK.
3000 OK label. VolBytes=64512 DVD=0 Volume="DGG441" Device="DEC TZ89" (/dev/nsa1)
Catalog record for Volume "DGG441", Slot 8  successfully created.
Sending label command for Volume "DGG471" Slot 9 ...
3307 Issuing autochanger "unload slot 8, drive 0" command.
3304 Issuing autochanger "load slot 9, drive 0" command.
3305 Autochanger "load slot 9, drive 0", status is OK.
3000 OK label. VolBytes=64512 DVD=0 Volume="DGG471" Device="DEC TZ89" (/dev/nsa1)
Catalog record for Volume "DGG471", Slot 9  successfully created.
Media record for Slot 10 Volume "DGG465" already exists.
*
Oh. Well. That's a problem. All the volumes already have media records for them. That is, the Catalog already contains a record with that label. OK, easily fixed. Delete them.
Deleting Volumes

I have ten Volumes to delete from my Catalog.

+---------+------------------+-----------+---------+----------------+----------+--------------+---------+------+-----------+-----------+---------------------+
| mediaid | volumename       | volstatus | enabled | volbytes       | volfiles | volretention | recycle | slot | inchanger | mediatype | lastwritten         |
+---------+------------------+-----------+---------+----------------+----------+--------------+---------+------+-----------+-----------+---------------------+
|     248 | DGG472           | Used      |       1 |         64,512 |        0 |   31,536,000 |       1 |    1 |         1 | DLT       |                     |
|     249 | DGG443           | Used      |       1 |         64,512 |        0 |   31,536,000 |       1 |    3 |         1 | DLT       |                     |
|     250 | DGG465           | Used      |       1 |         64,512 |        0 |   31,536,000 |       1 |   10 |         1 | DLT       |                     |
|     251 | DGG440           | Append    |       1 |         64,512 |        0 |   31,536,000 |       1 |    2 |         1 | DLT       |                     |
|     252 | DGG467           | Append    |       1 |         64,512 |        0 |   31,536,000 |       1 |    4 |         1 | DLT       |                     |
|     253 | DGG469           | Append    |       1 |         64,512 |        0 |   31,536,000 |       1 |    5 |         1 | DLT       |                     |
|     254 | DGG442           | Append    |       1 |         64,512 |        0 |   31,536,000 |       1 |    6 |         1 | DLT       |                     |
|     255 | DGG457           | Append    |       1 |         64,512 |        0 |   31,536,000 |       1 |    7 |         1 | DLT       |                     |
|     256 | DGG441           | Append    |       1 |         64,512 |        0 |   31,536,000 |       1 |    8 |         1 | DLT       |                     |
|     257 | DGG471           | Append    |       1 |         64,512 |        0 |   31,536,000 |       1 |    9 |         1 | DLT       |                     |
+---------+------------------+-----------+---------+----------------+----------+--------------+---------+------+-----------+-----------+---------------------+

I can do one delete, manually, like this:

*delete volume="DGG472"
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"

This command will delete volume DGG472
and all Jobs saved on that volume from the Catalog
Are you sure you want to delete Volume "DGG472"? (yes/no): yes
*

But you can reduce typing by altering the original command, by putting yes into the line.

*label barcodes
The defined Storage resources are:
     1: File
     2: FileRemote
     3: FileRemoteTLS
     4: DLT
     5: DigitalTapeLibrary
     6: DLTRemote
     7: DLTRemoteTLS
Select Storage resource (1-7): 5
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): yes
Defined Pools:
     1: Default
     2: FilePool
Select the Pool (1-2): 1
Connecting to Storage daemon DigitalTapeLibrary at bacula.unixathome.org:9103 ..                            .
Sending label command for Volume "DGG472" Slot 1 ...
3301 Issuing autochanger "loaded? drive 0" command.
3302 Autochanger "loaded? drive 0", result: nothing loaded.
3304 Issuing autochanger "load slot 1, drive 0" command.
3305 Autochanger "load slot 1, drive 0", status is OK.
3000 OK label. VolBytes=64512 DVD=0 Volume="DGG472" Device="DEC TZ89" (/dev/nsa1                            )
Catalog record for Volume "DGG472", Slot 1  successfully created.
Sending label command for Volume "DGG440" Slot 2 ...
3307 Issuing autochanger "unload slot 1, drive 0" command.
3304 Issuing autochanger "load slot 2, drive 0" command.
3305 Autochanger "load slot 2, drive 0", status is OK.
3920 Cannot label Volume because it is already labeled: "DGG440"
Label command failed for Volume DGG440.
Sending label command for Volume "DGG443" Slot 3 ...
3307 Issuing autochanger "unload slot 2, drive 0" command.
3304 Issuing autochanger "load slot 3, drive 0" command.
3305 Autochanger "load slot 3, drive 0", status is OK.
3000 OK label. VolBytes=64512 DVD=0 Volume="DGG443" Device="DEC TZ89" (/dev/nsa1)
Catalog record for Volume "DGG443", Slot 3  successfully created.
Sending label command for Volume "DGG467" Slot 4 ...
3307 Issuing autochanger "unload slot 3, drive 0" command.
3304 Issuing autochanger "load slot 4, drive 0" command.
3305 Autochanger "load slot 4, drive 0", status is OK.
3000 OK label. VolBytes=64512 DVD=0 Volume="DGG467" Device="DEC TZ89" (/dev/nsa1)
Catalog record for Volume "DGG467", Slot 4  successfully created.
Sending label command for Volume "DGG469" Slot 5 ...
3307 Issuing autochanger "unload slot 4, drive 0" command.
3304 Issuing autochanger "load slot 5, drive 0" command.
3305 Autochanger "load slot 5, drive 0", status is OK.
3000 OK label. VolBytes=64512 DVD=0 Volume="DGG469" Device="DEC TZ89" (/dev/nsa1)
Catalog record for Volume "DGG469", Slot 5  successfully created.
Sending label command for Volume "DGG442" Slot 6 ...
3307 Issuing autochanger "unload slot 5, drive 0" command.
3304 Issuing autochanger "load slot 6, drive 0" command.
3305 Autochanger "load slot 6, drive 0", status is OK.
3000 OK label. VolBytes=64512 DVD=0 Volume="DGG442" Device="DEC TZ89" (/dev/nsa1)
Catalog record for Volume "DGG442", Slot 6  successfully created.
Sending label command for Volume "DGG457" Slot 7 ...
3307 Issuing autochanger "unload slot 6, drive 0" command.
3304 Issuing autochanger "load slot 7, drive 0" command.
3305 Autochanger "load slot 7, drive 0", status is OK.
3000 OK label. VolBytes=64512 DVD=0 Volume="DGG457" Device="DEC TZ89" (/dev/nsa1)
Catalog record for Volume "DGG457", Slot 7  successfully created.
Sending label command for Volume "DGG441" Slot 8 ...
3307 Issuing autochanger "unload slot 7, drive 0" command.
3304 Issuing autochanger "load slot 8, drive 0" command.
3305 Autochanger "load slot 8, drive 0", status is OK.
3000 OK label. VolBytes=64512 DVD=0 Volume="DGG441" Device="DEC TZ89" (/dev/nsa1)
Catalog record for Volume "DGG441", Slot 8  successfully created.
Sending label command for Volume "DGG471" Slot 9 ...
3307 Issuing autochanger "unload slot 8, drive 0" command.
3304 Issuing autochanger "load slot 9, drive 0" command.
3305 Autochanger "load slot 9, drive 0", status is OK.
3000 OK label. VolBytes=64512 DVD=0 Volume="DGG471" Device="DEC TZ89" (/dev/nsa1)
Catalog record for Volume "DGG471", Slot 9  successfully created.
Sending label command for Volume "DGG465" Slot 10 ...
3307 Issuing autochanger "unload slot 9, drive 0" command.
3304 Issuing autochanger "load slot 10, drive 0" command.
3305 Autochanger "load slot 10, drive 0", status is OK.
3000 OK label. VolBytes=64512 DVD=0 Volume="DGG465" Device="DEC TZ89" (/dev/nsa1)
Catalog record for Volume "DGG465", Slot 10  successfully created.
*

Phew. That's the tapes labelled.

Done, but not finished

There are still a few things to sort out:

  • ensuring the devices are always the same regardless of whether they are att at boot time.
  • making sure Bacula uses sa0 unless I tell it to use sa1. I don't want the tape library used unless I'm away
  • verify that /boot/devices.hints contains the rights stuff to do the above

Achieving these goals won't be done today. So they will be left for a future article. Enjoy.


Need more help on this topic? Click here
This article has no comments
Show me similar articles