The Storage Daemon configuration file has relatively few resource definitions. However, due to the great variation in backup media and system capabilities, the storage daemon must be highly configurable. As a consequence, there are quite a large number of directives in the Device Resource definition that allow you to define all the characteristics of your Storage device (normally a tape drive). Fortunately, with modern storage devices, the defaults are sufficient, and very few directives are actually needed.
Examples of Device resource directives that are known to work for a number of common tape drives can be found in the bacula-src/examples/devices directory, and most will also be listed here.
For a general discussion of configuration file and resources including the data types recognized by Bacula, please see the ConfigurationConfigureChapter chapter of this manual. The following Storage Resource definitions must be defined:
In general, the properties specified under the Storage resource define global properties of the Storage daemon. Each Storage daemon configuration file must have one and only one Storage resource definition.
Typically on Linux systems, you will set this to: /var/run. If you are not installing Bacula in the system directories, you can use the Working Directory as defined above.
SDAddresses = { ip = { addr = 1.2.3.4; port = 1205; } ipv4 = { addr = 1.2.3.4; port = http; } ipv6 = { addr = 1.2.3.4; port = 1205; } ip = { addr = 1.2.3.4 port = 1205 } ip = { addr = 1.2.3.4 } ip = { addr = 201:220:222::2 } ip = { addr = bluedot.thun.net } }
where ip, ip4, ip6, addr, and port are all keywords. Note, that the address can be specified as either a dotted quadruple, or IPv6 colon notation, or as a symbolic name (only in the ip specification). Also, port can be specified as a number or as the mnemonic value from the /etc/services file. If a port is not specified, the default will be used. If an ip section is specified, the resolution can be made either by IPv4 or IPv6. If ip4 is specified, then only IPv4 resolutions will be permitted, and likewise with ip6.
Using this directive, you can replace both the SDPort and SDAddress directives shown below.
The following is a typical Storage daemon Storage definition.
# # "Global" Storage daemon configuration specifications appear # under the Storage resource. # Storage { Name = "Storage daemon" Address = localhost WorkingDirectory = "~/bacula/working" Pid Directory = "~/bacula/working" }
The Director resource specifies the Name of the Director which is permitted to use the services of the Storage daemon. There may be multiple Director resources. The Director Name and Password must match the corresponding values in the Director's configuration file.
Please note that if this director is being used by a Monitor, we highly recommend to set this directive to yes to avoid serious security problems.
The following is an example of a valid Director resource definition:
Director { Name = MainDirector Password = my_secret_password }
The Device Resource specifies the details of each device (normally a tape drive) that can be used by the Storage daemon. There may be multiple Device resources for a single Storage daemon. In general, the properties specified within the Device resource are specific to the Device.
As noted above, normally the Archive Device is the name of a tape drive, but you may also specify an absolute path to an existing directory. If the Device is a directory Bacula will write to file storage in the specified directory, and the filename used will be the Volume name as specified in the Catalog. If you want to write into more than one directory (i.e. to spread the load to different disk drives), you will need to define two Device resources, each containing an Archive Device with a different directory. In addition to a tape device name or a directory name, Bacula will accept the name of a FIFO. A FIFO is a special kind of file that connects two programs via kernel memory. If a FIFO device is specified for a backup operation, you must have a program that reads what Bacula writes into the FIFO. When the Storage daemon starts the job, it will wait for MaximumOpenWait seconds for the read program to start reading, and then time it out and terminate the job. As a consequence, it is best to start the read program at the beginning of the job perhaps with the RunBeforeJob directive. For this kind of device, you never want to specify AlwaysOpen, because you want the Storage daemon to open it only when a job starts, so you must explicitly set it to No. Since a FIFO is a one way device, Bacula will not attempt to read a label of a FIFO device, but will simply write on it. To create a FIFO Volume in the catalog, use the add command rather than the label command to avoid attempting to write a label.
Device { Name = FifoStorage Media Type = Fifo Device Type = Fifo Archive Device = /tmp/fifo LabelMedia = yes Random Access = no AutomaticMount = no RemovableMedia = no MaximumOpenWait = 60 AlwaysOpen = no }
During a restore operation, if the Archive Device is a FIFO, Bacula will attempt to read from the FIFO, so you must have an external program that writes into the FIFO. Bacula will wait MaximumOpenWait seconds for the program to begin writing and will then time it out and terminate the job. As noted above, you may use the RunBeforeJob to start the writer program at the beginning of the job.
The Archive Device directive is required.
The Device Type directive is not required, and if not specified, Bacula will attempt to guess what kind of device has been specified using the Archive Device specification supplied. There are several advantages to explicitly specifying the Device Type. First, on some systems, block and character devices have the same type. Secondly, if you explicitly specify the Device Type, the mount point need not be defined until the device is opened. This is the case with most removable devices such as USB that are mounted by the HAL daemon. If the Device Type is not explicitly specified, then the mount point must exist when the Storage daemon starts.
This directive was implemented in Bacula version 1.38.6.
Even though the names you assign are arbitrary (i.e. you choose the name you want), you should take care in specifying them because the Media Type is used to determine which storage device Bacula will select during restore. Thus you should probably use the same Media Type specification for all drives where the Media can be freely interchanged. This is not generally an issue if you have a single Storage daemon, but it is with multiple Storage daemons, especially if they have incompatible media.
For example, if you specify a Media Type of "DDS-4" then during the restore, Bacula will be able to choose any Storage Daemon that handles "DDS-4". If you have an autochanger, you might want to name the Media Type in a way that is unique to the autochanger, unless you wish to possibly use the Volumes in other drives. You should also ensure to have unique Media Type names if the Media is not compatible between drives. This specification is required for all devices.
In addition, if you are using disk storage, each Device resource will generally have a different mount point or directory. In order for Bacula to select the correct Device resource, each one must have a unique Media Type.
The specified name-string must be the generic SCSI device name of the autochanger that corresponds to the normal read/write Archive Device specified in the Device resource. This generic SCSI device name should be specified if you have an autochanger or if you have a standard tape drive and want to use the Alert Command (see below). For example, on Linux systems, for an Archive Device name of /dev/nst0, you would specify /dev/sg0 for the Changer Device name. Depending on your exact configuration, and the number of autochangers or the type of autochanger, what you specify here can vary. This directive is optional. See the Using AutochangersAutochangersChapter chapter of this manual for more details of using this and the following autochanger directives.
The name-string specifies an external program to be called that will automatically change volumes as required by Bacula. Normally, this directive will be specified only in the AutoChanger resource, which is then used for all devices. However, you may also specify the different Changer Command in each Device resource. Most frequently, you will specify the Bacula supplied mtx-changer script as follows:
Changer Command = "/path/mtx-changer %c %o %S %a %d"
and you will install the mtx on your system (found in the depkgs release). An example of this command is in the default bacula-sd.conf file. For more details on the substitution characters that may be specified to configure your autochanger please see the AutochangersAutochangersChapter chapter of this manual. For FreeBSD users, you might want to see one of the several chio scripts in examples/autochangers.
Note, it is not necessary to have an autochanger to use this command. The example below uses the tapeinfo program that comes with the mtx package, but it can be used on any tape drive. However, you will need to specify a Changer Device directive in your Device resource (see above) so that the generic SCSI device name can be edited into the command (with the %c).
An example of the use of this command to print Tape Alerts in the Job report is:
Alert Command = "sh -c 'tapeinfo -f %c | grep TapeAlert'"
and an example output when there is a problem could be:
bacula-sd Alert: TapeAlert[32]: Interface: Problem with SCSI interface between tape drive and initiator.
Maximum Concurrent Jobs is a directive that permits setting the maximum number of Jobs that can run concurrently on a specified Device. Using this directive, it is possible to have different Jobs using multiple drives, because when the Maximum Concurrent Jobs limit is reached, the Storage Daemon will start new Jobs on any other available compatible drive. This facilitates writing to multiple drives with multiple Jobs that all use the same Pool.
If you have Always Open = yes (recommended) and you want to use the drive for something else, simply use the unmount command in the Console program to release the drive. However, don't forget to remount the drive with mount when the drive is available or the next Bacula job will block.
For File storage, this directive is ignored. For a FIFO storage device, you must set this to No.
Please note that if you set this directive to No Bacula will release the tape drive between each job, and thus the next job will rewind the tape and position it to the end of the data. This can be a very time consuming operation. In addition, with this directive set to no, certain multiple drive autochanger operations will fail. We strongly recommend to keep Always Open set to Yes
If the removable medium is not automatically mounted (e.g. udev), then you might consider using additional Storage daemon device directives such as Requires Mount, Mount Point, Mount Command, and Unmount Command, all of which can be used in conjunction with Removable Media.
See the Edit Codesmountcodes section below for more details of the editing codes that can be used in this directive.
If you need to specify multiple commands, create a shell script.
Most frequently, you will define it as follows:
Unmount Command = "/bin/umount %m"
See the Edit Codesmountcodes section below for more details of the editing codes that can be used in this directive.
If you need to specify multiple commands, create a shell script.
You may turn off the Block Checksum (CRC32) code that Bacula uses when writing blocks to a Volume. Doing so can reduce the Storage daemon CPU usage slightly. It will also permit Bacula to read a Volume that has corrupted data.
The default is yes - i.e. the checksum is computed on write and checked on read.
We do not recommend to turn this off particularly on older tape drives or for disk Volumes where doing so may allow corrupted data to go undetected.
To force the block size to be fixed, as is the case for some non-random access devices (tape drives), set the Minimum Block Size and the Maximum Block Size to the same value (zero included). The default is that both the minimum and maximum block size are zero and the default block size is 64,512 bytes.
For example, suppose you want a fixed block size of 100K bytes, then you would specify:
Minimum block size = 100K Maximum block size = 100K
Please note that if you specify a fixed block size as shown above, the tape drive must either be in variable block size mode, or if it is in fixed block size mode, the block size (generally defined by mt) must be identical to the size specified in Bacula - otherwise when you attempt to re-read your Volumes, you will get an error.
If you want the block size to be variable but with a 64K minimum and 200K maximum (and default as well), you would specify:
Minimum block size = 64K Maximum blocksize = 256K
If no value is specified or zero is specified, the Storage daemon will use a default block size of 64,512 bytes (126 * 512).
The maximum size-in-bytes possible is 4,000,000.
Default setting for Hardware End of Medium is Yes. This function is used before appending to a tape to ensure that no previously written data is lost. We recommend if you have a non-standard or unusual tape drive that you use the btape program to test your drive to see whether or not it supports this function. All modern (after 1998) tape drives support this feature.
Default setting for Fast Forward Space File is Yes.
If you are using a Linux 2.6 kernel or other OSes such as FreeBSD or Solaris, the Offline On Unmount will leave the drive with no tape, and Bacula will not be able to properly open the drive and may fail the job. For more information on this problem, please see the description of Offline On UnmountNoTapeInDriveproblemssubsection in the Tape TestingTapeTestingChapterproblemschapter of the Bacula Enterprise Problem Resolution Guide.
If you are configuring an LTO-3 or LTO-4 tape, you probably will want to set the Maximum File Size to 2GB to avoid making the drive stop to write an EOF mark.
Note, this directive does not limit the size of Volumes that Bacula will create regardless of whether they are tape or disk volumes. It changes only the number of EOF marks on a tape and the number of block positioning records (see below) that are generated. If you want to limit the size of all Volumes for a particular device, use the Maximum Volume Size directive (above), or use the Maximum Volume Bytes directive in the Director's Pool resource, which does the same thing but on a Pool (Volume) basis.
The default size was chosen to be relatively large but not too big in the case that you are transmitting data over Internet. It is clear that on a high speed local network, you can increase this number and improve performance. For example, some users have found that if you use a value of 65,536 bytes they get five to ten times the throughput. Larger values for most users don't seem to improve performance. If you are interested in improving your backup speeds, this is definitely a place to experiment. You will probably also want to make the corresponding change in each of your File daemons conf files.
Before submitting the Mount Command, Unmount Command, or Free Space Command directives to the operating system, Bacula performs character substitution of the following characters:
%% = % %a = Archive device name %e = erase (set if cannot mount and first part) %n = part number %m = mount point
All the directives in this section are implemented only in Bacula version 1.37 and later and hence are available in version 1.38.6.
The directives: "Requires Mount", "Mount Point", "Mount Command", and "Unmount Command" apply to removable filesystems such as USB.
Most frequently, you will define it as follows:
Mount Command = "/bin/mount -t iso9660 -o ro %a %m"
For some media, you may need multiple commands. If so, it is recommended that you use a shell script instead of putting them all into the Mount Command. For example, instead of this:
Mount Command = "/usr/local/bin/mymount"
Where that script contains:
#!/bin/sh ndasadmin enable -s 1 -o w sleep 2 mount /dev/ndas-00323794-0p1 /backup
Similar consideration should be given to all other Command parameters.
Most frequently, you will define it as follows:
Unmount Command = "/bin/umount %m"
If you need to specify multiple commands, create a shell script.
For a description of the Messages Resource, please see the Messages ResourceMessagesChapter Chapter of this manual.
A example Storage Daemon configuration file might be the following:
# # Default Bacula Storage Daemon Configuration file # # For Bacula release 1.37.2 (07 July 2005) -- gentoo 1.4.16 # # You may need to change the name of your tape drive # on the "Archive Device" directive in the Device # resource. If you change the Name and/or the # "Media Type" in the Device resource, please ensure # that bacula-dir.conf has corresponding changes. # Storage { # definition of myself Name = rufus-sd Address = rufus WorkingDirectory = "$HOME/bacula/bin/working" Pid Directory = "$HOME/bacula/bin/working" Maximum Concurrent Jobs = 20 } # # List Directors who are permitted to contact Storage daemon # Director { Name = rufus-dir Password = "ZF9Ctf5PQoWCPkmR3s4atCB0usUPg+vWWyIo2VS5ti6k" } # # Restricted Director, used by tray-monitor to get the # status of the storage daemon # Director { Name = rufus-mon Password = "9usxgc307dMbe7jbD16v0PXlhD64UVasIDD0DH2WAujcDsc6" Monitor = yes } # # Devices supported by this Storage daemon # To connect, the Director's bacula-dir.conf must have the # same Name and MediaType. # Autochanger { Name = Autochanger Device = Drive-1 Device = Drive-2 Changer Command = "/home/kern/bacula/bin/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 Alert Command = "sh -c 'tapeinfo -f %c |grep TapeAlert|cat'" } 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 Alert Command = "sh -c 'tapeinfo -f %c |grep TapeAlert|cat'" } Device { Name = "HP DLT 80" Media Type = DLT8000 Archive Device = /dev/nst0 AutomaticMount = yes; # when device opened, read it AlwaysOpen = yes; RemovableMedia = yes; } #Device { # Name = SDT-7000 # # Media Type = DDS-2 # Archive Device = /dev/nst0 # AutomaticMount = yes; # when device opened, read it # AlwaysOpen = yes; # RemovableMedia = yes; #} #Device { # Name = Floppy # Media Type = Floppy # Archive Device = /mnt/floppy # RemovableMedia = yes; # Random Access = Yes; # AutomaticMount = yes; # when device opened, read it # AlwaysOpen = no; #} #Device { # Name = FileStorage # Media Type = File # Archive Device = /tmp # LabelMedia = yes; # lets Bacula label unlabeled media # Random Access = Yes; # AutomaticMount = yes; # when device opened, read it # RemovableMedia = no; # AlwaysOpen = no; #} # # A very old Exabyte with no end of media detection # #Device { # Name = "Exabyte 8mm" # Media Type = "8mm" # Archive Device = /dev/nst0 # Hardware end of medium = No; # AutomaticMount = yes; # when device opened, read it # AlwaysOpen = Yes; # RemovableMedia = yes; #} # # Send all messages to the Director, # mount messages also are sent to the email address # Messages { Name = Standard director = rufus-dir = all operator = root = mount }