Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > df754e4e6f7f5fc8ab9d6ed8559f3e3d > files > 136

bacula-docs-5.0.3-19.fc16.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<!--Converted with LaTeX2HTML 2008 (1.71)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>Automatic Volume Recycling</TITLE>
<META NAME="description" CONTENT="Automatic Volume Recycling">
<META NAME="keywords" CONTENT="main">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">

<META NAME="Generator" CONTENT="LaTeX2HTML v2008">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">

<LINK REL="STYLESHEET" HREF="main.css">

<LINK REL="next" HREF="Basic_Volume_Management.html">
<LINK REL="previous" HREF="Restore_Command.html">
<LINK REL="up" HREF="Bacula_Main_Reference.html">
<LINK REL="next" HREF="Basic_Volume_Management.html">
</HEAD>

<BODY >
<!--Navigation Panel-->
<A NAME="tex2html1627"
  HREF="Basic_Volume_Management.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html1621"
  HREF="Bacula_Main_Reference.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html1615"
  HREF="Restore_Command.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html1623"
  HREF="Contents.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html1625"
  HREF="Thanks.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html1628"
  HREF="Basic_Volume_Management.html">Basic Volume Management</A>
<B> Up:</B> <A NAME="tex2html1622"
  HREF="Bacula_Main_Reference.html">Bacula Main Reference</A>
<B> Previous:</B> <A NAME="tex2html1616"
  HREF="Restore_Command.html">The Restore Command</A>
 &nbsp; <B>  <A NAME="tex2html1624"
  HREF="Contents.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html1626"
  HREF="Thanks.html">Index</A></B> 
<BR>
<BR>
<!--End of Navigation Panel-->
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>

<UL>
<LI><A NAME="tex2html1629"
  HREF="Automatic_Volume_Recycling.html#SECTION002610000000000000000">Automatic Pruning</A>
<LI><A NAME="tex2html1630"
  HREF="Automatic_Volume_Recycling.html#SECTION002620000000000000000">Pruning Directives</A>
<LI><A NAME="tex2html1631"
  HREF="Automatic_Volume_Recycling.html#SECTION002630000000000000000">Recycling Algorithm</A>
<LI><A NAME="tex2html1632"
  HREF="Automatic_Volume_Recycling.html#SECTION002640000000000000000">Recycle Status</A>
<LI><A NAME="tex2html1633"
  HREF="Automatic_Volume_Recycling.html#SECTION002650000000000000000">Making Bacula Use a Single Tape</A>
<LI><A NAME="tex2html1634"
  HREF="Automatic_Volume_Recycling.html#SECTION002660000000000000000">Daily, Weekly, Monthly Tape Usage Example</A>
<LI><A NAME="tex2html1635"
  HREF="Automatic_Volume_Recycling.html#SECTION002670000000000000000">Automatic Pruning and Recycling Example</A>
<LI><A NAME="tex2html1636"
  HREF="Automatic_Volume_Recycling.html#SECTION002680000000000000000">Manually Recycling Volumes</A>
</UL>
<!--End of Table of Child-Links-->
<HR>

<H1><A NAME="SECTION002600000000000000000"></A>
<A NAME="RecyclingChapter"></A>
<BR>
Automatic Volume Recycling
</H1>
<A NAME="15135"></A>
<A NAME="15136"></A>

<P>
By default, once Bacula starts writing a Volume, it can append to the
volume, but it will not overwrite the existing data thus destroying it.
However when Bacula <B>recycles</B> a Volume, the Volume becomes available
for being reused, and Bacula can at some later time overwrite the previous
contents of that Volume.  Thus all previous data will be lost.  If the
Volume is a tape, the tape will be rewritten from the beginning.  If the
Volume is a disk file, the file will be truncated before being rewritten.

<P>
You may not want Bacula to automatically recycle (reuse) tapes.  This would
require a large number of tapes though, and in such a case, it is possible
to manually recycle tapes.  For more on manual recycling, see the section
entitled  Manually Recycling Volumesmanualrecycling below in this
chapter.

<P>
Most people prefer to have a Pool of tapes that are used for daily backups and
recycled once a week, another Pool of tapes that are used for Full backups
once a week and recycled monthly, and finally a Pool of tapes that are used
once a month and recycled after a year or two. With a scheme like this, the 
number of tapes in your pool or pools remains constant.

<P>
By properly defining your Volume Pools with appropriate Retention periods,
Bacula can manage the recycling (such as defined above) automatically. 

<P>
Automatic recycling of Volumes is controlled by four records in the <B>Pool</B> resource definition in the Director's configuration file. These four
records are: 

<P>

<UL>
<LI>AutoPrune = yes 
</LI>
<LI>VolumeRetention = time 
</LI>
<LI>Recycle = yes
</LI>
<LI>RecyclePool = APool (<I>This require bacula 2.1.4 or greater</I>)
</LI>
</UL>

<P>
The above three directives are all you need assuming that you fill
each of your Volumes then wait the Volume Retention period before 
reusing them.  If you want Bacula to stop using a Volume and recycle
it before it is full, you will need to use one or more additional 
directives such as:

<UL>
<LI>Use Volume Once = yes
</LI>
<LI>Volume Use Duration = ttt
</LI>
<LI>Maximum Volume Jobs = nnn
</LI>
<LI>Maximum Volume Bytes = mmm
</LI>
</UL>
Please see below and 
the Basic Volume ManagementDiskChapter chapter
of this manual for more complete examples.  

<P>
Automatic recycling of Volumes is performed by Bacula only when it wants a
new Volume and no appendable Volumes are available in the Pool. It will then
search the Pool for any Volumes with the <B>Recycle</B> flag set and the 
Volume Status is <B>Purged</B>. At that point, it will choose the oldest 
purged volume and recycle it.

<P>
If there are no volumes with Status <B>Purged</B>, then 
the recycling occurs in two steps:
The first is that the Catalog for a Volume must be pruned of all Jobs (i.e.
Purged).  Files contained on that Volume, and the second step is the actual
recycling of the Volume.  Only Volumes marked <B>Full</B> or <B>Used</B> will
be considerd for pruning.  The Volume will be purged if the VolumeRetention
period has expired.  When a Volume is marked as Purged, it means that no
Catalog records reference that Volume, and the Volume can be recycled.
Until recycling actually occurs, the Volume data remains intact.  If no
Volumes can be found for recycling for any of the reasons stated above,
Bacula will request operator intervention (i.e.  it will ask you to label a
new volume).

<P>
A key point mentioned above, that can be a source of frustration, is that Bacula
will only recycle purged Volumes if there is no other appendable Volume
available, otherwise, it will always write to an appendable Volume before
recycling even if there are Volume marked as Purged. This preserves your data
as long as possible. So, if you wish to "force" Bacula to use a purged
Volume, you must first ensure that no other Volume in the Pool is marked <B>Append</B>. If necessary, you can manually set a volume to <B>Full</B>. The reason
for this is that Bacula wants to preserve the data on your old tapes (even
though purged from the catalog) as long as absolutely possible before
overwriting it. There are also a number of directives such as
<B>Volume Use Duration</B> that will automatically mark a volume as <B>Used</B> and thus no longer appendable.

<P>
<A NAME="AutoPruning"></A>
<H1><A NAME="SECTION002610000000000000000">
Automatic Pruning</A>
</H1>
<A NAME="15163"></A>
<A NAME="15164"></A>

<P>
As Bacula writes files to tape, it keeps a list of files, jobs, and volumes
in a database called the catalog.  Among other things, the database helps
Bacula to decide which files to back up in an incremental or differential
backup, and helps you locate files on past backups when you want to restore
something.  However, the catalog will grow larger and larger as time goes
on, and eventually it can become unacceptably large.

<P>
Bacula's process for removing entries from the catalog is called Pruning.
The default is Automatic Pruning, which means that once an entry reaches a
certain age (e.g.  30 days old) it is removed from the catalog.  Once a job
has been pruned, you can still restore it from the backup tape, but one
additional step is required: scanning the volume with bscan.  The
alternative to Automatic Pruning is Manual Pruning, in which you explicitly
tell Bacula to erase the catalog entries for a volume.  You'd usually do
this when you want to reuse a Bacula volume, because there's no point in
keeping a list of files that USED TO BE on a tape.  Or, if the catalog is
starting to get too big, you could prune the oldest jobs to save space.
Manual pruning is done with the  prune commandManualPruning in
the console.  (thanks to Bryce Denney for the above explanation).

<P>

<H1><A NAME="SECTION002620000000000000000">
Pruning Directives</A>
</H1>
<A NAME="15168"></A>
<A NAME="15169"></A>

<P>
There are three pruning durations. All apply to catalog database records and
not to the actual data in a Volume. The pruning (or retention) durations are
for: Volumes (Media records), Jobs (Job records), and Files (File records).
The durations inter-depend a bit because if Bacula prunes a Volume, it
automatically removes all the Job records, and all the File records. Also when
a Job record is pruned, all the File records for that Job are also pruned
(deleted) from the catalog. 

<P>
Having the File records in the database means that you can examine all the
files backed up for a particular Job. They take the most space in the catalog
(probably 90-95% of the total). When the File records are pruned, the Job
records can remain, and you can still examine what Jobs ran, but not the
details of the Files backed up. In addition, without the File records, you
cannot use the Console restore command to restore the files. 

<P>
When a Job record is pruned, the Volume (Media record) for that Job can still
remain in the database, and if you do a "list volumes", you will see the
volume information, but the Job records (and its File records) will no longer
be available. 

<P>
In each case, pruning removes information about where older files are, but it
also prevents the catalog from growing to be too large. You choose the
retention periods in function of how many files you are backing up and the
time periods you want to keep those records online, and the size of the
database. You can always re-insert the records (with 98% of the original data)
by using "bscan" to scan in a whole Volume or any part of the volume that
you want. 

<P>
By setting <B>AutoPrune</B> to <B>yes</B> you will permit <B>Bacula</B> to
automatically prune all Volumes in the Pool when a Job needs another Volume.
Volume pruning means removing records from the catalog. It does not shrink the
size of the Volume or affect the Volume data until the Volume gets
overwritten. When a Job requests another volume and there are no Volumes with
Volume Status <B>Append</B> available, Bacula will begin volume pruning. This
means that all Jobs that are older than the <B>VolumeRetention</B> period will
be pruned from every Volume that has Volume Status <B>Full</B> or <B>Used</B>
and has Recycle set to <B>yes</B>. Pruning consists of deleting the
corresponding Job, File, and JobMedia records from the catalog database. No
change to the physical data on the Volume occurs during the pruning process.
When all files are pruned from a Volume (i.e. no records in the catalog), the
Volume will be marked as <B>Purged</B> implying that no Jobs remain on the
volume. The Pool records that control the pruning are described below. 

<P>
<DL>
<DT><STRONG>AutoPrune = yes|no</STRONG></DT>
<DD><A NAME="15182"></A>
   If AutoPrune is set to  <B>yes</B> (default), Bacula
   will  automatically apply the Volume retention period when running a Job  and
   it needs a new Volume but no appendable volumes are available.  At that point,
   Bacula will prune all Volumes that can be pruned  (i.e. AutoPrune set) in an
   attempt to find a usable volume. If  during the autoprune, all files are
   pruned from the Volume, it  will be marked with VolStatus <B>Purged</B>.  The
   default is <B>yes</B>. Note, that although the File and Job records may be 
   pruned from the catalog, a Volume will be marked Purged (and hence 
   ready for recycling) if the Volume status is Append, Full, Used, or Error.
   If the Volume has another status, such as Archive, Read-Only, Disabled,
   Busy, or Cleaning, the Volume status will not be changed to Purged.

<P>
</DD>
<DT><STRONG>Volume Retention = time-period-specification</STRONG></DT>
<DD><A NAME="15188"></A>
   The Volume Retention record defines the length of time that Bacula will
   guarantee that the Volume is not reused counting from the time the last
   job stored on the Volume terminated.  A key point is that this time
   period is not even considered as long at the Volume remains appendable.
   The Volume Retention period count down begins only when the Append
   status has been changed to some othe status (Full, Used, Purged, ...).

<P>
When this time period expires, and if <B>AutoPrune</B> is set to <B>   yes</B>, and a new Volume is needed, but no appendable Volume is available,
   Bacula will prune (remove) Job records that are older than the specified
   Volume Retention period.

<P>
The Volume Retention period takes precedence over any Job Retention
   period you have specified in the Client resource.  It should also be
   noted, that the Volume Retention period is obtained by reading the
   Catalog Database Media record rather than the Pool resource record.
   This means that if you change the VolumeRetention in the Pool resource
   record, you must ensure that the corresponding change is made in the
   catalog by using the <B>update pool</B> command.  Doing so will insure
   that any new Volumes will be created with the changed Volume Retention
   period.  Any existing Volumes will have their own copy of the Volume
   Retention period that can only be changed on a Volume by Volume basis
   using the <B>update volume</B> command.

<P>
When all file catalog entries are removed from the volume,  its VolStatus is
   set to <B>Purged</B>. The files remain physically  on the Volume until the
   volume is overwritten.  

<P>
Retention periods are specified in seconds,  minutes, hours, days, weeks,
   months,  quarters, or years on the record. See the  
   Configuration chapterTime of this  manual for
   additional details of time specification.  

<P>
The default is 1 year. 

<P>
</DD>
<DT><STRONG>Recycle = yes|no</STRONG></DT>
<DD><A NAME="15198"></A>
   This statement tells Bacula whether or not the particular Volume can be
   recycled (i.e.  rewritten).  If Recycle is set to <B>no</B> (the
   default), then even if Bacula prunes all the Jobs on the volume and it
   is marked <B>Purged</B>, it will not consider the tape for recycling.  If
   Recycle is set to <B>yes</B> and all Jobs have been pruned, the volume
   status will be set to <B>Purged</B> and the volume may then be reused
   when another volume is needed.  If the volume is reused, it is relabeled
   with the same Volume Name, however all previous data will be lost.
   
</DD>
</DL>

<P>
It is also possible to "force" pruning of all Volumes in the Pool
   associated with a Job by adding <B>Prune Files = yes</B> to the Job resource. 

<P>
<A NAME="Recycling"></A><A NAME="RecyclingAlgorithm"></A>
<H1><A NAME="SECTION002630000000000000000">
Recycling Algorithm</A>
</H1>
<A NAME="15208"></A>
<A NAME="15209"></A>

<P>
After all Volumes of a Pool have been pruned (as mentioned above, this happens
when a Job needs a new Volume and no appendable Volumes are available), Bacula
will look for the oldest Volume that is Purged (all Jobs and Files expired),
and if the <B>Recycle</B> flag is on (Recycle=yes) for that Volume, Bacula will
relabel it and write new data on it. 

<P>
As mentioned above, there are two key points for getting a Volume
to be recycled. First, the Volume must no longer be marked Append (there
are a number of directives to automatically make this change), and second
since the last write on the Volume, one or more of the Retention periods
must have expired so that there are no more catalog backup job records
that reference that Volume.  Once both those conditions are satisfied,
the volume can be marked Purged and hence recycled.

<P>
The full algorithm that Bacula uses when it needs a new Volume is: 
<A NAME="15211"></A>
<A NAME="15212"></A>

<P>
The algorithm described below assumes that AutoPrune is enabled,
that Recycling is turned on, and that you have defined
appropriate Retention periods, or used the defaults for all these
items. 

<P>

<UL>
<LI>If the request is for an Autochanger device, look only
   for Volumes in the Autochanger (i.e. with InChanger set and that have
   the correct Storage device).        
</LI>
<LI>Search the Pool for a Volume with VolStatus=Append (if there is more
   than one, the Volume with the oldest date last written is chosen.  If
   two have the same date then the one with the lowest MediaId is chosen).
</LI>
<LI>Search the Pool for a Volume with VolStatus=Recycle and the InChanger
   flag is set true (if there is more than one, the Volume with the oldest
   date last written is chosen.  If two have the same date then the one
   with the lowest MediaId is chosen).
</LI>
<LI>Try recycling any purged Volumes.
</LI>
<LI>Prune volumes applying Volume retention period (Volumes with VolStatus 
   Full, Used, or Append are pruned). Note, even if all the File and Job
   records are pruned from a Volume, the Volume will not be marked Purged
   until the Volume retention period expires.
</LI>
<LI>Search the Pool for a Volume with VolStatus=Purged 
</LI>
<LI>If a Pool named "Scratch" exists, search for a Volume and if found
   move it to the current Pool for the Job and use it. Note, when
   the Scratch Volume is moved into the current Pool, the basic
   Pool defaults are applied as if it is a newly labeled Volume
   (equivalent to an <B>update volume from pool</B> command).
</LI>
<LI>If we were looking for Volumes in the Autochanger, go back to
   step 2 above, but this time, look for any Volume whether or not
   it is in the Autochanger.                   
</LI>
<LI>Attempt to create a new Volume if automatic labeling enabled 
   If Python is enabled, a Python NewVolume event is generated before
   the Label Format directve is used. If the maximum number of Volumes
   specified for the pool is reached, a new Volume will not be created.
</LI>
<LI>Prune the oldest Volume if RecycleOldestVolume=yes (the Volume with the
   oldest LastWritten date and VolStatus equal to  Full, Recycle, Purged, Used,
   or Append is chosen). This  record ensures that all retention periods are
   properly respected. 
</LI>
<LI>Purge the oldest Volume if PurgeOldestVolume=yes (the Volume  with the
   oldest LastWritten date and VolStatus equal to  Full, Recycle, Purged, Used,
   or Append is chosen). We strongly  recommend against the use of <B>   PurgeOldestVolume</B> as it can quite easily lead to loss of current backup
   data. 
</LI>
<LI>Give up and ask operator. 
</LI>
</UL>

<P>
The above occurs when Bacula has finished writing a Volume or when no Volume
is present in the drive. 

<P>
On the other hand, if you have inserted a different Volume after the last job,
and Bacula recognizes the Volume as valid, it will request authorization from
the Director to use this Volume. In this case, if you have set <B>Recycle
Current Volume = yes</B> and the Volume is marked as Used or Full, Bacula will
prune the volume and if all jobs were removed during the pruning (respecting
the retention periods), the Volume will be recycled and used. 

<P>
The recycling algorithm in this case is: 

<UL>
<LI>If the VolStatus is <B>Append</B> or <B>Recycle</B> 
   is set, the volume  will be used.  
</LI>
<LI>If <B>Recycle Current Volume</B> is set and the  volume is marked <B>   Full</B> or <B>Used</B>, Bacula  will prune the volume (applying the retention
   period).  If all Jobs are pruned from the volume, it will be  recycled. 
</LI>
</UL>

<P>
This permits users to manually change the Volume every day and load tapes in
an order different from what is in the catalog, and if the volume does not
contain a current copy of your backup data, it will be used. 

<P>
A few points from Alan Brown to keep in mind:

<P>

<OL>
<LI>If a pool doesn't have maximum volumes defined then Bacula will prefer to 
  demand new volumes over forcibly purging older volumes.

<P>
</LI>
<LI>If volumes become free through pruning and the Volume retention period has
  expired, then they get marked as "purged" and are immediately available for
  recycling - these will be used in preference to creating new volumes.

<P>
</LI>
<LI>If the Job, File, and Volume retention periods are different, then
  it's common to see a tape with no files or jobs listed in the database,
  but which is still not marked as "purged".
</LI>
</OL>

<P>

<H1><A NAME="SECTION002640000000000000000">
Recycle Status</A>
</H1>
<A NAME="15228"></A>
<A NAME="15229"></A>

<P>
Each Volume inherits the Recycle status (yes or no) from the Pool resource
record when the Media record is created (normally when the Volume is labeled).
This Recycle status is stored in the Media record of the Catalog. Using
the Console program, you may subsequently change the Recycle status for each
Volume. For example in the following output from <B>list volumes</B>: 

<P>
<PRE>
+----------+-------+--------+---------+------------+--------+-----+
| VolumeNa | Media | VolSta | VolByte | LastWritte | VolRet | Rec |
+----------+-------+--------+---------+------------+--------+-----+
| File0001 | File  | Full   | 4190055 | 2002-05-25 | 14400  | 1   |
| File0002 | File  | Full   | 1896460 | 2002-05-26 | 14400  | 1   |
| File0003 | File  | Full   | 1896460 | 2002-05-26 | 14400  | 1   |
| File0004 | File  | Full   | 1896460 | 2002-05-26 | 14400  | 1   |
| File0005 | File  | Full   | 1896460 | 2002-05-26 | 14400  | 1   |
| File0006 | File  | Full   | 1896460 | 2002-05-26 | 14400  | 1   |
| File0007 | File  | Purged | 1896466 | 2002-05-26 | 14400  | 1   |
+----------+-------+--------+---------+------------+--------+-----+
</PRE>
<P>
all the volumes are marked as recyclable, and the last Volume, <B>File0007</B>
has been purged, so it may be immediately recycled. The other volumes are all
marked recyclable and when their Volume Retention period (14400 seconds or four
hours) expires, they will be eligible for pruning, and possibly recycling.
Even though Volume <B>File0007</B> has been purged, all the data on the Volume
is still recoverable. A purged Volume simply means that there are no entries
in the Catalog. Even if the Volume Status is changed to <B>Recycle</B>, the
data on the Volume will be recoverable. The data is lost only when the Volume
is re-labeled and re-written. 

<P>
To modify Volume <B>File0001</B> so that it cannot be recycled, you use the
<B>update volume pool=File</B> command in the console program, or simply <B>update</B> and Bacula will prompt you for the information. 

<P>
<PRE>
+----------+------+-------+---------+-------------+-------+-----+
| VolumeNa | Media| VolSta| VolByte | LastWritten | VolRet| Rec |
+----------+------+-------+---------+-------------+-------+-----+
| File0001 | File | Full  | 4190055 | 2002-05-25  | 14400 | 0   |
| File0002 | File | Full  | 1897236 | 2002-05-26  | 14400 | 1   |
| File0003 | File | Full  | 1896460 | 2002-05-26  | 14400 | 1   |
| File0004 | File | Full  | 1896460 | 2002-05-26  | 14400 | 1   |
| File0005 | File | Full  | 1896460 | 2002-05-26  | 14400 | 1   |
| File0006 | File | Full  | 1896460 | 2002-05-26  | 14400 | 1   |
| File0007 | File | Purged| 1896466 | 2002-05-26  | 14400 | 1   |
+----------+------+-------+---------+-------------+-------+-----+
</PRE>
<P>
In this case, <B>File0001</B> will never be automatically recycled. The same
effect can be achieved by setting the Volume Status to Read-Only. 

<P>
As you have noted, the Volume Status (VolStatus) column in the 
catalog database contains the current status of the Volume, which
is normally maintained automatically by Bacula. To give you an
idea of some of the values it can take during the life cycle of
a Volume, here is a picture created by Arno Lehmann:

<P>
<PRE>
A typical volume life cycle is like this:

              because job count or size limit exceeded
      Append  ----------------------------------------&gt;  Used
        ^                                                  |
        | First Job writes to        Retention time passed |
        | the volume                   and recycling takes |
        |                                            place |
        |                                                  v
      Recycled &lt;-------------------------------------- Purged
                     Volume is selected for reuse
</PRE>
<P>

<H1><A NAME="SECTION002650000000000000000"></A>
<A NAME="singletape"></A>
<BR>
Making Bacula Use a Single Tape
</H1>
<A NAME="15246"></A>
<A NAME="15247"></A>

<P>
Most people will want Bacula to fill a tape and when it is full, a new tape
will be mounted, and so on. However, as an extreme example, it is possible for
Bacula to write on a single tape, and every night to rewrite it. To get this
to work, you must do two things: first, set the VolumeRetention to less than
your save period (one day), and the second item is to make Bacula mark the
tape as full after using it once. This is done using <B>UseVolumeOnce =
yes</B>. If this latter record is not used and the tape is not full after the
first time it is written, Bacula will simply append to the tape and eventually
request another volume. Using the tape only once, forces the tape to be marked
<B>Full</B> after each use, and the next time <B>Bacula</B> runs, it will
recycle the tape. 

<P>
An example Pool resource that does this is: 

<P>
<PRE>
Pool {
  Name = DDS-4
  Use Volume Once = yes
  Pool Type = Backup
  AutoPrune = yes
  VolumeRetention = 12h # expire after 12 hours
  Recycle = yes
}
</PRE>
<P>

<H1><A NAME="SECTION002660000000000000000"></A>
<A NAME="usageexample"></A>
<BR>
Daily, Weekly, Monthly Tape Usage Example
</H1>
<A NAME="15255"></A>
<A NAME="15256"></A>

<P>
This example is meant to show you how one could define a fixed set of volumes
that Bacula will rotate through on a regular schedule. There are an infinite
number of such schemes, all of which have various advantages and
disadvantages. 

<P>
We start with the following assumptions: 

<P>

<UL>
<LI>A single tape has more than enough capacity to do  a full save.  
</LI>
<LI>There are ten tapes that are used on a daily basis  for incremental
   backups. They are prelabeled Daily1 ...  Daily10.  
</LI>
<LI>There are four tapes that are used on a weekly basis  for full backups.
   They are labeled Week1 ... Week4.  
</LI>
<LI>There are 12 tapes that are used on a monthly basis  for full backups.
   They are numbered Month1 ... Month12  
</LI>
<LI>A full backup is done every Saturday evening (tape inserted  Friday
   evening before leaving work).  
</LI>
<LI>No backups are done over the weekend (this is easy to  change).  
</LI>
<LI>The first Friday of each month, a Monthly tape is used for  the Full
   backup.  
</LI>
<LI>Incremental backups are done Monday - Friday (actually  Tue-Fri
   mornings). 
</LI>
</UL>

<P>
We start the system by doing a Full save to one of the weekly volumes or one
of the monthly volumes. The next morning, we remove the tape and insert a
Daily tape. Friday evening, we remove the Daily tape and insert the next tape
in the Weekly series. Monday, we remove the Weekly tape and re-insert the
Daily tape. On the first Friday of the next month, we insert the next Monthly
tape in the series rather than a Weekly tape, then continue. When a Daily tape
finally fills up, <B>Bacula</B> will request the next one in the series, and
the next day when you notice the email message, you will mount it and <B>Bacula</B> will finish the unfinished incremental backup. 

<P>
What does this give? Well, at any point, you will have the last complete
Full save plus several Incremental saves. For any given file you want to
recover (or your whole system), you will have a copy of that file every day
for at least the last 14 days. For older versions, you will have at least three
and probably four Friday full saves of that file, and going back further, you
will have a copy of that file made on the beginning of the month for at least
a year. 

<P>
So you have copies of any file (or your whole system) for at least a year, but
as you go back in time, the time between copies increases from daily to weekly
to monthly. 

<P>
What would the Bacula configuration look like to implement such a scheme? 

<P>
<PRE>
Schedule {
  Name = "NightlySave"
  Run = Level=Full Pool=Monthly 1st sat at 03:05
  Run = Level=Full Pool=Weekly 2nd-5th sat at 03:05
  Run = Level=Incremental Pool=Daily tue-fri at 03:05
}
Job {
  Name = "NightlySave"
  Type = Backup
  Level = Full
  Client = LocalMachine
  FileSet = "File Set"
  Messages = Standard
  Storage = DDS-4
  Pool = Daily
  Schedule = "NightlySave"
}
# Definition of file storage device
Storage {
  Name = DDS-4
  Address = localhost
  SDPort = 9103
  Password = XXXXXXXXXXXXX
  Device = FileStorage
  Media Type = 8mm
}
FileSet {
  Name = "File Set"
  Include = signature=MD5 {
    fffffffffffffffff
  }
  Exclude = { *.o }
}
Pool {
  Name = Daily
  Pool Type = Backup
  AutoPrune = yes
  VolumeRetention = 10d   # recycle in 10 days
  Maximum Volumes = 10
  Recycle = yes
}
Pool {
  Name = Weekly
  Use Volume Once = yes
  Pool Type = Backup
  AutoPrune = yes
  VolumeRetention = 30d  # recycle in 30 days (default)
  Recycle = yes
}
Pool {
  Name = Monthly
  Use Volume Once = yes
  Pool Type = Backup
  AutoPrune = yes
  VolumeRetention = 365d  # recycle in 1 year
  Recycle = yes
}
</PRE>
<P>

<H1><A NAME="SECTION002670000000000000000"></A>
<A NAME="PruningExample"></A>
<BR>
Automatic Pruning and Recycling Example
</H1>
<A NAME="15265"></A>
<A NAME="15266"></A>

<P>
Perhaps the best way to understand the various resource records that come into
play during automatic pruning and recycling is to run a Job that goes through
the whole cycle. If you add the following resources to your Director's
configuration file: 

<P>
<PRE>
Schedule {
  Name = "30 minute cycle"
  Run = Level=Full Pool=File Messages=Standard Storage=File
         hourly at 0:05
  Run = Level=Full Pool=File Messages=Standard Storage=File
         hourly at 0:35
}
Job {
  Name = "Filetest"
  Type = Backup
  Level = Full
  Client=XXXXXXXXXX
  FileSet="Test Files"
  Messages = Standard
  Storage = File
  Pool = File
  Schedule = "30 minute cycle"
}
# Definition of file storage device
Storage {
  Name = File
  Address = XXXXXXXXXXX
  SDPort = 9103
  Password = XXXXXXXXXXXXX
  Device = FileStorage
  Media Type = File
}
FileSet {
  Name = "Test Files"
  Include = signature=MD5 {
    fffffffffffffffff
  }
  Exclude = { *.o }
}
Pool {
  Name = File
  Use Volume Once = yes
  Pool Type = Backup
  LabelFormat = "File"
  AutoPrune = yes
  VolumeRetention = 4h
  Maximum Volumes = 12
  Recycle = yes
}
</PRE>
<P>
Where you will need to replace the <B>ffffffffff</B>'s by the appropriate files
to be saved for your configuration. For the FileSet Include, choose a
directory that has one or two megabytes maximum since there will probably be
approximately eight copies of the directory that <B>Bacula</B> will cycle through. 

<P>
In addition, you will need to add the following to your Storage daemon's
configuration file: 

<P>
<PRE>
Device {
  Name = FileStorage
  Media Type = File
  Archive Device = /tmp
  LabelMedia = yes;
  Random Access = Yes;
  AutomaticMount = yes;
  RemovableMedia = no;
  AlwaysOpen = no;
}
</PRE>
<P>
With the above resources, Bacula will start a Job every half hour that saves a
copy of the directory you chose to /tmp/File0001 ... /tmp/File0012. After 4
hours, Bacula will start recycling the backup Volumes (/tmp/File0001 ...). You
should see this happening in the output produced. Bacula will automatically
create the Volumes (Files) the first time it uses them. 

<P>
To turn it off, either delete all the resources you've added, or simply
comment out the <B>Schedule</B> record in the <B>Job</B> resource. 

<P>

<H1><A NAME="SECTION002680000000000000000"></A>
<A NAME="manualrecycling"></A>
<BR>
Manually Recycling Volumes
</H1>
<A NAME="15277"></A>
<A NAME="15278"></A>

<P>
Although automatic recycling of Volumes is implemented in version 1.20 and
later (see the 
Automatic Recycling of VolumesRecyclingChapter chapter of
this manual), you may want to manually force reuse (recycling) of a Volume. 

<P>
Assuming that you want to keep the Volume name, but you simply want to write
new data on the tape, the steps to take are: 

<P>

<UL>
<LI>Use the <B>update volume</B> command in the Console to  ensure that the
   <B>Recycle</B> field is set to <B>1</B>  
</LI>
<LI>Use the <B>purge jobs volume</B> command in the Console  to mark the
   Volume as <B>Purged</B>. Check by using  <B>list volumes</B>. 
</LI>
</UL>

<P>
Once the Volume is marked Purged, it will be recycled the next time a Volume
is needed. 

<P>
If you wish to reuse the tape by giving it a new name, follow the following
steps: 

<P>

<UL>
<LI>Use the <B>purge jobs volume</B> command in the Console  to mark the
   Volume as <B>Purged</B>. Check by using  <B>list volumes</B>.  
</LI>
<LI>In Bacula version 1.30 or greater, use the Console  <B>relabel</B>
   command to relabel the Volume. 
</LI>
</UL>

<P>
Please note that the relabel command applies only to tape Volumes. 

<P>
For Bacula versions prior to 1.30 or to manually relabel the Volume, use the
instructions below: 

<P>

<UL>
<LI>Use the <B>delete volume</B> command in the Console  to delete the Volume
   from the Catalog.  
</LI>
<LI>If a different tape is mounted, use the <B>unmount</B>  command,
   remove the tape, and insert the tape to be  renamed.  
</LI>
<LI>Write an EOF mark in the tape using the following  commands: 

<P>
<PRE>
  mt -f /dev/nst0 rewind
  mt -f /dev/nst0 weof
</PRE>
<P>
where you replace <B>/dev/nst0</B> with the appropriate  device name on your
system.  
</LI>
<LI>Use the <B>label</B> command to write a new label to  the tape and to
   enter it in the catalog. 
</LI>
</UL>

<P>
Please be aware that the <B>delete</B> command can be dangerous. Once it is
done, to recover the File records, you must either restore your database as it
was before the <B>delete</B> command, or use the <B>bscan</B> utility program to
scan the tape and recreate the database entries. 

<P>
<HR>
<!--Navigation Panel-->
<A NAME="tex2html1627"
  HREF="Basic_Volume_Management.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html1621"
  HREF="Bacula_Main_Reference.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html1615"
  HREF="Restore_Command.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html1623"
  HREF="Contents.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html1625"
  HREF="Thanks.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html1628"
  HREF="Basic_Volume_Management.html">Basic Volume Management</A>
<B> Up:</B> <A NAME="tex2html1622"
  HREF="Bacula_Main_Reference.html">Bacula Main Reference</A>
<B> Previous:</B> <A NAME="tex2html1616"
  HREF="Restore_Command.html">The Restore Command</A>
 &nbsp; <B>  <A NAME="tex2html1624"
  HREF="Contents.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html1626"
  HREF="Thanks.html">Index</A></B> 
<!--End of Navigation Panel-->
<ADDRESS>

2012-01-24
</ADDRESS>
</BODY>
</HTML>