%%
%%

\section*{Storage Daemon Configuration}
\label{_ChapterStart31}
\index[general]{Storage Daemon Configuration}
\index[general]{Configuration!Storage Daemon}
\addcontentsline{toc}{section}{Storage Daemon Configuration}

\subsection*{General}
\index[general]{General}
\addcontentsline{toc}{subsection}{General}

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 {\bf Device} resource directives that are known to work for a
number of common tape drives can be found in the {\bf
\lt{}bacula-src\gt{}/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 {\bf Bacula}, please see the 
\ilink{Configuration}{_ChapterStart16} chapter of this manual. The
following Storage Resource definitions must be defined: 

\begin{itemize}
\item 
   \ilink{Storage}{StorageResource} -- to define the  name of the
   Storage daemon.  
\item 
   \ilink{Director}{DirectorResource1} -- to  define the Director's
   name and his access password.  
\item 
   \ilink{Device}{DeviceResource} -- to define  the
   characteristics of your storage device (tape  drive).  
\item 
   \ilink{Messages}{_ChapterStart15} -- to define where error  and
   information messages are to be sent. 
\end{itemize}

\subsection*{Storage Resource}
\label{StorageResource}
\index[general]{Resource!Storage}
\index[general]{Storage Resource}
\addcontentsline{toc}{subsection}{Storage Resource}

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. 

\begin{description}

\item [Name = \lt{}Storage-Daemon-Name\gt{}]
   \index[sd]{Name }
   Specifies the Name of the Storage daemon. This  directive is required. 

\item [Working Directory = \lt{}Directory\gt{}]
   \index[sd]{Working Directory }
   This directive  is mandatory and specifies a directory in which the Storage
   daemon  may put its status files. This directory should be used only  by {\bf
   Bacula}, but may be shared by other Bacula daemons provided the names
   given to each daemon are unique. This  directive is
   required  

\item [Pid Directory = \lt{}Directory\gt{}]
   \index[sd]{Pid Directory }
   This directive  is mandatory and specifies a directory in which the Director 
   may put its process Id file files. The process Id file is used to  shutdown
   Bacula and to prevent multiple copies of  Bacula from running simultaneously. 
   This directive is required. Standard shell expansion of the {\bf Directory} 
   is done when the configuration file is read so that values such  as {\bf
   \$HOME} will be properly expanded.  

   Typically on Linux systems, you will set this to:  {\bf /var/run}. If you are
   not installing Bacula in the  system directories, you can use the {\bf Working
   Directory} as  defined above. 

\item [Heartbeat Interval = \lt{}time-interval\gt{}]
   \index[sd]{Heartbeat Interval }
   \index[general]{Heartbeat Interval}
   \index[general]{Broken pipe}
   This directive defines an interval of time.  When the Storage daemon is
   waiting for the operator to mount a tape, each time interval, it will
   send a heartbeat signal to the File daemon.  The default interval is
   zero which disables the heartbeat.  This feature is particularly useful
   if you have a router such as 3Com that does not follow Internet
   standards and times out an valid connection after a short duration 
   despite the fact that keepalive is set. This usually results
   in a broken pipe error message.

\item [Maximum Concurrent Jobs = \lt{}number\gt{}]
   \index[sd]{Maximum Concurrent Jobs}
   where \lt{}number\gt{} is the maximum number of Jobs that should run
   concurrently.  The default is set to 10, but you may set it to a larger
   number.  Each contact from the Director (e.g.  status request, job start
   request) is considered as a Job, so if you want to be able to do a {\bf
   status} request in the console at the same time as a Job is running, you
   will need to set this value greater than 1.  To run simultaneous Jobs,
   you will need to set a number of other directives in the Director's
   configuration file.  Which ones you set depend on what you want, but you
   will almost certainly need to set the {\bf Maximum Concurrent Jobs} in
   the Storage resource in the Director's configuration file and possibly
   those in the Job and Client resources.

\item [SDAddresses = \lt{}IP-address-specification\gt{}]
   \index[sd]{SDAddresses}
   Specify the ports and addresses on which the Storage daemon will listen
   for Director connections.  Normally, the default is sufficient and you
   do not need to specify this directive.  Probably the simplest way to
   explain how this directive works is to show an example:

\footnotesize
\begin{verbatim}
 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
    }
}
\end{verbatim}
\normalsize

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. 

\item [SDPort = \lt{}port-number\gt{}]
   \index[sd]{SDPort }
   Specifies port number on which the Storage daemon  listens for Director
   connections. The default is 9103.  
   
\item [SDAddress = \lt{}IP-Address\gt{}]
   \index[sd]{SDAddress }
   This directive is optional,  and if it is specified, it will cause the Storage
   daemon server (for  Director and File daemon connections) to bind to the
   specified  {\bf IP-Address}, which is either a domain name or an IP address 
   specified as a dotted quadruple. If this directive is not specified,  the
   Storage daemon will bind to any available address (the default).

\end{description}

The following is a typical Storage daemon Storage definition. 

\footnotesize
\begin{verbatim}
#
# "Global" Storage daemon configuration specifications appear
# under the Storage resource.
#
Storage {
  Name = "Storage daemon"
  Address = localhost
  WorkingDirectory = "~/bacula/working"
  Pid    Directory = "~/bacula/working"
}
\end{verbatim}
\normalsize

\subsection*{Director Resource}
\label{DirectorResource1}
\index[general]{Director Resource}
\index[general]{Resource!Director}
\addcontentsline{toc}{subsection}{Director Resource}

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.

\begin{description}

\item [Name = \lt{}Director-Name\gt{}]
   \index[sd]{Name }
   Specifies the Name of the Director allowed to connect  to the Storage daemon.
   This directive is required.  

\item [Password = \lt{}Director-password\gt{}]
   \index[sd]{Password }
   Specifies the password that must be supplied by the above named  Director.
   This directive is required.  

\item [Monitor = \lt{}yes|no\gt{}]
   \index[sd]{Monitor }
   If Monitor is set to {\bf no} (default), this director will have full
   access to this Storage daemon.  If Monitor is set to {\bf yes}, this
   director will only be able to fetch the current status of this Storage
   daemon.

   Please note that if this director is being used by a Monitor, we highly 
   recommend to set this directive to {\bf yes} to avoid serious security 
   problems. 

\end{description}

The following is an example of a valid Director resource definition: 

\footnotesize
\begin{verbatim}
Director {
  Name = MainDirector
  Password = my_secret_password
}
\end{verbatim}
\normalsize

\label{DeviceResource}
\subsection*{Device Resource}
\index[general]{Resource!Device}
\index[general]{Device Resource}
\addcontentsline{toc}{subsection}{Device Resource}

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.

\begin{description}

\item [Name = {\it Device-Name}]
   \index[sd]{Name }
   Specifies the Name that the Director will use when asking to backup or
   restore to or from to this device. This is the logical  Device name, and may
   be any string up to 127 characters in length.  It is generally a good idea to
   make it correspond to the English  name of the backup device. The physical
   name of the device is  specified on the {\bf Archive Device} directive
   described below.  The name you specify here is also used in your Director's
   conf  file on the 
   \ilink{Device directive}{StorageResource2}  in its Storage
   resource. 

\item [Archive Device = {\it name-string}]
   \index[sd]{Archive Device }
   The specified {\bf name-string} gives the system file name of the  storage
   device managed by this storage daemon. This will usually be  the device file
   name of a removable storage device (tape drive),  for example "{\bf
   /dev/nst0}" or "{\bf /dev/rmt/0mbn}".  For a DVD-writer, it will be for
   example {\bf /dev/hdc}.  It may also be a directory name if you are archiving
   to disk storage.  In this case, you must supply the full absolute path to the
   directory.  When specifying a tape device, it is preferable that the 
   "non-rewind" variant of the device file name be given.  In addition, on
   systems such as Sun, which have multiple tape  access methods, you must be
   sure to specify to use  Berkeley I/O conventions with the device. The {\bf b}
   in the Solaris (Sun)  archive specification {\bf /dev/rmt/0mbn} is what is
   needed in  this case. Bacula does not support SysV tape drive behavior.  
   
   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 {\bf 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 {\bf RunBeforeJob}  directive. For this
   kind of device, you never want to specify  {\bf AlwaysOpen}, because you want
   the Storage daemon to open it only  when a job starts, so you must explicitly
   set it to {\bf 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 {\bf add} command rather than  then {\bf
   label} command to avoid attempting to write a label.  
   
   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 {\bf 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 {\bf RunBeforeJob}  to start the writer program
   at the beginning of the job.  
   
   The Archive Device directive is required. 

\item [Media Type = {\it name-string}]
   \index[sd]{Media Type }
   The specified {\bf name-string} names the type of media supported  by this
   device, for example, "DLT7000". Media type names  are arbitrary in that you
   set it to anything you want, but  must be known to the volume database to keep
   track of which  storage daemons can read which volumes. The same  {\bf
   name-string} must appear in the appropriate Storage  resource definition in
   the Director's configuration file.  
   
   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. 

\label{Autochanger}
\item [Autochanger = {\it Yes|No}]
   \index[sd]{Autochanger}
   If {\bf Yes}, this device belongs to an automatic tape changer, and  you should also
   specify a {\bf Changer Device} as well as  a {\bf Changer Command}.  If {\bf
   No} (default), the volume must be manually changed.  You should also
   have an identical directive to the  
   \ilink{Storage resource}{Autochanger1}  in the Director's
   configuration file so that  when labeling tapes you are prompted for the slot.

\item [Changer Device = {\it name-string}]
   \index[sd]{Changer Device }
   The specified {\bf name-string} must be the {\bf generic SCSI} device
   name of the autochanger that corresponds to the normal read/write
   {\bf Archive Device}  specified in the Device resource. This
   gemeric SCSI device name should be specified if you have an autochanger 
   or if you have a standard tape drive and want to use the
   {\bf Alert Command} (see below). For example, on Linux systems, for 
   an Archive Device name of {\bf /dev/nst0}, you would specify {\bf
   /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 \ilink{ Using Autochangers}{_ChapterStart18} chapter
   of this manual for more details of using this and the following
   autochanger directives.

\item [Changer Command = {\it name-string}]
   \index[sd]{Changer Command }
   The {\bf name-string} specifies an external program to be called  that will
   automatically change volumes as required by {\bf Bacula}.  Most frequently,
   you will specify the Bacula supplied {\bf mtx-changer}  script as follows:  

\footnotesize
\begin{verbatim}
Changer Command = "/path/mtx-changer %c %o %S %a %d"
\end{verbatim}
\normalsize

   and you will install the {\bf mtx} on your system (found  in the {\bf 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 
   \ilink{Autochangers}{_ChapterStart18} chapter of this  manual.
   For FreeBSD users, you might want to see one of the  several {\bf chio}
   scripts in {\bf examples/autochangers}.  

\item [Alert Command = {\it name-string}]
   \index[sd]{Alert Command }
   The {\bf name-string} specifies an external program to be called  at the
   completion of each Job after the device is released.  The purpose of this
   command is to check for Tape Alerts, which  are present when something is
   wrong with your tape drive  (at least for most modern tape drives).  The same
   substitution characters that may be specified  in the Changer Command may also
   be used in this string.  For more information, please see  the 
   \ilink{Autochangers}{_ChapterStart18} chapter of this  manual. 
   
   
   Note, it is not necessary to have an autochanger to use this  command. The
   example below uses the {\bf tapeinfo} program  that comes with the {\bf mtx}
   package, but it can be used  on any tape drive. However, you will need to
   specify  a {\bf 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:  

\footnotesize
\begin{verbatim}
Alert Command = "sh -c 'tapeinfo -f %c | grep TapeAlert'"
      
\end{verbatim}
\normalsize

and an example output when there is a problem could be:  

\footnotesize
\begin{verbatim}
bacula-sd  Alert: TapeAlert[32]: Interface: Problem with SCSI interface
                  between tape drive and initiator.
      
\end{verbatim}
\normalsize

\item [Drive Index = {\it number}]
   \index[sd]{Drive Index}
   The {\bf Drive Index} that you specify is passed to the  {\bf mtx-changer}
   script and is thus passed to the {\bf mtx}  program. By default, the Drive
   Index is zero, so if you have only  one drive in your autochanger, everything
   will work normally.  However, if you have multiple drives, you may specify two
   Bacula  Device resources. The first will either set Drive Index to zero,  or
   leave it unspecified, and the second Device Resource should  contain a Drive
   Index set to 1. This will then permit you to  use two or more drives in your
   autochanger. However, you must ensure  that Bacula does not request the same
   Volume on both drives  at the same time. You may also need to modify the
   mtx-changer  script to do locking so that two jobs don't attempt to use  the
   autochanger at the same time. An example script can  be found in {\bf
   examples/autochangers/locking-mtx-changer}.

\item [Autoselect = {\it Yes|No}]
   \index[sd]{Autoselect}
   If this directive is set to {\bf yes} (default), and the Device
   belongs to an autochanger, then when the Autochanger is referenced
   by the Director, this device can automatically be selected. If this
   directive is set to {\bf no}, then the Device can only be referenced
   by directly using the Device name in the Director. This is useful
   for reserving a drive for something special such as a high priority
   backup or restore operations.

\item [Maximum Changer Wait = {\it seconds}]
   \index[sd]{Maximum Changer Wait}
   This directive specifies the maximum time in seconds for Bacula to wait
   for an autochanger to change the volume.  If this time is exceeded,
   Bacula will invalidate the Volume slot number stored in the catalog and
   try again.  If no additional changer volumes exist, Bacula will ask the
   operator to intervene.  The default is 5 minutes.      

   Please note that if you want to set your changer wait time to
   10 minutes, you must specify:

\begin{verbatim}
Maximum Changer Wait = 600
\end{verbatim}

   This directive will not accept qualifiers (such as "minutes").

\item [Maximum Rewind Wait = {\it seconds}]
   \index[sd]{Maximum Rewind Wait}
   This directive specifies the maximum time in seconds for Bacula to wait
   for a rewind before timing out.  If this time is exceeded,
   Bacula will cancel the job.  The default is 5 minutes.

\item [Maximum Open Wait = {\it seconds}]
   \index[sd]{Maximum Open Wait}
   This directive specifies the maximum time in seconds for Bacula to wait
   for a open before timing out.  If this time is exceeded,
   Bacula will cancel the job.  The default is 5 minutes.

\item [Always Open = {\it Yes|No}]
   \index[sd]{Always Open }
   If {\bf Yes} (default), Bacula will always keep the device open unless
   specifically {\bf unmounted} by the Console program.  This permits
   Bacula to ensure that the tape drive is always available.  If you set
   {\bf AlwaysOpen} to {\bf no} {\bf Bacula} will only open the drive when
   necessary, and at the end of the Job if no other Jobs are using the
   drive, it will be freed.  The next time Bacula wants to append to a tape
   on a drive that was freed, Bacula must rewind the tape and position to
   the end.  To avoid unnecessary tape positioning and to minimize
   unnecessary operator intervention, it is highly recommended that {\bf
   Always Open = yes}.  This also ensures that the drive is available when
   Bacula needs it.
   
   If you have {\bf Always Open = yes} (recommended) and you want  to use the
   drive for something else, simply use the {\bf unmount}  command in the Console
   program to release the drive. However, don't  forget to remount the drive with
   {\bf 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 {\bf No}.  
   
   Please note that if you set this directive to {\bf 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. 

\item [Volume Poll Interval = {\it time}]
   \index[sd]{Volume Poll Interval }
   If the time  specified on this directive is non-zero, after  asking the
   operator to mount a new volume Bacula will  periodically poll (or read) the
   drive at the specified  interval to see if a new volume has been mounted. If
   the  time interval is zero (the default), no polling will occur.  This
   directive can be useful if you want to avoid operator  intervention via the
   console. Instead, the operator can  simply remove the old volume and insert
   the requested one,  and Bacula on the next poll will recognize the new tape
   and  continue. Please be aware that if you set this interval  too small, you
   may excessively wear your tape drive if the  old tape remains in the drive,
   since Bacula will read it on  each poll. This can be avoided by ejecting the
   tape using  the {\bf Offline On Unmount} and the {\bf Close on Poll} 
   directives. 
   However, 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
   \ilink{description of Offline On Unmount}{NoTapeInDrive} in the Tape
   Testing chapter.

\item [Close on Poll= {\it Yes|No}]
   \index[sd]{Close on Poll}
   If {\bf Yes}, Bacula close the device (equivalent to  an unmount except no
   mount is required) and reopen it at each  poll. Normally this is not too
   useful unless you have the  {\bf Offline on Unmount} directive set, in which
   case the  drive will be taken offline preventing wear on the tape  during any
   future polling. Once the operator inserts a new  tape, Bacula will recognize
   the drive on the next poll and  automatically continue with the backup. 
   Please see above more more details.

\item [Maximum Open Wait = {\it seconds}]
   \index[sd]{Maximum Open Wait }
   This directive specifies the maximum amount of time in seconds that
   Bacula will wait for a device that is busy.  The default is 5 minutes.
   If the device cannot be obtained, the current Job will be terminated in
   error.  Bacula will re-attempt to open the drive the next time a Job
   starts that needs the the drive.

\item [Removable media = {\it Yes|No}]
   \index[sd]{Removable media }
   If {\bf Yes}, this device supports removable media (for  example, tapes or
   CDs). If {\bf No}, media cannot be removed  (for example, an intermediate
   backup area on a hard disk).  

\item [Random access = {\it Yes|No}]
   \index[sd]{Random access }
   If {\bf Yes}, the archive device is assumed to be a random  access medium
   which supports the {\bf lseek} (or  {\bf lseek64} if Largefile is enabled
   during configuration) facility.  

\item [Minimum block size = {\it size-in-bytes}]
   \index[sd]{Minimum block size }
   On most modern tape drives, you will not need or wamt to specify this
   directive, and if you do so, it will be to make Bacula use fixed block
   sizes.  This statement applies only to non-random access devices (e.g.
   tape drives).  Blocks written by the storage daemon to a non-random
   archive device will never be smaller than the given {\bf size-in-bytes}.
   The Storage daemon will attempt to efficiently fill blocks with data
   received from active sessions but will, if necessary, add padding to a
   block to achieve the required minimum size.
   
   To force the block size to be fixed, as is the case for some non-random
   access devices (tape drives), set the {\bf Minimum block size} and the
   {\bf 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.  If you wish the block size to be fixed and
   different from the default, specify the same value for both {\bf Minimum
   block size} and {\bf Maximum block size}.
   
   For  example, suppose you want a fixed block size of 100K bytes, then you 
   would specify:  

\footnotesize
\begin{verbatim}
 
    Minimum block size = 100K
    Maximum block size = 100K
    
\end{verbatim}
\normalsize

   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 {\bf mt}) {\bf 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:  

\footnotesize
\begin{verbatim}
 
    Minimum block size = 64K
    Maximum blocksize = 200K
   
\end{verbatim}
\normalsize

\item [Maximum block size = {\it size-in-bytes}]
   \index[sd]{Maximum block size }
   On most modern tape drives, you will not need to specify this directive.
   If you do so, it will most likely be to use fixed block sizes (see
   Minimum block size above).  The Storage daemon will aways attempt to
   write blocks of the specified {\bf size-in-bytes} to the archive device.
   As a consequence, this statement specifies both the default block size
   and the maximum block size.  The size written never exceed the given
   {\bf size-in-bytes}.  If adding data to a block would cause it to exceed
   the given maximum size, the block will be written to the archive device,
   and the new data will begin a new block.
   
   If no value is specified or zero is specified, the Storage daemon will
   use a default block size of 64,512 bytes (126 * 512).

\item [Hardware End of Medium = {\it Yes|No}]
   \index[sd]{Hardware End of Medium }
   If {\bf No}, the archive device is not required to support end  of medium
   ioctl request, and the storage daemon will use the forward  space file
   function to find the end of the recorded data. If  {\bf Yes}, the archive
   device must support the {\tt ioctl}  {\tt MTEOM} call, which will position the
   tape to the end of the  recorded data. In addition, your SCSI driver must keep
   track  of the file number on the tape and report it back correctly by  the
   {\bf MTIOCGET} ioctl. Note, some SCSI drivers will correctly  forward space to
   the end of the recorded data, but they do not  keep track of the file number.
   On Linux machines, the SCSI driver  has a {\bf fast-eod} option, which if set
   will cause the driver  to lose track of the file number. You should ensure
   that this  option is always turned off using the {\bf mt} program.  
   
   Default setting for Hardware End of Medium is {\bf 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 {\bf btape} program  to test your drive to see whether or not it
   supports this function.  All modern (after 1998) tape drives support this
   feature.  
   
\item [Fast Forward Space File = {\it Yes|No}]
   \index[sd]{Fast Forward Space File }
   If {\bf No}, the archive device is not required to support  keeping track of
   the file number ({\bf MTIOCGET} ioctl) during  forward space file. If {\bf
   Yes}, the archive device must support  the {\tt ioctl} {\tt MTFSF} call, which
   virtually all drivers  support, but in addition, your SCSI driver must keep
   track of the  file number on the tape and report it back correctly by the 
   {\bf MTIOCGET} ioctl. Note, some SCSI drivers will correctly  forward space,
   but they do not keep track of the file number or more  seriously, they do not
   report end of meduim.  
   
   Default setting for Fast Forward Space File is {\bf Yes}.
   
\item [Use MTIOCGET = {\it Yes|No}]
   \index[sd]{Fast Forward Space File }
   If {\bf No}, the operating system is not required to support keeping track of
   the file number and reporting it in the ({\bf MTIOCGET} ioctl). The default
   is {\bf Yes}. If you must set this to No, Bacula will do the proper file
   position determination, but it is very unfortunate because it means that 
   tape movement is very inefficient.
   Fortunately, this operation system deficiency seems to be the case only
   on a few *BSD systems.  Operating systems known to work correctly are
   Solaris, Linux and FreeBSD.

\item [BSF at EOM = {\it Yes|No}]
   \index[sd]{BSF at EOM }
   If {\bf No}, the default, no special action is taken by  Bacula with the End
   of Medium (end of tape) is reached because  the tape will be positioned after
   the last EOF tape mark, and  Bacula can append to the tape as desired.
   However, on some  systems, such as FreeBSD, when Bacula reads the End of
   Medium  (end of tape), the tape will be positioned after the second  EOF tape
   mark (two successive EOF marks indicated End of  Medium). If Bacula appends
   from that point, all the appended  data will be lost. The solution for such
   systems is to  specify {\bf BSF at EOM} which causes Bacula to backspace  over
   the second EOF mark. Determination of whether or not  you need this directive
   is done using the {\bf test} command  in the {\bf btape} program.

\item [TWO EOF = {\it Yes|No}]
   \index[sd]{TWO EOF }
   If {\bf Yes}, Bacula will write two end of file marks when  terminating a tape
-- i.e. after the last job or at the end of  the medium. If {\bf No}, the
default, Bacula will only write  one end of file to terminate the tape. 

\item [Backward Space Record = {\it Yes|No}]
   \index[sd]{Backward Space Record}
   If {\it Yes}, the archive device supports the {\tt MTBSR  ioctl} to backspace
   records. If {\it No}, this call is not  used and the device must be rewound
   and advanced forward to the  desired position. Default is {\bf Yes} for non
   random-access  devices. This function if enabled is used at the end of a 
   Volume after writing the end of file and any ANSI/IBM labels to determine whether
   or not the last block was written correctly. If you turn this function off,
   the test will not be done. This causes no harm as the re-read process is
   precautionary rather than required.

\item [Backward Space File = {\it Yes|No}]
   \index[sd]{Backward Space File }
   If {\it Yes}, the archive device supports the {\bf MTBSF} and  {\bf MTBSF
  ioctl}s to backspace over an end of file mark and to the  start of a file. If
  {\it No}, these calls are not used and the  device must be rewound and
  advanced forward to the desired position.  Default is {\bf Yes} for non
  random-access devices. 

\item [Forward Space Record = {\it Yes|No}]
   \index[sd]{Forward Space Record }
   If {\it Yes}, the archive device must support the {\bf MTFSR  ioctl} to
   forward space over records. If {\bf No}, data must  be read in order to
   advance the position on the device. Default is  {\bf Yes} for non
   random-access devices. 

\item [Forward Space File = {\it Yes|No}]
   \index[sd]{Forward Space File }
   If {\bf Yes}, the archive device must support the {\tt MTFSF  ioctl} to
   forward space by file marks. If {\it No}, data  must be read to advance the
   position on the device. Default is  {\bf Yes} for non random-access devices. 

\item [Offline On Unmount = {\it Yes|No}]
   \index[sd]{Offline On Unmount }
   The default for this directive is {\bf No}. If {\bf Yes} the  archive device
   must support the {\tt MTOFFL ioctl} to rewind and  take the volume offline. In
   this case, Bacula will issue the  offline (eject) request before closing the
   device during the {\bf unmount}  command. If {\bf No} Bacula will not attempt
   to offline the  device before unmounting it. After an offline is issued,  the
   cassette will be ejected thus {\bf requiring operator intervention}  to
   continue, and on some systems require an explicit load command  to be issued
   ({\bf mt -f /dev/xxx load}) before the system will recognize  the tape. If you
   are using an autochanger, some devices  require an offline to be issued prior
   to changing the volume. However,  most devices do not and may get very
   confused.  

   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
   \ilink{description of Offline On Unmount}{NoTapeInDrive} in the Tape
   Testing chapter.


\item [Maximum Volume Size = {\it size}]
   \index[sd]{Maximum Volume Size }
   No more than {\bf size} bytes will be written onto a given volume on the
   archive device.  This directive is used mainly in testing Bacula to
   simulate a small Volume.  It can also be useful if you wish to limit the
   size of a File Volume to say less than 2GB of data.  In some rare cases
   of really antiquated tape drives that do not properly indicate when the
   end of a tape is reached during writing (though I have read about such
   drives, I have never personally encountered one).  Please note, this
   directive is deprecated (being phased out) in favor of the {\bf Maximum
   Volume Bytes} defined in the Director's configuration file.

\item [Maximum File Size = {\it size}]
   \index[sd]{Maximum File Size }
   No more than {\bf size} bytes will be written into a given logical file
   on the volume.  Once this size is reached, an end of file mark is
   written on the volume and subsequent data are written into the next
   file.  Breaking long sequences of data blocks with file marks permits
   quicker positioning to the start of a given stream of data and can
   improve recovery from read errors on the volume.  The default is one
   Gigabyte.

\item [Block Positioning = {\it yes|no}]
   \index[sd]{Block Positioning }
   This directive is not normally used (and has not yet been  tested). It will
   tell Bacula not to use block positioning when  it is reading tapes. This can
   cause Bacula to be {\bf extremely}  slow when restoring files. You might use
   this directive if you  wrote your tapes with Bacula in variable block mode
   (the default),  but your drive was in fixed block mode. If it then works as  I
   hope, Bacula will be able to re-read your tapes. 

\item [Maximum Network Buffer Size = {\it bytes}]
   \index[sd]{Maximum Network Buffer Size }
   where {\it bytes} specifies the initial network buffer  size to use with the
   File daemon.  This size will be adjusted down if it is too large until
   it is accepted by the OS. Please use care in setting this value since if
   it is too large, it will be trimmed by 512 bytes until the OS is happy,
   which may require a large number of system calls.  The default value is
   32,768 bytes.

   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 5-10 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.


\item [Maximum Spool Size = {\it bytes}]
   \index[sd]{Maximum Spool Size }
   where the bytes specify the maximum spool size for all jobs  that are running.
   The default is no limit. 

\item [Maximum Job Spool Size = {\it bytes}]
   \index[sd]{Maximum Job Spool Size }
   where the bytes specify the maximum spool size for any one job  that is
   running. The default is no limit. 
   This directive is implemented only in version 1.37 and later.

\item [Spool Directory = {\it directory}]
   \index[sd]{Spool Directory }
   specifies the name of the directory to be used to store  the spool files for
   this device. This directory is also used to store  temporary part files when
   writing to a device that requires mount (DVD).  The default is to use the
   working directory. 

\item [Maximum Part Size = {\it bytes}]
   \index[sd]{Maximum Part Size }
   This is the maximum size of a volume part file. The default is no limit.
   This directive is implemented only in version 1.37 and later.

   If the device requires  mount, it is transfered to the device when this size
   is reached.  In this case, you must take care to have enough disk space left
   in  the spool directory.  

   Otherwise, it is left on the hard disk.  

   It is ignored for tape and FIFO devices.  


\end{description}

\subsection*{Devices that require a mount (DVD)}
\index[general]{Devices that require a mount (DVD)}
\index[general]{DVD!Devices that require a mount}
\addcontentsline{toc}{subsection}{Devices that require a mount (DVD)}

All the directives in this section are implemented only in
Bacula version 1.37 and later.

\begin{description}

\item [Requires Mount = {\it Yes|No}]
   \index[sd]{Requires Mount }
   You must set this directive to {\bf yes} for DVD-writers,  and to {\bf no} for
   all other devices (tapes/files).  This directive indicates if the device
   requires to be mounted to be read,  and if it must be written in a special way.
   If it set, {\bf Mount Point},  {\bf Mount Command}, {\bf Unmount Command} and
   {\bf Write Part Command}  directives must also be defined. 

\item [Mount Point = {\it directory}]
   \index[sd]{Mount Point }
   Directory where the device can be mounted. 

\item [Mount Command = {\it name-string}]
   \index[sd]{Mount Command }
   Command that must be executed to mount the device. Before the command is 
   executed, \%a is replaced with the Archive Device, and \%m with the Mount 
   Point.

   Most frequently, you will define it as follows:  

\footnotesize
\begin{verbatim}
  Mount Command = "/bin/mount -t iso9660 -o ro %a %m"
\end{verbatim}
\normalsize

\item [Unmount Command = {\it name-string}]
   \index[sd]{Unmount Command }
   Command that must be executed to unmount the device. Before the command  is
   executed, \%a is replaced with the Archive Device, and \%m with the  Mount
   Point.

   Most frequently, you will define it as follows:  

\footnotesize
\begin{verbatim}
  Unmount Command = "/bin/umount %m"
\end{verbatim}
\normalsize

\item [Write Part Command = {\it name-string}]
   \index[sd]{Write Part Command }
   Command that must be executed to write a part to the device. Before the 
   command is executed, \%a is replaced with the Archive Device, \%m with the 
   Mount Point, \%e is replaced with 1 if we are writing the first part,
   and with 0 otherwise, and \%v with the current part filename.

   For a DVD, you will most frequently specify the Bacula supplied  {\bf
   dvd-writepart} script as follows:  

\footnotesize
\begin{verbatim}
  Write Part Command = "/path/dvd-writepart %e %a %v"
\end{verbatim}
\normalsize

  Where {\bf /path} is the path to your scripts install directory, and
  dvd-writepart is the Bacula supplied script file.  
  This command will already be present, but commented out,
  in the default bacula-sd.conf file. To use it, simply remove
  the comment (\#) symbol.


\item [Free Space Command = {\it name-string}]
   \index[sd]{Free Space Command }
   Command that must be executed to check how much free space is left on the 
   device. Before the command is executed,\%a is replaced with the Archive
   Device, \%m with the Mount Point, \%e is replaced with 1 if we are writing
   the first part, and with 0 otherwise, and \%v with the current part filename.

   For a DVD, you will most frequently specify the Bacula supplied  {\bf
   dvd-freespace} script as follows:  

\footnotesize
\begin{verbatim}
  Free Space Command = "/path/dvd-freespace %a"
\end{verbatim}
\normalsize

  Where {\bf /path} is the path to your scripts install directory, and
  dvd-freespace is the Bacula supplied script file.
  If you want to specify your own command, please look at the code of
  dvd-freespace to see what output Bacula expects from this command.
  This command will already be present, but commented out,
  in the default bacula-sd.conf file. To use it, simply remove
  the comment (\#) symbol.

  If you do not set it, Bacula will expect there is always free space on the
  device. 

\end{description}

\label{AutochangerRes}
\label{AutochangerResource1}
\input{autochangerres}

\subsection*{Capabilities}
\index[general]{Capabilities}
\addcontentsline{toc}{subsection}{Capabilities}

\begin{description}

\item [Label media = {\it Yes|No}]
   \index[sd]{Label media }
   If {\bf Yes}, permits this device to automatically  label blank media without
   an explicit operator command.  It does so by using an internal algorithm as
   defined  on the 
   \ilink{Label Format}{Label} record in each Pool resource.  If
   this is {\bf No} as by default,  Bacula will label tapes only by specific
   operator  command ({\bf label} in the Console) or when the tape has been
   recycled.  The automatic labeling feature is most useful when writing to disk 
   rather than tape volumes.  

\item [Automatic mount = {\it Yes|No}]
   \index[sd]{Automatic mount }
   If {\bf Yes} (the default), permits the daemon to examine the device to
   determine if it contains a Bacula labeled volume.  This is done
   initially when the daemon is started, and then at the beginning of each
   job.  If the This directive is particularly important if you have set
   {\bf Always Open = no} because it permits Bacula to attempt to read the
   device before asking the system operator to mount a tape.  However,
   please note that the tape must be mounted before the job begins.

\end{description}

\subsection*{Messages Resource}
\label{MessagesResource1}
\index[general]{Resource!Messages}
\index[general]{Messages Resource}
\addcontentsline{toc}{subsection}{Messages Resource}

For a description of the Messages Resource, please see the 
\ilink{Messages Resource}{_ChapterStart15} Chapter of this
manual. 

\subsection*{Sample Storage Daemon Configuration File}
\label{SampleConfiguration}
\index[general]{File!Sample Storage Daemon Configuration}
\index[general]{Sample Storage Daemon Configuration File}
\addcontentsline{toc}{subsection}{Sample Storage Daemon Configuration File}

A example Storage Daemon configuration file might be the following: 

\footnotesize
\begin{verbatim}
#
# 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;
#}
#Device {
#  Name = "NEC ND-1300A"
#  Media Type = DVD
#  Archive Device = /dev/hda
#  LabelMedia = yes;                   # lets Bacula label unlabeled media
#  Random Access = Yes;
#  AutomaticMount = yes;               # when device opened, read it
#  RemovableMedia = yes;
#  AlwaysOpen = no;
#  MaximumPartSize = 800M;
#  RequiresMount = yes;
#  MountPoint = /mnt/cdrom;
#  MountCommand = "/bin/mount -t iso9660 -o ro %a %m";
#  UnmountCommand = "/bin/umount %m";
#  SpoolDirectory = /tmp/backup;
#  WritePartCommand = "/etc/bacula/dvd-writepart %e %a %v"
#  FreeSpaceCommand = "/etc/bacula/dvd-freespace %a"
#}
#
# 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
}
\end{verbatim}
\normalsize
