
#include "bacula_template.inc" title="Data Spooling" num=14

<h1>Data Spooling</h1>
Bacula allows you to specify that you want the Storage 
daemon to initially write your data to disk and then
subsequently to tape. This serves several important purposes.
First it can take a long time for data to come in from the 
File daemon during an Incremental backup. If it is directly written
to tape, the tape will start and stop or shoe-shine as it is often
called causing tape wear. By first writing the data to disk, then
writing it to tape, the tape can be kept in continual motion.  
The second major purpose is that while the spooled data is     
being written to the tape, the despooling process has exclusive
use of the tape. This means that you can spool multiple simultaneous
jobs to disk, then have them very efficiently despooled one at
a time without having the data blocks from several jobs 
intermingled, thus substantially improving the time needed
to restore files.
<p>
The remainder of this chapter explains the various directives
that you can use in the spooling process.              

<h2>Data Spooling Directives</h2>
The following directives can be used to control data spooling.
<ul>
  <li>To turn on/off data spooling at the Job level in
      the Job resource in the Director's conf file (default
      <b>no</b>.<p>
      <b>SpoolData = yes/no</b> </li>
  <li>To override the Job specification in a Schedule Run
      directive in the Director's conf file.<p>
      <b>SpoolData = yes/no</b> </li>
  <li>To limit the maximum total size of the spooled data
      for a particular device. Specified in the Device
      resource of the Storage daemon's conf file (default
      unlimited).<p>
      <b>Maximum Spool Size = size</b><p>
      Where size is a the maximum spool size for all jobs
      specified in bytes. </li>
  <li>To limit the maximum total size of the spooled data
      for a particular device for a single job. Specified
      in the Device Resource of the Storage daemon's conf
      file (default unlimited).<p>
      <b>Maximum Job Spool Size = size</b><p>
      Where size is the maximum spool file size for a single
      job specified in bytes. </li>
  <li>To specify the spool directory for a particular device.
      Specified in the Device Resource of the Storage daemon's conf
      file (default, the working directory).<p>
      <b>Spool Directory = directory</b></li>
</ul>

<h2>!!! MAJOR WARNING !!!</h2>
Please be very careful to exclude the spool directory from
any backup, otherwise, your job will write enormous amounts
of data to the Volume, and most probably terminate in error.
This is simply because in attempting to backup the spool file,
the backup data will be written a second time to the spool
file, and so on ad infinum. 
<p>
Another advice is to always specify the maximum spool size
so that your disk doesn't completely fill up. In principle,
data spooling will properly detect a full disk, and despool
data allowing the job to continue. However, attribute spooling
is not so kind to the user. If the disk on which attributes
are being spooled fills, the job will be canceled.

<h2>Other Points</h2>
<ul> 
 <li>When data spooling is enabled, Bacula automatically
     turns on attribute spooling. In other words, it also
     spools the catalog entries to disk. This is done so
     that in case the job fails, there will be no catalog
     entries pointing to non-existent tape backups.</li>
 <li>Attribute spooling is done at the end of the job, as
     a consequence, after Bacula stops writing the data to
     the tape, there may be a pause while the attributes are sent
     to the Directory and entered into the catalog before
     the job terminates.</li>
 <li>Attribute spool files are always placed in the
     working directory.</li>
 <li>When Bacula begins despooling data spooled to disk, it
     takes exclusive use of the tape. This has the major      
     advantage that in running multiple simultaneous jobs at
     the same time, the blocks of several jobs will not be
     intermingled.</li>
 <li>It probably does not make a lot of sense to enable data
     spooling if you are writing to disk files.</li>
</ul>


<page_prev name="Backing Up to Disk Volumes" url="disk.html">
<page_next name="Data Spooling" url="spooling.html">
