Home -> Enterprise Data Backup and Recovery Methods Blog -> How to Execute Tape Backup with Bacula Enterprise Edition? Tape Library Setup.

How to Execute Tape Backup with Bacula Enterprise Edition? Tape Library Setup.

  • February 15, 2019

tape backup setup in bacula enterpriseDespite the inroads made in large scale disk backup and backup to cloud strategies, magnetic tape backup remains a major component of many data protection architectures. Tape provides advantages that are hard to replace with any other technology. Factors such as data write speed, portability, reliability, ease of storage, and data density all contribute to the ongoing popularity of tape backup. Bacula Enterprise Edition supports tape libraries of all vendors, sizes, and types, in addition to cloud and disk backup, giving the customer total flexibility in storage media. This how-to will describe some of the basic setup steps and configuration notes for using tape backup for most tape libraries with Bacula Enterprise Edition. For more advanced tape libraries using ACSLS, please contact Bacula Systems for more information on our ACSLS functionality.

The Bacula Enterprise Storage Daemon is the component that manages reads and writes to the various storage devices supported by Bacula. Tape backup is managed in part by native Linux tools and therefore supported devices largely follow support in the Linux kernel. For information about whether or not a specific tape library or drive is supported by Bacula Enterprise Edition, Bacula Systems support can answer the question. However, most commercially available tape libraries and drives that are supported by the Linux kernel are supported by Bacula.

While most tape drives will work with very little configuration, there are some main things to be aware of in order to have the best possible performance and reliability. Bacula Enterprise has a web interface, BWeb, which greatly simplifies setup and provides sensible defaults, it’s good to have an understanding of what is going on underneath in the configuration files. To get an idea of how BWeb manages creation and configuration of autochangers, please watch the video here: https://www.youtube.com/watch?v=_HZ-lnt4vg0 . This video is related to installing a deduplicating disk autochanger, but the same wizard and process are used to install tape devices. The information that follows should help fill in any gaps when setting up a tape autochanger, or allow you to set up tape autochangers without the help of BWeb.

By default, Bacula Enterprise is installed with a number of functional example configurations. There’s a tape autochanger (Bacula uses the word autochanger to describe the tape library) example that should look something like the one below.


# An autochanger device with two drives
#
#Autochanger {
# Name = Autochanger
# Device = Drive-1
# Device = Drive-2
# Changer Command = "/opt/bacula/scripts/mtx-changer %c %o %S %a %d"
# Changer Device = /dev/sg0
#}

#Device {
# Name = Drive-1 #
# Drive Index = 0
# Media Type = DLT-8000
# Archive Device = /dev/nst0
# AutomaticMount = yes; # when device opened, read it
# AlwaysOpen = yes;
# RemovableMedia = yes;
# RandomAccess = no;
# AutoChanger = yes
# #
# # New alert command in Bacula Enterprise Edition 8.8.0
# # Note: you must have the sg3_utils (rpms) or the
# # sg3-utils (deb) installed on your system.
# # and you must set the correct control device that
# # corresponds to the Archive Device
# Control Device = /dev/sg?? # must be SCSI ctl for /dev/nst0
# Alert Command = "/opt/bacula/scripts/tapealert %l"
#
# #
# # Enable the Alert command only if you have the mtx package loaded
# # Note, apparently on some systems, tapeinfo resets the SCSI controller
# # thus if you turn this on, make sure it does not reset your SCSI
# # controller. I have never had any problems, and smartctl does
# # not seem to cause such problems.
# #
# Alert Command = "sh -c 'tapeinfo -f %c |grep TapeAlert|cat'"
# If you have smartctl, enable this, it has more info than tapeinfo
# Alert Command = "sh -c 'smartctl -H -l error %c'"
#}

#Device {
# Name = Drive-2 #
# Drive Index = 1
# Media Type = DLT-8000
# Archive Device = /dev/nst1
# AutomaticMount = yes; # when device opened, read it
# AlwaysOpen = yes;
# RemovableMedia = yes;
# RandomAccess = no;
# AutoChanger = yes
# # Enable the Alert command only if you have the mtx package loaded
# Alert Command = "sh -c 'tapeinfo -f %c |grep TapeAlert|cat'"
# If you have smartctl, enable this, it has more info than tapeinfo
# Alert Command = "sh -c 'smartctl -H -l error %c'"
#}

Let’s break this down a bit. To make a better configuration, we’d need to make just a few changes. First, it should have a better name to avoid confusion in the future. The device names here can change to match as well, as they are just references to the device resources we’ll look at next. Next, it’s best to use the udev device name rather than the ‘/dev/sgX’ device path, as the udev name will never change on a reboot. So that will look like ‘/dev/tape/by-id/scsi-xxxxxxxxxxxx’ The changer command usually doesn’t need to change, and you can view the script in ‘/opt/bacula/scripts/’ if you want to see how it works. So the example below is closer to a production config:


# An autochanger device with two drives
#
#Autochanger {
# Name = HPLTOLib1
# Device = HPLTOLib1-Drive-1
# Device = HPLTOLib1-Drive-2
# Changer Command = "/opt/bacula/scripts/mtx-changer %c %o %S %a %d"
# Changer Device = /dev/tape/by-id/scsi-xxxxxxxxxxxx
#}

Next, let’s look at the tape devices. As with the autochanger itself, we’ll want to rename the devices so it’s clear which device ‘owns’ them. In this case, the names must match the names in the autochanger config. We’ll also want to use the udev persistent names, as you can see below. The drive index is important; when mtx-changer issues a command such as ‘load tape x into drive y’, it uses the drive index from this device setting to determine where the tape will go. So this must match what the library itself understands the drive numbering to be. Usually it starts with drive 0.

The Media Type is an arbitrary designation given to devices within a tape library to tell Bacula which devices can be called to operate which tapes. Tapes are labeled with a media type as well. This means that, for example, if you have two LTO-7 tape drives in library A, and two in Library B, it may be best to give them different media types so that Bacula doesn’t request a mount from Library A to Library B. So in this case, we’ll the the media type to the autochanger.

Always Open means that Bacula will not rewind the tape after each write session, but rather leave the drive ready for the next append. Automatic Mount means what it sounds like; Bacula will mount and use the tape devices without user intervention. Removable Media tells Bacula that the media may not always be available in the autochanger and changes the behavior when a new tape is needed. Random Access is set to ‘no’ as tapes are read and written in a linear manner, and finally Bacula needs to know that the device is a member of an autochanger. Bacula Enterprise can also use the sg3-utils packages to send tape alert and monitoring commands, and alert you if a drive is showing errors. So the config below is pretty good, and can be copied for the second drive with just a change to the name, drive index, and archive device.


#Device {
# Name = HPLTOLib1-Drive-1 #
# Drive Index = 0
# Media Type = HPLTOLib1-LTO-7
# Archive Device = /dev/tape/by-id/scsi-xxxxxxx-nst
# AutomaticMount = yes; # when device opened, read it
# AlwaysOpen = yes;
# RemovableMedia = yes;
# RandomAccess = no;
# AutoChanger = yes
# Maximum Block Size = xxxxxxxx
# Maximum File Size = xxx
# #
# # New alert command in Bacula Enterprise Edition 8.8.0
# # Note: you must have the sg3_utils (rpms) or the
# # sg3-utils (deb) installed on your system.
# # and you must set the correct control device that
# # corresponds to the Archive Device
# Control Device = /dev/sg?? # must be SCSI ctl for /dev/nst0
# Alert Command = "/opt/bacula/scripts/tapealert %l"
#

So with the above, we could very likely have a working configuration that can load, unload, read, and write volumes. What are the next steps? First, there is a command line tool called ‘btape’ that should be run before putting anything into production. Please note that btape will destroy any data on a volume, so please use a blank tape! Within btape, there are commands to test the autochanger, test writing a full tape and making sure it can be read back, as well as performance testing tools. A successful run of the ‘btape test’ for each device, and ‘btape autochanger’ should be considered a minimum requirement.

Finally, for performance, the ‘maximum block size’ and ‘maximum file size’ should be set for each device. The values here that will yield the best performance depend mostly on the tape drive technology. Sensible defaults are set by BWeb, or can be provided by Bacula Systems Support. Block sizes usually range between 64-512k, and file size anywhere from 1-5GB. It’s best to get the current recommendations from Bacula Systems Support when possible, and then apply them and test using the btape speed test. Please note that block sizes can’t be changed easily once in production, so take the time to test beforehand.

Hopefully this has been a helpful overview of how to set up tape backup in Bacula. As always, the Bacula Main Manual has detailed information about each configuration option, as well as more example configurations. For Bacula Enterprise Edition customers, please don’t hesitate to contact support with questions as you set up tape devices.

Leave a comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>