Pages

Thursday, January 26, 2012

Using a stand alone tape with bacula

This time I want you to show how to use a stand alone tape drive with bacula. I have a couple of DDS-3 tape drives which all work with Solaris 10 X86 and bacula. Before you begin you need to know the device file for your tape drive. Under Solaris use iostat:

# iostat -En
...
rmt/0            Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Vendor: SONY     Product: SDT-9000         Revision: 0400 Serial No: 03/05/98
...

Then change into your bacula configuration directory and add the tape drive to the bacula storage device configuration like this:

# cd /opt/bacula/latest/etc
# vi bacula-sd.conf
...
Device {
  Name = DDS-3-01
  Media Type = DDS-3
  Archive Device = /dev/rmt/0n
  AutomaticMount = yes;
  AlwaysOpen = yes;
  RemovableMedia = yes;
  RandomAccess = no;
  Maximum File Size = 12GB
}
...

Also let the bacula director know that there is a tape drive available:

# vi common/storage.conf
...
Storage {
  Name = DDS-3-01
  Address = bck01
  SDPort = 9103
  Password = "QLBrhBa8ebxbTjWwy74qIfvPlTFN44dCfmymfmmL41i8"
  Device = DDS-3-01
  Media Type = DDS-3
  Autochanger = no
}
...

Then add a pool for your tapes. I called the pool etc because I want to backup all my configuration from my servers stored under /etc:

# vi common/pool.conf
...
Pool {
  Name = etc
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Volume Retention = 7 days
  Maximum Volume Bytes = 12G
  Maximum Volumes = 10
}
...

To take effect of all your changes you have to restart the bacula director and bacula storage daemon:

# kill -15 `pgrep bacula-dir`
# kill -15 `pgrep bacula-sd`
# /opt/bacula/latest/sbin/bacula-dir -c /opt/bacula/latest/etc/bacula-dir.conf
# /opt/bacula/latest/sbin/bacula-sd -c /opt/bacula/latest/etc/bacula-sd.conf

Finally label a tape to make it ready for usage. First start bconsole:

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

Then run the label command. As storage ressource use the prior defined tape. As name you can use whatever you want. I just like to number my tapes like tape01, tape02 etc:

*label
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
The defined Storage resources are:
     1: File
     2: DDS-3-01
Select Storage resource (1-2): 2
Enter new Volume name: tape01
Defined Pools:
     1: File
     2: etc
Select the Pool (1-2): 2
Connecting to Storage daemon DDS-3-01 at bck01:9103 ...
Sending label command for Volume "tape01" Slot 0 ...
3000 OK label. VolBytes=64512 DVD=0 Volume="tape01" Device="DDS-3-01" (/dev/rmt/0n)
Catalog record for Volume "tape01", Slot 0  successfully created.
Requesting to mount DDS-3-01 ...
3001 Device ""DDS-3-01" (/dev/rmt/0n)" is mounted with Volume "tape01"

If you work with different pools then it may be wise to use something like poolname1_tape01, poolname1_tape02, poolname2_tape01 etc.
When the tape is labeled then it is ready to use inside bacula. Run any job and modify it to use the new tape.
If you have these stupid Python tape drives - don't use them. The just suck:

1. under Solaris you can only use the low density device, eg /dev/rmt/1l
2. they are killing tapes like hell

Both points are just my personal experience.