Sunday, February 5, 2012

Using bacula with mhvtl

In a prior article I showed you how to setup a virtual tape library with mhvtl. I configured a MSL600 with 48 tapes. This device I want to use with bacula now. My current setup is the bacula director running on a Solaris 10 X86 machine, but the mhvtl is running on a Slackware X86 machine. To continue I have to install the bacula storage daemon on the Slackware machine first. To install the storage daemon you have to build the complete bacula software. Download a copy of the source and store them under /usr/src. Then extract the source package and change into the new directory: 

# cd /usr/src
# tar xf bacula-5.2.3.tar.gz
# cd bacula-5.2.3

Then run the configure script followed by make and make install:

# configure --prefix=/opt/bacula/5.2.3
...
# make
...
# make install
...

After the sources were compiled go into the base installation directory and create a symbolic link to latest:

# cd /opt/bacula
# ln -s 5.2.3 latest

Next go into the configuration directory and and remove the installed configuration (I will setup a complete new one her):

# cd /opt/bacula/latest/etc
# rm -rf *

Finally configure the bacula storage daemon:

Storage {
  Name = dc01-sd
  SDPort = 9103
  WorkingDirectory = "/opt/bacula/5.2.3/var/bacula/working"
  Pid Directory = "/var/run"
  Maximum Concurrent Jobs = 20
}

Director {
  Name = bck01-dir
  Password = "QLBrhBa8ebxbTjWwy74qIfvPlTFN44dCfmymfmmL41i8"
}

Messages {
  Name = Standard
  director = bck01-dir = all
}

Autochanger {
  Name = MSL6000
  Device = Drive-1, Drive-2, Drive-3, Drive-4
  Changer Command = "/opt/bacula/latest/etc/mtx-changer %c %o %S %a %d"
  Changer Device = /dev/sg8
}

Device {
  Name = Drive-1
  Drive Index = 0
  Media Type = LTO-3
  Archive Device = /dev/nst0
  AutomaticMount = yes;
  AlwaysOpen = yes;
  AutoChanger = yes;
  LabelMedia = no;
}

Device {
  Name = Drive-2
  Drive Index = 1
  Media Type = LTO-3
  Archive Device = /dev/nst1
  AutomaticMount = yes;
  AlwaysOpen = yes;
  AutoChanger = yes;
  LabelMedia = no;
}

Device {
  Name = Drive-3
  Drive Index = 2
  Media Type = LTO-3
  Archive Device = /dev/nst2
  AutomaticMount = yes;
  AlwaysOpen = yes;
  AutoChanger = yes;
  LabelMedia = no;
}

Device {
  Name = Drive-4
  Drive Index = 3
  Media Type = LTO-3
  Archive Device = /dev/nst3
  AutomaticMount = yes;
  AlwaysOpen = yes;
  AutoChanger = yes;
  LabelMedia = no;
}

The first three sections are the normal configurations about the storage daemon itself, the director and the how to send messages. Then comes the Autochanger section which describes the autochanger in the virtual tape library. I am using a MSL6000 with four drives and the autochanger device is /dev/sg8. Check if you have the same devices and reconfigure the configuration as you need it. After the autochanger section are four Device sections for each tape drive in the library one. Again check for the devices.
Before starting the bacula storage daemon copy the mtx-changer script and mtx-changer configuration file from the sources to the bacula configuration directory:

# cp /usr/src/bacula-5.2.3/scripts/mtx-changer /opt/bacula/latest/etc/
# cp /usr/src/bacula-5.2.3/scripts/mtx-changer.conf /opt/bacula/latest/etc/

Make sure that the path for the mtx-changer script in the Autochanger section is the same where the script has been copied.
After the configuration finished try to start the bacula storage daemon:

# /opt/bacula/latest/sbin/bacula-sd -c /opt/bacula/latest/etc/bacula-sd.conf

That's it for the storage daemon. Next configure the virtual tape library in the bacula director. On the host where your bacula director run login and go into the configuration directory:

# cd /opt/bacula/latest/etc

Then configure the storage resource:

# vi common/storage.conf
...
Storage {
  Name = MSL6000
  Address = dc01
  SDPort = 9103
  Password = "QLBrhBa8ebxbTjWwy74qIfvPlTFN44dCfmymfmmL41i8"
  Device = Drive-1
  Device = Drive-2
  Device = Drive-3
  Device = Drive-4
  Media Type = LTO-3
  Autochanger = yes
}
...

And create a new pool resource for it:

# vi common/pool.conf
...
Pool {
  Name = MSL6000
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Volume Retention = 14 days
  Maximum Volume Bytes = 500M
  Maximum Volumes = 48
}
...

That's all for the director, now start bconsole and reload the configuration:

# bconsole
Connecting to Director bck01:9101
1000 OK: bck01-dir Version: 5.2.3 (16 December 2011)
Enter a period to cancel a command.
* reload

To use the virtual tape library check the content of it with all tapes etc. by running the update slots command:

*update slots
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
The defined Storage resources are:
     1: D240-File
     2: D240-Tape
     3: MSL6000
Select Storage resource (1-3): 3
Enter autochanger drive[0]:
Connecting to Storage daemon MSL6000 at dc01:9103 ...
3306 Issuing autochanger "slots" command.
Device "Drive-1" has 52 slots.
Connecting to Storage daemon MSL6000 at dc01:9103 ...
3306 Issuing autochanger "list" command.
Volume "HPS001L3" not found in catalog. Slot=1 InChanger set to zero.
Volume "HPS002L3" not found in catalog. Slot=2 InChanger set to zero.
...

Then label the tapes with their own barcodes:

*label barcodes
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
The defined Storage resources are:
     1: D240-File
     2: D240-Tape
     3: MSL6000
Select Storage resource (1-3): 3
Connecting to Storage daemon MSL6000 at dc01:9103 ...
Enter autochanger drive[0]:
Connecting to Storage daemon MSL6000 at dc01:9103 ...
3306 Issuing autochanger "slots" command.
Device "Drive-1" has 52 slots.
Connecting to Storage daemon MSL6000 at dc01:9103 ...
3306 Issuing autochanger "list" command.
The following Volumes will be labeled:
Slot  Volume
==============
   1  HPS001L3
   2  HPS002L3
...
Do you want to label these Volumes? (yes|no): yes
Defined Pools:
     1: D240-File
     2: D240-Tape
     3: MSL6000
Select the Pool (1-3): 3
Connecting to Storage daemon MSL6000 at dc01:9103 ...
Sending label command for Volume "HPS001L3" 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="HPS001L3" Device="Drive-1" (/dev/nst0)
Catalog record for Volume "HPS001L3", Slot 1  successfully created.
Sending label command for Volume "HPS002L3" Slot 2 ...
3307 Issuing autochanger "unload slot 1, drive 0" command.
3304 Issuing autochanger "load slot 2, drive 0" command.
...

After all that run a job and modify it to use the virtual tape library.