.. _DirectorChapter:

Director Configuration
======================

.. index::
   pair: Director; Configuration

Of all the configuration files needed to run Bareos, the Director’s is the most complicated and the one that you will need to modify the most often as you add clients or modify the FileSets.

For a general discussion of configuration files and resources including the recognized data types see :ref:`ConfigureChapter`.

.. index::
   single: Types; Director Resource
   single: Director; Resource Types
   single: Resource Types

Everything revolves around a job and is tied to a job in one way or another.

The |dir| knows about following resource types:

-  :ref:`DirectorResourceDirector` – to define the Director’s name and its access password used for authenticating the Console program. Only a single Director resource definition may appear in the Director’s configuration file.

-  :ref:`DirectorResourceJob` – to define the backup/restore Jobs and to tie together the Client, FileSet and Schedule resources to be used for each Job. Normally, you will Jobs of different names corresponding to each client (i.e. one Job per client, but a different one with a different name for each client).

-  :ref:`DirectorResourceJobDefs` – optional resource for providing defaults for Job resources.

-  :ref:`DirectorResourceSchedule` – to define when a Job has to run. You may have any number of Schedules, but each job will reference only one.

-  :ref:`DirectorResourceFileSet` – to define the set of files to be backed up for each Client. You may have any number of FileSets but each Job will reference only one.

-  :ref:`DirectorResourceClient` – to define what Client is to be backed up. You will generally have multiple Client definitions. Each Job will reference only a single client.

-  :ref:`DirectorResourceStorage` – to define on what physical device the Volumes should be mounted. You may have one or more Storage definitions.

-  :ref:`DirectorResourcePool` – to define the pool of Volumes that can be used for a particular Job. Most people use a single default Pool. However, if you have a large number of clients or volumes, you may want to have multiple Pools. Pools allow you to restrict a Job (or a Client) to use only a particular set of Volumes.

-  :ref:`DirectorResourceCatalog` – to define in what database to keep the list of files and the Volume names where they are backed up. Most people only use a single catalog. It is possible, however not adviced and not supported to use multiple catalogs, see :ref:`MultipleCatalogs`.

-  :ref:`DirectorResourceMessages` – to define where error and information messages are to be sent or logged. You may define multiple different message resources and hence direct particular classes of messages to different users or locations (files, ...).

.. _DirectorResourceDirector:

Director Resource
-----------------

.. index::
   pair: Director; Resource

The Director resource defines the attributes of the Directors running on the network. Only a single Director resource is allowed.

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

.. code-block:: bareosconfig
   :caption: Director Resource example

   Director {
     Name = bareos-dir
     Password = secretpassword
     QueryFile = "/etc/bareos/query.sql"
     Maximum Concurrent Jobs = 10
     Messages = Daemon
   }


.. include:: /include/autogenerated/bareos-dir-resource-director-table.rst.inc

.. include:: /include/autogenerated/bareos-dir-resource-director-description.rst.inc


.. _DirectorResourceJob:

.. _JobResource:

Job Resource
------------

.. index::
   pair: Resource; Job

The Job resource defines a Job (Backup, Restore, ...) that Bareos must perform. Each Job resource definition contains the name of a Client and a FileSet to backup, the Schedule for the Job, where the data are to be stored, and what media Pool can be used. In effect, each Job resource must specify What, Where, How, and When or FileSet, Storage, Backup/Restore/Level, and Schedule respectively. Note, the FileSet must be specified for a restore job for historical reasons, but it is no longer used.

Only a single type (Backup, Restore, ...) can be specified for any job. If you want to backup multiple FileSets on the same Client or multiple Clients, you must define a Job for each one.

Note, you define only a single Job to do the Full, Differential, and Incremental backups since the different backup levels are tied together by a unique Job name. Normally, you will have only one Job per Client, but if a client has a really huge number of files (more than several million), you might want to split it into several Jobs each with a different FileSet covering only parts of the total files.

Multiple Storage daemons are not currently supported for Jobs, if you do want to use multiple storage daemons, you will need to create a different Job and ensure the combination of Client and FileSet is unique.

.. warning::

  Bareos uses only :config:option:`dir/job/Client` and :config:option:`dir/job/FileSet` to determine which jobids belong together.
  If job A and B have the same client and fileset defined, the resulting jobids will be intermixed as follows:

  #. When a job determines its predecessor to determine its required level and since-time, it will consider all jobs with the same client and fileset.
  #. When restoring a client you select the fileset and all jobs that used that fileset will be considered.

  As a matter of fact, if you want separate backups, you have to duplicate your filesets with a different name and the same content.


.. include:: /include/autogenerated/bareos-dir-resource-job-table.rst.inc

.. include:: /include/autogenerated/bareos-dir-resource-job-description.rst.inc

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

.. code-block:: bareosconfig
   :caption: Job Resource Example

   Job {
     Name = "Minou"
     Type = Backup
     Level = Incremental                 # default
     Client = Minou
     FileSet="Minou Full Set"
     Storage = DLTDrive
     Pool = Default
     Schedule = "MinouWeeklyCycle"
     Messages = Standard
   }

.. _DirectorResourceJobDefs:

JobDefs Resource
----------------

.. index::
   single: Job; JobDefs Resource
   single: Resource; JobDefs

The JobDefs resource permits all the same directives that can appear in a Job resource.
However, a JobDefs resource does not create a Job, rather it can be referenced within
a Job to provide defaults for that Job. This permits you to concisely define several nearly
identical Jobs, each one referencing a JobDefs resource which contains the defaults.
Only the changes from the defaults need to be mentioned in each Job.

.. _DirectorResourceSchedule:

Schedule Resource
-----------------

.. index::
   single: Resource; Schedule
   single: Schedule; Resource

The Schedule resource provides a means of automatically scheduling a Job as well as the ability to override the default Level, Pool, Storage and Messages resources. If a Schedule resource is not referenced in a Job, the Job can only be run manually. In general, you specify an action to be taken and when.

.. include:: /include/autogenerated/bareos-dir-resource-schedule-table.rst.inc

.. include:: /include/autogenerated/bareos-dir-resource-schedule-description.rst.inc

Note, the Week of Year specification wnn follows the ISO standard definition of the week of the year, where Week 1 is the week in which the first Thursday of the year occurs, or alternatively, the week which contains the 4th of January. Weeks are numbered w01 to w53. w00 for Bareos is the week that precedes the first ISO week (i.e. has the first few days of the year if any occur before Thursday). w00 is not defined by the ISO specification. A week starts with Monday and ends with Sunday.

According to the NIST (US National Institute of Standards and Technology), 12am and 12pm are ambiguous and can be defined to anything. However, 12:01am is the same as 00:01 and 12:01pm is the same as 12:01, so Bareos defines 12am as 00:00 (midnight) and 12pm as 12:00 (noon). You can avoid this abiguity (confusion) by using 24 hour time specifications (i.e. no am/pm).

An example schedule resource that is named WeeklyCycle and runs a job with level full each Sunday at 2:05am and an incremental job Monday through Saturday at 2:05am is:

.. code-block:: bareosconfig
   :caption: Schedule Example

   Schedule {
     Name = "WeeklyCycle"
     Run = Level=Full sun at 2:05
     Run = Level=Incremental mon-sat at 2:05
   }

An example of a possible monthly cycle is as follows:

.. code-block:: bareosconfig

   Schedule {
     Name = "MonthlyCycle"
     Run = Level=Full Pool=Monthly 1st sun at 2:05
     Run = Level=Differential 2nd-5th sun at 2:05
     Run = Level=Incremental Pool=Daily mon-sat at 2:05
   }

The first of every month:

.. code-block:: bareosconfig

   Schedule {
     Name = "First"
     Run = Level=Full on 1 at 2:05
     Run = Level=Incremental on 2-31 at 2:05
   }

The last friday of the month (i.e. the last friday in the last week of the month)

.. code-block:: bareosconfig

   Schedule {
     Name = "Last Friday"
     Run = Level=Full last fri at 21:00
   }

Every 10 minutes:

.. code-block:: bareosconfig

   Schedule {
     Name = "TenMinutes"
     Run = Level=Full hourly at 0:05
     Run = Level=Full hourly at 0:15
     Run = Level=Full hourly at 0:25
     Run = Level=Full hourly at 0:35
     Run = Level=Full hourly at 0:45
     Run = Level=Full hourly at 0:55
   }

The modulo scheduler makes it easy to specify schedules like odd or even days/weeks, or more generally every n days or weeks. It is called modulo scheduler because it uses the modulo to determine if the schedule must be run or not. The second variable behind the slash lets you determine in which cycle of days/weeks a job should be run. The first part determines on which day/week the job should be run first. E.g. if you want to run a backup in a 5-week-cycle, starting on week 3, you set it up as
w03/w05.

.. code-block:: bareosconfig
   :caption: Schedule Examples: modulo

   Schedule {
     Name = "Odd Days"
     Run = 1/2 at 23:10
   }

   Schedule {
     Name = "Even Days"
     Run = 2/2 at 23:10
   }

   Schedule {
     Name = "On the 3rd week in a 5-week-cycle"
     Run = w03/w05 at 23:10
   }

   Schedule {
     Name = "Odd Weeks"
     Run = w01/w02 at 23:10
   }

   Schedule {
     Name = "Even Weeks"
     Run = w02/w02 at 23:10
   }


Technical Notes on Schedules
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. index:: Schedule; Technical Notes

Internally Bareos keeps a schedule as a bit mask. There are six masks and a minute field to each schedule. The masks are hour, day of the month (mday), month, day of the week (wday), week of the month (wom), and week of the year (woy). The schedule is initialized to have the bits of each of these masks set, which means that at the beginning of every hour, the job will run. When you specify a month for the first time, the mask will be cleared and the bit corresponding to your selected month will
be selected. If you specify a second month, the bit corresponding to it will also be added to the mask. Thus when Bareos checks the masks to see if the bits are set corresponding to the current time, your job will run only in the two months you have set. Likewise, if you set a time (hour), the hour mask will be cleared, and the hour you specify will be set in the bit mask and the minutes will be stored in the minute field.

For any schedule you have defined, you can see how these bits are set by doing a show schedules command in the Console program. Please note that the bit mask is zero based, and Sunday is the first day of the week (bit zero).


.. _DirectorResourceFileSet:

FileSet Resource
----------------

.. index::
   pair: Resource; FileSet

The FileSet resource defines what files are to be included or excluded in a backup job. A FileSet resource is required for each backup Job. It consists of a list of files or directories to be included, a list of files or directories to be excluded and the various backup options such as compression, encryption, and signatures that are to be applied to each file.

Any change to the list of the included files
will cause Bareos to automatically create a new FileSet
(defined by the name and an MD5 checksum of the Include/Exclude File directives contents).
Each time a new FileSet is created
Bareos will ensure that the next backup is always a full backup.
However, this does only apply to changes in directives
:config:option:`dir/FileSet/Include/File` and
:config:option:`dir/FileSet/Exclude/File`.
Changes in other directives or the :ref:`fileset-options` do not result
in upgrade to a full backup.
Use :config:option:`dir/FileSet/IgnoreFileSetChanges` to disable this behavior.


.. include:: /include/autogenerated/bareos-dir-resource-fileset-table.rst.inc

.. include:: /include/autogenerated/bareos-dir-resource-fileset-description.rst.inc

.. _fileset-include:

FileSet Include Resource
~~~~~~~~~~~~~~~~~~~~~~~~

The Include resource must contain a list of directories and/or files to be processed in the backup job.

Normally, all files found in all subdirectories of any directory in the Include File list will be backed up. The Include resource may also contain one or more Options resources that specify options such as compression to be applied to all or any subset of the files found when processing the file-list for backup. Please see below for more details concerning Options resources.

There can be any number of Include resources within the FileSet, each having its own list of directories or files to be backed up and the backup options defined by one or more Options resources.

Please take note of the following items in the FileSet syntax:

#. There is no equal sign (=) after the Include and before the opening brace ({). The same is true for the Exclude.

#. Each directory (or filename) to be included or excluded is preceded by a File =. Previously they were simply listed on separate lines.

#. The Exclude resource does not accept Options.

#. When using wild-cards or regular expressions, directory names are always terminated with a slash (/) and filenames have no trailing slash.

.. config:option:: dir/fileset/include/File

   :type: "path"
   :type: "<includefile-server"
   :type: "\\\\<includefile-client"
   :type: "\|command-server"
   :type: "\\\\\|command-client"

   The file list consists of one file or directory name per line. Directory names should be specified without a trailing slash with Unix path notation.

   .. note::

      Windows users, please take note to specify directories (even :file:`c:/...`) in Unix path notation. If you use Windows conventions, you will most likely not be able to restore your files due to the fact that the Windows path separator was defined as an escape character long before Windows existed, and Bareos adheres to that convention (i.e. means the next character appears as itself).

   You should always specify a full path for every directory and file that you list in the FileSet. In addition, on Windows machines, you should always prefix the directory or filename with the drive specification (e.g. :file:`c:/xxx`) using Unix directory name separators (forward slash). The drive letter itself can be upper or lower case (e.g. :file:`c:/xxx` or :file:`C:/xxx`).

   A file item may not contain wild-cards.
   Use directives in the :ref:`fileset-options`
   if you wish to specify wild-cards or regular expression matching.

   Bareos’s default for processing directories is to recursively descend in the directory saving all files and subdirectories. Bareos will not by default cross filesystems (or mount points in Unix parlance). This means that if you specify the root partition (e.g. :file:`/`), Bareos will save only the root partition and not any of the other mounted filesystems. Similarly on Windows systems, you must explicitly specify each of the drives you want saved (e.g. :file:`c:/` and :file:`d:/` ...). In addition, at least for
   Windows systems, you will most likely want to enclose each specification within double quotes particularly if the directory (or file) name contains spaces.

   Take special care not to include a directory twice or Bareos will by default backup the same files two times wasting a lot of space on your archive device. Including a directory twice is very easy to do. For example:

   .. code-block:: bareosconfig
      :caption: File Set

      Include {
        Options {
          Compression = LZ4
        }
        File = /
        File = /usr
      }

   on a Unix system where :file:`/usr` is a subdirectory (rather than a mounted filesystem) will cause :file:`/usr` to be backed up twice.
   Using the directive :config:option:`dir/fileset/include/options/Shadowing` Bareos can be configured to detect and exclude duplicates automatically.

   To include names containing spaces, enclose the name between double-quotes.

   There are a number of special cases when specifying directories and files.
   They are:

   ``@filename``
      Any name preceded by an at-sign (@) is assumed to be the name of a file, which contains a list of files each preceded by a "File =". The named file is read once when the configuration file is parsed during the Director startup. Note, that the file is read on the Director’s machine and not on the Client’s. In fact, the @filename can appear anywhere within a configuration file where a token would be read, and the contents of the named file will be logically inserted in the place of the @filename. What must be in the file depends on the location the @filename is specified in the conf file. For example:

      .. code-block:: bareosconfig
         :caption: File Set with Include File

         Include {
           Options {
             Compression = LZ4
           }
           @/home/files/my-files
         }


   ``File = "<includefile-server"``
      Any file item preceded by a less-than sign (``<``) will be taken to be a file. This file will be read on the Director’s machine (see below for doing it on the Client machine) at the time the Job starts, and the data will be assumed to be a list of directories or files, one per line, to be included. The names should start in column 1 and should not be quoted even if they contain spaces. This feature allows you to modify the external file and change what will be saved without stopping and restarting Bareos as would be necessary if using the @ modifier noted above. For example:

      .. code-block:: bareosconfig

         Include {
           Options {
             Signature = XXH128
           }
           File = "</home/files/local-filelist"
         }


   ``File = "\\<includefile-client"``
      If you precede the less-than sign (``<``) with two backslashes as in ``\\<``, the file-list will be read on the Client machine instead of on the Director’s machine.

      .. code-block:: bareosconfig

         Include {
           Options {
             Signature = XXH128
           }
           File = "\\</home/xxx/filelist-on-client"
         }


   ``File = "|command-server"``
      Any name beginning with a vertical bar (|) is assumed to be the name of a program. This program will be executed on the Director’s machine at the time the Job starts (not when the Director reads the configuration file), and any output from that program will be assumed to be a list of files or directories, one per line, to be included. Before submitting the specified command Bareos will performe :ref:`character substitution <character substitution>`.

      This allows you to have a job that, for example, includes all the local partitions even if you change the partitioning by adding a disk. The examples below show you how to do this. However, please note two things:

      1. if you want the local filesystems, you probably should be using the :config:option:`dir/fileset/include/options/FsType` directive and set :config:option:`dir/fileset/include/options/OneFs = no`.
      2. the exact syntax of the command needed in the examples below is very system dependent. For example, on recent Linux systems, you may need to add the -P option, on FreeBSD systems, the options will be different as well.

      In general, you will need to prefix your command or commands with a :command:`sh -c` so that they are invoked by a shell. This will not be the case if you are invoking a script as in the second example below. Also, you must take care to escape (precede with a ``\``) wild-cards, shell character, and to ensure that any spaces in your command are escaped as well. If you use a single quotes (’) within a double quote ("), Bareos will treat everything between the single quotes as one field so it will not be necessary to escape the spaces. In general, getting all the quotes and escapes correct is a real pain as you can see by the next example. As a consequence, it is often easier to put everything in a file and simply use the file name within Bareos. In that case the sh -c will not be necessary providing the first line of the file is #!/bin/sh.

      As an example:

      .. code-block:: bareosconfig
         :caption: File Set with inline script

         Include {
            Options {
              Signature = XXH128
            }
            File = "|sh -c 'df -l | grep \"^/dev/hd[ab]\" | grep -v \".*/tmp\" | awk \"{print \\$6}\"'"
         }

      will produce a list of all the local partitions on a Linux system. Quoting is a real problem because you must quote for Bareos which consists of preceding every \\ and every " with a \\, and you must also quote for the shell command. In the end, it is probably easier just to execute a script file with:

      .. code-block:: bareosconfig
         :caption: File Set with external script

         Include {
           Options {
             Signature = XXH128
           }
           File = "|my_partitions"
         }

      where :command:`my_partitions` has:

      .. code-block:: shell

         #!/bin/sh
         df -l | grep "^/dev/hd[ab]" | grep -v ".*/tmp" \
               | awk "{print \$6}"


   ``File = "\\|command-client"``
      If the vertical bar (``|``) in front of :command:`my_partitions` is preceded by a two backslashes as in ``\\|``, the program will be executed on the Client’s machine instead of on the Director’s machine. An example, provided by John Donagher, that backs up all the local UFS partitions on a remote system is:

      .. code-block:: bareosconfig
         :caption: File Set with inline script in quotes

         FileSet {
           Name = "All local partitions"
           Include {
             Options {
               Signature = XXH128
               OneFs=yes
             }
             File = "\\|bash -c \"df -klF ufs | tail +2 | awk '{print \$6}'\""
           }
         }

      The above requires two backslash characters after the double quote (one preserves the next one). If you are a Linux user, just change the ufs to ext3 (or your preferred filesystem type), and you will be in business.

      If you know what filesystems you have mounted on your system, e.g. for Linux only using ext2, ext3 or ext4, you can backup all local filesystems using something like:

      .. code-block:: bareosconfig
         :caption: File Set to backup all ext fs partitions

         Include {
            Options {
              Signature = XXH128
              OneFs = no
              FsType = ext2
              FsType = ext3
              FsType = ext4
            }
            File = /
         }


   Raw Partition
      .. index::
         single: Backup; Partitions
         single: Backup; Raw Partitions

      If you explicitly specify a block device such as :file:`/dev/hda1`, then Bareos will assume that this is a raw partition to be backed up. In this case, you are strongly urged to specify a Sparse=yes include option, otherwise, you will save the whole partition rather than just the actual data that the partition contains. For example:

      .. code-block:: bareosconfig
         :caption: Backup Raw Partitions

         Include {
           Options {
             Signature = XXH128
             Sparse = yes
           }
           File = /dev/hd6
         }

      will backup the data in device :file:`/dev/hd6`. Note, :file:`/dev/hd6` must be the raw partition itself. Bareos will not back it up as a raw device if you specify a symbolic link to a raw device such as my be created by the LVM Snapshot utilities.


.. config:option:: dir/fileset/include/ExcludeDirContaining

   :type: filename

   This directive can be added to the Include section of the FileSet resource. If the specified filename (filename-string) is found on the Client in any directory to be backed up, the whole directory will be ignored (not backed up). We recommend to use the filename :file:`.nobackup`, as it is a hidden file on unix systems, and explains what is the purpose of the file.

   For example:

   .. code-block:: bareosconfig
      :caption: Exlude Directories containing the file .nobackup

      # List of files to be backed up
      FileSet {
        Name = "MyFileSet"
        Include {
          Options {
            Signature = XXH128
          }
          File = /home
          Exclude Dir Containing = .nobackup
        }
      }

   But in :file:`/home`, there may be hundreds of directories of users and some people want to indicate that they don’t want to have certain directories backed up. For example, with the above FileSet, if the user or sysadmin creates a file named .nobackup in specific directories, such as

   ::

      /home/user/www/cache/.nobackup
      /home/user/temp/.nobackup

   then Bareos will not backup the two directories named:

   ::

      /home/user/www/cache
      /home/user/temp

   Subdirectories will not be backed up. That is, the directive applies to the two directories in question and any children (be they files, directories, etc).

.. # define a hard line break for HTML
.. |br| raw:: html

   <br />

.. _directive-fileset-plugin:

.. config:option:: dir/fileset/include/Plugin

   :type: "plugin-name" |br|
          ":plugin-parameter1" |br|
          ":plugin-parameter2" |br|
          ":..."

   Instead of only specifying files, a file set can also use plugins. Plugins are additional libraries that handle specific requirements. The purpose of plugins is to provide an interface to any system program for backup and restore. That allows you, for example, to do database backups without a local dump.

   The syntax and semantics of the Plugin directive require the first part of the string up to the colon to be the name of the plugin. Everything after the first colon is ignored by the File daemon but is passed to the plugin. Thus the plugin writer may define the meaning of the rest of the string as he wishes.

   Since :sinceVersion:`20: Multiline Strings` the plugin string can be spread over multiple lines using quotes as shown above.

   For more information, see :ref:`fdPlugins`.

   It is also possible to define more than one plugin directive in a FileSet to do several database dumps at once.


.. config:option:: dir/fileset/include/Options

   See the :ref:`fileset-options` section.



.. _fileset-exclude:

FileSet Exclude Resource
~~~~~~~~~~~~~~~~~~~~~~~~

.. index::
   single: Excluding Files and Directories

FileSet Exclude-Resources very similar to Include-Resources, except that they only allow following directives:

.. config:option:: dir/fileset/exclude/file

   :type: "path"
   :type: "<includefile-server"
   :type: "\\\\<includefile-client"
   :type: "\|command-server"
   :type: "\\\\\|command-client"

   Files to exclude are descripted in the same way as at the :ref:`fileset-include`.

   For example:

   .. code-block:: bareosconfig
      :caption: FileSet using Exclude

      FileSet {
        Name = Exclusion_example
        Include {
          Options {
            Signature = XXH128
          }
          File = /
          File = /boot
          File = /home
          File = /rescue
          File = /usr
        }
        Exclude {
          File = /proc
          File = /tmp                          # Don't add trailing /
          File = .journal
          File = .autofsck
        }
      }

   Another way to exclude files and directories is to use the
   :config:option:`dir/fileset/include/options/Exclude = yes` setting
   in a Include section.



.. _fileset-options:

FileSet Options Resource
~~~~~~~~~~~~~~~~~~~~~~~~

The Options resource is optional, but when specified, it will contain a list of keyword=value options to be applied to the file-list. See below for the definition of file-list. Multiple Options resources may be specified one after another. As the files are found in the specified directories, the Options will applied to the filenames to determine if and how the file should be backed up. The wildcard and regular expression pattern matching parts of the Options resources are checked in the order
they are specified in the FileSet until the first one that matches. Once one matches, the compression and other flags within the Options specification will apply to the pattern matched.

A key point is that in the absence of an Option or no other Option is matched, every file is accepted for backing up. This means that if you want to exclude something, you must explicitly specify an Option with an exclude = yes and some pattern matching.

Once Bareos determines that the Options resource matches the file under consideration, that file will be saved without looking at any other Options resources that may be present. This means that any wild cards must appear before an Options resource without wild cards.

If for some reason, Bareos checks all the Options resources to a file under consideration for backup, but there are no matches (generally because of wild cards that don’t match), Bareos as a default will then backup the file. This is quite logical if you consider the case of no Options clause is specified, where you want everything to be backed up, and it is important to keep in mind when excluding as mentioned above.

However, one additional point is that in the case that no match was found, Bareos will use the options found in the last Options resource. As a consequence, if you want a particular set of "default" options, you should put them in an Options resource after any other Options.

It is a good idea to put all your wild-card and regex expressions inside double quotes to prevent conf file scanning problems.

This is perhaps a bit overwhelming, so there are a number of examples included below to illustrate how this works.

You find yourself using a lot of Regex statements, which will cost quite a lot of CPU time, we recommend you simplify them if you can, or better yet convert them to Wild statements which are much more efficient.

The directives within an Options resource may be one of the following:

.. config:option:: dir/fileset/include/options/AutoExclude

   :type: BOOLEAN
   :default: yes

   Automatically exclude files not intended for backup.
   Currently only used for Windows, to exclude files defined in the registry key ``HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\BackupRestore\FilesNotToBackup``, see section :ref:`FilesNotToBackup`.

   Since :sinceVersion:`14.2.2: Auto Exclude`.

.. config:option:: dir/fileset/include/options/compression

   :type: <GZIP|GZIP1|...|GZIP9|LZO|LZFAST|LZ4|LZ4HC>

   Configures the software compression to be used by the File Daemon.
   The compression is done on a file by file basis.

   Software compression gets important if you are writing to a device that does not support compression by itself
   (e.g. hard disks). Otherwise, all modern tape drive do support hardware compression.

   Software compression can also be helpful to reduce the required network bandwidth,
   as compression is done on the File Daemon.
   In most cases, :strong:`LZ4` is the best choice, because it is relatively fast.
   If the compression rate of :strong:`LZ4` isn't good enough,
   you might consider :strong:`LZ4HC`.
   However, using Bareos software compression and device hardware compression together
   is not advised, as trying to compress precompressed data is a very CPU-intense task
   and probably end up in even larger data.

   You can overwrite this option per Storage resource using the
   :config:option:`dir/storage/AllowCompression = no` option.

   GZIP
        All files saved will be software compressed using the GNU ZIP
        compression format.

        Specifying :strong:`GZIP` uses the default compression level 6
        (i.e. :strong:`GZIP` is identical to :strong:`GZIP6`).
        If you want a different compression
        level (1 through 9), you can specify it by appending the level number
        with no intervening spaces to :strong:`GZIP`.
        Thus :strong:`compression=GZIP1` would give minimum compression
        but the fastest algorithm, and :strong:`compression=GZIP9`
        would give the highest level of compression, but requires more computation.
        According to the GZIP documentation, compression levels greater than six
        generally give very little extra compression and are rather CPU intensive.

   LZFAST
        .. deprecated:: 19.2

        All files saved will be software compressed using the LZFAST
        compression format.

        LZFAST provides much faster compression and decompression speed but lower
        compression ratio than GZIP. If your CPU is fast enough you should be able
        to compress your data without making the backup duration longer.

        .. warning:: This is a nonstandard compression algorithm and support for compressing backups using it may be removed in a future version. Please consider using one of the other algorithms instead.

   LZO
        All files saved will be software compressed using the LZO
        compression format.

        LZO provides much faster compression and decompression speed but lower
        compression ratio than GZIP. If your CPU is fast enough you should be able
        to compress your data without making the backup duration longer.

        Note that Bareos only use one compression level LZO1X-1 specified by LZO.

   LZ4
        All files saved will be software compressed using the LZ4
        compression format.

        LZ4 provides much faster compression and decompression speed but lower
        compression ratio than GZIP. If your CPU is fast enough you should be able
        to compress your data without making the backup duration longer.

        Both LZ4 and LZ4HC have the same decompression speed which is about twice
        the speed of the LZO compression. So for a restore both LZ4 and LZ4HC are
        good candidates.

   LZ4HC
        All files saved will be software compressed using the LZ4HC
        compression format.

        LZ4HC is the High Compression version of the LZ4 compression. It has
        a higher compression ratio than LZ4 and is more comparable to GZIP-6
        in both compression rate and CPU usage.

        Both LZ4 and LZ4HC have the same decompression speed which is about twice
        the speed of the LZO compression. So for a restore both LZ4 and LZ4HC are
        good candidates.



.. config:option:: dir/fileset/include/options/Signature

   :type: <MD5|SHA1|SHA256|SHA512|XXH128>

   It is strongly recommend to use signatures for your backups.
   Note, only one type of signature can be computed per file.

   You have to find the right balance between speed and security. Todays CPUs have often special instructions that can calculate checksums very fast. So if in doubt, testing the speed of the different signatures in your environment will show what is the fastest algorithm.
   The XXH128 algorithm is not cryptographically safe, but it is suitable for non-cryptographic purposes (like calculating a checksum to avoid avoid data corruption as used by Bareos here).  Bareos suggests XXH128 as the preferred algorithm due to the fact that it has by magnitudes lower computational requirements. The calculation of the cryptographical checksum like MD5 or SHA has proven to be the bottleneck in environments with high-speed requirements.

   MD5
           :index:`\ <single: MD5>`
           :index:`\ <single: signature; MD5>`
           An MD5 signature (128 bits) will be computed for each file saved.  Adding this
           option generates about 5\% extra overhead for each file saved.  In
           addition to the additional CPU time, the MD5 signature adds 16 more
           bytes per file to your catalog.

   SHA1
           :index:`\ <single: SHA1>`
           :index:`\ <single: signature; SHA1>`
           An SHA1 (160 bits) signature will be computed for each file saved.
           The SHA1 algorithm is purported to be some what slower than the MD5
           algorithm, but at the same time is significantly better from a cryptographic
           point of view (i.e. much fewer collisions).
           The SHA1 signature requires adds 20 bytes per file to your catalog.

   SHA256
           :index:`\ <single: SHA256>`
           :index:`\ <single: signature; SHA256>`
           An SHA256 signature (256 bits) will be computed for each file saved.
           The SHA256 algorithm is purported to be slower than the SHA1 algorithm, but
           at the same time is significantly better from a cryptographic point of view
           (i.e. no collisions found).
           The SHA256 signature requires 32 bytes per file in the catalog.

   SHA512
           :index:`\ <single: SHA512>`
           :index:`\ <single: signature; SHA512>`
           An SHA512 signature (512 bits) will be computed for each file saved.
           This is the slowest algorithm and is equivalent in terms of cryptographic
           value than SHA256.
           The SHA512 signature requires 64 bytes per file in the catalog.

   XXH128
           :index:`\ <single: XXH128>`
           :index:`\ <single: signature; XXH128>`
           An xxHash signature (XXH3, 128 bits) will be computed for each file saved.
           This is the algorithm with the least computational requirements, but it is also not cryptographically safe.
           The XXH128 signature requires 16 bytes per file in the catalog.



.. config:option:: dir/fileset/include/options/BaseJob

   :type: <options>


   The options letters specified are used when running a :strong:`Backup Level=Full`
   with BaseJobs. The options letters are the same than in the :strong:`verify=`
   option below.

.. config:option:: dir/fileset/include/options/accurate

   :type: <options>

   The options letters specified are used when
   running a :strong:`Backup Level=Incremental/Differential` in Accurate mode. The
   options letters are the same than in the :strong:`verify=` option below.
   The default setting is **mcs** which means that *modification time*, *change time*
   and *size* are compared.

.. config:option:: dir/fileset/include/options/Verify

   :type: <options>

   The options letters specified are used  when running a :strong:`Verify
   Level=Catalog` as well as the  :strong:`DiskToCatalog` level job. The options
   letters may be any  combination of the following:

    i
        compare the inodes

    p
        compare the permission bits

    n
        compare the number of links

    u
        compare the user id

    g
        compare the group id

    s
        compare the size

    a
        compare the access time

    m
        compare the modification time (st\_mtime)

    c
        compare the change time (st\_ctime)

    d
        report file size decreases

    5
        compare the MD5 signature

    1
        compare the SHA1 signature

    A
        Only for Accurate option, it allows to always backup the file

    A useful set of general options on the :strong:`Level=Catalog`  or :strong:`Level=DiskToCatalog`  verify is :strong:`pins5` i.e. compare permission bits,
    inodes, number  of links, size, and MD5 changes.


.. config:option:: dir/fileset/include/options/OneFs

   :type: yes|no
   :default: yes

   If set to :strong:`yes`, Bareos will remain on a single
   file system.  That is it will not backup file systems that are mounted
   on a subdirectory.  If you are using a Unix system, you may not even be
   aware that there are several different filesystems as they are often
   automatically mounted by the OS (e.g.  :file:`/dev`, :file:`/net`, :file:`/sys`, :file:`/proc`, ...).
   Bareos will inform you when it decides not to
   traverse into another filesystem.  This can be very useful if you forgot
   to backup a particular partition.
   An example of the informational
   message in the job report is:

   .. code-block:: bareoslog

      host-fd: /misc is a different filesystem. Will not descend from / into /misc
      host-fd: /net is a different filesystem. Will not descend from / into /net
      host-fd: /var/lib/nfs/rpc_pipefs is a different filesystem. Will not descend from /var/lib/nfs into /var/lib/nfs/rpc_pipefs
      host-fd: /selinux is a different filesystem. Will not descend from / into /selinux
      host-fd: /sys is a different filesystem. Will not descend from / into /sys
      host-fd: /dev is a different filesystem. Will not descend from / into /dev
      host-fd: /home is a different filesystem. Will not descend from / into /home


   If you wish to backup multiple filesystems, you can  explicitly
   list each filesystem you want saved.  Otherwise, if you set the onefs option
   to :strong:`no`, Bareos will backup  all mounted file systems (i.e. traverse mount
   points) that  are found within the :strong:`FileSet`. Thus if  you have NFS or
   Samba file systems mounted on a directory listed  in your FileSet, they will
   also be backed up. Normally, it is  preferable to set :config:option:`dir/fileset/include/options/OneFs = yes` and to
   explicitly name  each filesystem you want backed up. Explicitly naming  the
   filesystems you want backed up avoids the possibility  of getting into a
   infinite loop recursing filesystems.  Another possibility is to
   use :config:option:`dir/fileset/include/options/OneFs = no` and to set :config:option:`dir/fileset/include/options/FsType = ext2, ...`.
   See the example below for more details.

   If you think that Bareos should be backing up a particular directory
   and it is not, and you have :strong:`onefs=yes` set, before you complain,
   please do:

   .. code-block:: shell-session

      stat /
      stat <filesystem>


   where you replace :strong:`filesystem` with the one in question.  If the
   :strong:`Device:` number is different for / and for your filesystem, then they
   are on different filesystems.  E.g.

   .. code-block:: shell-session

      root@host:~# stat /
      File: `/'
      Size: 4096            Blocks: 16         IO Block: 4096   directory
      Device: 302h/770d       Inode: 2           Links: 26
      Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
      Access: 2005-11-10 12:28:01.000000000 +0100
      Modify: 2005-09-27 17:52:32.000000000 +0200
      Change: 2005-09-27 17:52:32.000000000 +0200

      root@host:~# stat /net
      File: `/home'
      Size: 4096            Blocks: 16         IO Block: 4096   directory
      Device: 308h/776d       Inode: 2           Links: 7
      Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
      Access: 2005-11-10 12:28:02.000000000 +0100
      Modify: 2005-11-06 12:36:48.000000000 +0100
      Change: 2005-11-06 12:36:48.000000000 +0100


   Also be aware that even if you include :file:`/home` in your list
   of files to backup, as you most likely should, you will get the
   informational message that  "/home is a different filesystem" when
   Bareos is processing the :file:`/` directory.  This message does not
   indicate an error. This message means that while examining the
   :strong:`File =` referred to in the second part of the message, Bareos will
   not descend into the directory mentioned in the first part of the message.
   However, it is possible that the separate filesystem will be backed up
   despite the message. For example, consider the following FileSet:

   .. code-block:: bareosconfig

      File = /
      File = /var

   where :file:`/var` is a separate filesystem.  In this example, you will get a
   message saying that Bareos will not decend from :file:`/` into :file:`/var`.  But
   it is important to realise that Bareos will descend into :file:`/var` from the
   second File directive shown above.  In effect, the warning is bogus,
   but it is supplied to alert you to possible omissions from your FileSet. In
   this example, :file:`/var` will be backed up.  If you changed the FileSet such
   that it did not specify :file:`/var`, then :file:`/var` will not be backed up.

.. config:option:: dir/fileset/include/options/HonorNoDumpFlag

   :type: yes|no

   If your file system supports the :strong:`nodump` flag (e. g. most
   BSD-derived systems) Bareos will honor the setting of the flag
   when this option is set to :strong:`yes`. Files having this flag set
   will not be included in the backup and will not show up in the
   catalog. For directories with the :strong:`nodump` flag set recursion
   is turned off and the directory will be listed in the catalog.
   If the :strong:`honor nodump flag` option is not defined
   or set to :strong:`no` every file and directory will be eligible for
   backup.

.. _portable:

.. config:option:: dir/fileset/include/options/portable

   :type: yes|no

   If set to :strong:`yes` (default is :strong:`no`), the Bareos File daemon will
   backup Win32 files in a portable format, but not all Win32 file
   attributes will be saved and restored.  By default, this option is set
   to :strong:`no`, which means that on Win32 systems, the data will be backed
   up using Windows API calls and on WinNT/2K/XP, all the security and
   ownership attributes will be properly backed up (and restored).  However
   this format is not portable to other systems -- e.g.  Unix, Win95/98/Me.
   When backing up Unix systems, this option is ignored, and unless you
   have a specific need to have portable backups, we recommend accept the
   default (:strong:`no`) so that the maximum information concerning your files
   is saved.

.. config:option:: dir/fileset/include/options/recurse

   :type: yes|no

   If set to :strong:`yes` (the default), Bareos will recurse (or descend) into
   all subdirectories found unless the directory is explicitly excluded
   using an :strong:`exclude` definition.  If you set :strong:`recurse=no`, Bareos
   will save the subdirectory entries, but not descend into the
   subdirectories, and thus will not save the files or directories
   contained in the subdirectories.  Normally, you will want the default
   (:strong:`yes`).

.. config:option:: dir/fileset/include/options/sparse

   :type: yes|no

   Enable special code that checks for sparse files such as created by
   ndbm.  The default is :strong:`no`, so no checks are made for sparse files.
   You may specify :strong:`sparse=yes` even on files that are not sparse file.
   No harm will be done, but there will be a small additional overhead to
   check for buffers of all zero, and if there is a 32K block of all zeros
   (see below), that block will become a hole in the file, which
   may not be desirable if the original file was not a sparse file.

   :strong:`Restrictions:` Bareos reads files in 32K buffers.  If the whole
   buffer is zero, it will be treated as a sparse block and not written to
   tape.  However, if any part of the buffer is non-zero, the whole buffer
   will be written to tape, possibly including some disk sectors (generally
   4098 bytes) that are all zero.  As a consequence, Bareos's detection of
   sparse blocks is in 32K increments rather than the system block size.
   If anyone considers this to be a real problem, please send in a request
   for change with the reason.

   If you are not familiar with sparse files, an example is say a file
   where you wrote 512 bytes at address zero, then 512 bytes at address 1
   million.  The operating system will allocate only two blocks, and the
   empty space or hole will have nothing allocated.  However, when you read
   the sparse file and read the addresses where nothing was written, the OS
   will return all zeros as if the space were allocated, and if you backup
   such a file, a lot of space will be used to write zeros to the volume.
   Worse yet, when you restore the file, all the previously empty space
   will now be allocated using much more disk space.  By turning on the
   :strong:`sparse` option, Bareos will specifically look for empty space in
   the file, and any empty space will not be written to the Volume, nor
   will it be restored.  The price to pay for this is that Bareos must
   search each block it reads before writing it.  On a slow system, this
   may be important.  If you suspect you have sparse files, you should
   benchmark the difference or set sparse for only those files that are
   really sparse.

   You probably should not use this option on files or raw disk devices
   that are not really sparse files (i.e. have holes in them).


.. _readfifo:

.. config:option:: dir/fileset/include/options/ReadFifo

   :type: yes|no

   If enabled, tells the Client to read the data on a backup and write the
   data on a restore to any FIFO (pipe) that is explicitly mentioned in the
   FileSet.  In this case, you must have a program already running that
   writes into the FIFO for a backup or reads from the FIFO on a restore.
   This can be accomplished with the :strong:`RunBeforeJob` directive.  If this
   is not the case, Bareos will hang indefinitely on reading/writing the
   FIFO. When this is not enabled (default), the Client simply saves the
   directory entry for the FIFO.

   Normally, when Bareos runs a RunBeforeJob, it waits until that
   script terminates, and if the script accesses the FIFO to write
   into it, the Bareos job will block and everything will stall.
   However, Vladimir Stavrinov as supplied tip that allows this feature
   to work correctly.  He simply adds the following to the beginning
   of the RunBeforeJob script:

   .. code-block:: sh

      exec > /dev/null

   .. code-block:: bareosconfig
      :caption: FileSet with Fifo

      Include {
        Options {
          signature=SHA1
          readfifo=yes
        }
        File = "/home/abc/fifo"
      }

   This feature can be used to do a "hot" database backup.
   You can use the :strong:`RunBeforeJob` to create the fifo
   and to start a program that dynamically reads your database and writes
   it to the fifo.  Bareos will then write it to the Volume.

   During the restore operation, the inverse is true, after Bareos creates
   the fifo if there was any data stored with it (no need to explicitly
   list it or add any options), that data will be written back to the fifo.
   As a consequence, if any such FIFOs exist in the fileset to be restored,
   you must ensure that there is a reader program or Bareos will block, and
   after one minute, Bareos will time out the write to the fifo and move on
   to the next file.

   If you are planing to use a Fifo for backup, better take a look to the :ref:`bpipe` section.


.. config:option:: dir/fileset/include/options/NoAtime

   :type: yes|no

   If enabled, and if your Operating System supports the O\_NOATIME file
   open flag, Bareos will open all files to be backed up with this option.
   It makes it possible to read a file without updating the inode atime
   (and also without the inode ctime update which happens if you try to set
   the atime back to its previous value).  It also prevents a race
   condition when two programs are reading the same file, but only one does
   not want to change the atime.  It's most useful for backup programs and
   file integrity checkers (and Bareos can fit on both categories).

   This option is particularly useful for sites where users are sensitive
   to their MailBox file access time.  It replaces both the :strong:`keepatime`
   option without the inconveniences of that option (see below).

   If your Operating System does not support this option, it will be
   silently ignored by Bareos.


.. config:option:: dir/fileset/include/options/MtimeOnly

   :type: yes|no
   :default: no

   If enabled, tells the Client that the selection of files during
   Incremental and Differential backups should based only on the st\_mtime
   value in the stat() packet.  The default is :strong:`no` which means that
   the selection of files to be backed up will be based on both the
   st\_mtime and the st\_ctime values.  In general, it is not recommended
   to use this option.

.. config:option:: dir/fileset/include/options/KeepAtime

   :type: yes|no

   The default is :strong:`no`.  When enabled, Bareos will reset the st\_atime
   (access time) field of files that it backs up to their value prior to
   the backup.  This option is not generally recommended as there are very
   few programs that use st\_atime, and the backup overhead is increased
   because of the additional system call necessary to reset the times.
   However, for some files, such as mailboxes, when Bareos backs up the
   file, the user will notice that someone (Bareos) has accessed the
   file. In this, case keepatime can be useful.
   (I'm not sure this works on Win32).

   Note, if you use this feature, when Bareos resets the access time, the
   change time (st\_ctime) will automatically be modified by the system,
   so on the next incremental job, the file will be backed up even if
   it has not changed. As a consequence, you will probably also want
   to use :strong:`mtimeonly = yes` as well as keepatime (thanks to
   Rudolf Cejka for this tip).

.. config:option:: dir/fileset/include/options/CheckFileChanges

   :type: yes|no
   :default: no


   If enabled, the Client will check size, age of each file after
   their backup to see if they have changed during backup. If time
   or size mismatch, an error will raise.


   .. code-block:: bconsole

      zog-fd: Client1.2007-03-31_09.46.21 Error: /tmp/test mtime changed during backup.


   .. note::

      This option is intended to be used :config:option:`dir/fileset/include/File` resources.
      Using it with :config:option:`dir/fileset/include/Plugin` filesets will generate warnings during backup.

.. config:option:: dir/fileset/include/options/HardLinks

   :type: yes|no
   :default: no

   .. warning::

      Since :sinceVersion:`23.0.0: fileset keep hard links option switched from yes to no`
      the default is :strong:`no`.

   When disabled, Bareos will backup each file individually and restore them as
   unrelated files as well. The fact that the files were hard links will be
   lost.

   When enabled, this directive will cause hard links to be backed up as hard
   links. For each set of hard links, the file daemon will only backup the file
   contents once -- when it encounters the first file of that set -- and only
   backup meta data and a reference to that first file for each subsequent file
   in that set.

   Be aware that the process of keeping track of the hard links can be quite
   expensive if you have lots of them (tens of thousands or more). Backups
   become very long and the File daemon will consume a lot of CPU power
   checking hard links.

   See related performance option like :config:option:`dir/director/OptimizeForSize`

   .. note::

      If you created backups with :config:option:`dir/fileset/include/options/HardLinks = yes`
      you should only ever restore all files in that set of hard links at once
      or not restore any of them.
      If you were to restore a file inside that set, which was not the file
      with the contents attached, then Bareos will not restore its data, but
      instead just try to link with the file it references and restore its meta
      data.
      This means that the newly restored file might not actually have the same
      contents as when it was backed up.

.. config:option:: dir/fileset/include/options/Wild

   :type: <string>

   Specifies a wild-card string to be applied to the filenames and
   directory names.  Note, if :strong:`Exclude` is not enabled, the wild-card
   will select which files are to be included.  If :strong:`Exclude=yes` is
   specified, the wild-card will select which files are to be excluded.
   Multiple wild-card directives may be specified, and they will be applied
   in turn until the first one that matches.  Note, if you exclude a
   directory, no files or directories below it will be matched.

   It is recommended to enclose the string in double quotes.

   You may want to test your expressions prior to running your
   backup by using the :ref:`bwild` program.
   You can also test your full FileSet definition by using
   the :ref:`estimate <estimate>` command.

   An example of excluding with the WildFile option is presented
   at :ref:`FileSetExamples`


.. config:option:: dir/fileset/include/options/WildDir

   :type: <string>

   Specifies a wild-card string to be applied to directory names only.  No
   filenames will be matched by this directive.  Note, if :strong:`Exclude` is
   not enabled, the wild-card will select directories to be
   included.  If :strong:`Exclude=yes` is specified, the wild-card will select
   which directories are to be excluded.  Multiple wild-card directives may be
   specified, and they will be applied in turn until the first one that
   matches.  Note, if you exclude a directory, no files or directories
   below it will be matched.

   It is recommended to enclose the string in double quotes.

   You may want to test your expressions prior to running your
   backup by using the :ref:`bwild` program.
   You can also test your full FileSet definition by using
   the :ref:`estimate <estimate>` command.

   An example of excluding with the WildFile option is presented
   at :ref:`FileSetExamples`


.. config:option:: dir/fileset/include/options/WildFile

   :type: <string>

   Specifies a wild-card string to be applied to non-directories. That
   is no directory entries will be matched by this directive.
   However, note that the match is done against the full path and filename,
   so your wild-card string must take into account that filenames
   are preceded by the full path.
   If :config:option:`dir/fileset/include/options/Exclude`
   is not enabled, the wild-card will select which files are to be
   included.
   If :config:option:`dir/fileset/include/options/Exclude=yes` is specified,
   the wild-card will select
   which files are to be excluded.  Multiple wild-card directives may be
   specified, and they will be applied in turn until the first one that
   matches.

   It is recommended to enclose the string in double quotes.

   You may want to test your expressions prior to running your
   backup by using the :ref:`bwild` program.
   You can also test your full FileSet definition by using
   the :ref:`estimate <estimate>` command.

   An example of excluding with the WildFile option is presented
   at :ref:`FileSetExamples`


.. _FileRegex:

.. config:option:: dir/fileset/include/options/Regex

   :type: <string>

   Specifies a POSIX extended regular expression to be applied to the
   filenames and directory names, which include the full path.  If :strong:`
   Exclude` is not enabled, the regex will select which files are to be
   included. If :config:option:`dir/fileset/include/options/Exclude = yes` is specified, the regex will select
   which files are to be excluded.  Multiple regex directives may be
   specified within an Options resource, and they will be applied in turn
   until the first one that matches.  Note, if you exclude a directory, no
   files or directories below it will be matched.

   It is recommended to enclose the string in double quotes.

   The regex libraries differ from one operating system to
   another, and in addition, regular expressions are complicated,
   so you may want to test your expressions prior to running your
   backup by using the :ref:`bregex` program.
   You can also test your full FileSet definition by using
   the :ref:`estimate <estimate>` command.

   You find yourself using a lot of Regex statements, which will cost quite a lot
   of CPU time, we recommend you simplify them if you can, or better yet
   convert them to Wild statements which are much more efficient.


.. config:option:: dir/fileset/include/options/RegexFile

   :type: <string>

   Specifies a POSIX extended regular expression to be applied to
   non-directories. No directories will be matched by this directive.
   However, note that the match is done against the full path and
   filename, so your regex string must take into account that filenames
   are preceded by the full path.
   If :strong:`Exclude` is not enabled, the regex will select which files are
   to be included.  If :strong:`Exclude=yes` is specified, the regex will
   select which files are to be excluded.  Multiple regex directives may be
   specified, and they will be applied in turn until the first one that
   matches.

   It is recommended to enclose the string in double quotes.

   The regex libraries differ from one operating system to
   another, and in addition, regular expressions are complicated,
   so you may want to test your expressions prior to running your
   backup by using the :ref:`bregex` program.

.. config:option:: dir/fileset/include/options/RegexDir

   :type: <string>

   Specifies a POSIX extended regular expression to be applied to directory
   names only.  No filenames will be matched by this directive.  Note, if
   :strong:`Exclude` is not enabled, the regex will select directories
   files are to be included.  If :strong:`Exclude=yes` is specified, the
   regex will select which files are to be excluded.  Multiple
   regex directives may be specified, and they will be applied in turn
   until the first one that matches.  Note, if you exclude a directory, no
   files or directories below it will be matched.

   It is recommended to enclose the string in double quotes.

   The regex libraries differ from one operating system to
   another, and in addition, regular expressions are complicated,
   so you may want to test your expressions prior to running your
   backup by using the :ref:`bregex` program.

.. config:option:: dir/fileset/include/options/Exclude

   :type: BOOLEAN

   When enabled, any files matched within the
   Options will be excluded from the backup.


.. _ACLSupport:

.. config:option:: dir/fileset/include/options/AclSupport

   :type: yes|no
   :default: yes

   Since :sinceVersion:`18.2.4: ACL support = yes (new default)`
   the default is :strong:`yes`.
   If this option is set to yes, and you have the
   POSIX :strong:`libacl` installed on your Linux system, Bareos will backup the
   file and directory Unix Access Control Lists (ACL) as defined in IEEE Std
   1003.1e draft 17 and "POSIX.1e" (abandoned).  This feature is
   available on Unix systems only and requires the Linux ACL library. Bareos is
   automatically compiled with ACL support if the :strong:`libacl` library is
   installed on your Linux system (shown in config.out).  While restoring the
   files Bareos will try to restore the ACLs, if there is no ACL support
   available on the system, Bareos restores the files and directories but
   not the ACL information.  Please note, if you backup an EXT3 or XFS
   filesystem with ACLs, then you restore them to a different filesystem
   (perhaps reiserfs) that does not have ACLs, the ACLs will be ignored.

   For other operating systems there is support for either POSIX ACLs or
   the more extensible NFSv4 ACLs.

   The ACL stream format between Operation Systems is :strong:`not`
   compatible so for example an ACL saved on Linux cannot be restored on
   Solaris.

   The following Operating Systems are currently supported:

   * AIX (pre-5.3 (POSIX) and post 5.3 (POSIX and NFSv4) ACLs)
   * Darwin
   * FreeBSD (POSIX and NFSv4/ZFS ACLs)
   * HPUX
   * IRIX
   * Linux
   * Solaris (POSIX and NFSv4/ZFS ACLs)
   * Tru64


.. _XattrSupport:

.. config:option:: dir/fileset/include/options/XAttrSupport

   :type: yes|no
   :default: yes

   Since :sinceVersion:`18.2.4: xattr support = yes (new default)`
   the default is :strong:`yes`.
   If this option is set to yes, and your
   operating system support either so called Extended Attributes or
   Extensible Attributes Bareos will backup the file and directory
   XATTR data. This feature is available on UNIX only and depends on
   support of some specific library calls in libc.

   The XATTR stream format between Operating Systems is :strong:`not`
   compatible so an XATTR saved on Linux cannot for example be restored
   on Solaris.

   On some operating systems ACLs are also stored as Extended Attributes
   (Linux, Darwin, FreeBSD) Bareos checks if you have the aclsupport
   option enabled and if so will not save the same info when saving
   extended attribute information. Thus ACLs are only saved once.

   The following Operating Systems are currently supported:

   * AIX (Extended Attributes)
   * Darwin (Extended Attributes)
   * FreeBSD (Extended Attributes)
   * IRIX (Extended Attributes)
   * Linux (Extended Attributes)
   * NetBSD (Extended Attributes)
   * Solaris (Extended Attributes and Extensible Attributes)
   * Tru64 (Extended Attributes)


.. config:option:: dir/fileset/include/options/IgnoreCase

   :type: yes|no

   The default is :strong:`no`.  On Windows systems, you will almost surely
   want to set this to :strong:`yes`.  When this directive is set to :strong:`yes`
   all the case of character will be ignored in wild-card and regex
   comparisons.  That is an uppercase A will match a lowercase a.

.. config:option:: dir/fileset/include/options/FsType

   :type: filesystem-type

   This option allows you to select files and directories by the
   filesystem type.  Example filesystem-type names are:

   btrfs, ext2, ext3, ext4, jfs, ntfs, proc, reiserfs, xfs, nfs, vfat,
   usbdevfs, sysfs, smbfs, iso9660.

   You may have multiple Fstype directives, and thus permit matching
   of multiple filesystem types within a single Options resource.  If
   the type specified on the fstype directive does not match the
   filesystem for a particular directive, that directory will not be
   backed up.  This directive can be used to prevent backing up
   non-local filesystems. Normally, when you use this directive, you
   would also set :config:option:`dir/fileset/include/options/OneFs=no`
   so that Bareos will traverse filesystems.

   This option is not implemented in Win32 systems.


.. config:option:: dir/fileset/include/options/DriveType

   :type: Windows-drive-type

   This option is effective only on Windows machines and is
   somewhat similar to the Unix/Linux
   :config:option:`dir/fileset/include/options/FsType`
   described above,
   except that it allows you to select what Windows
   drive types you want to allow.  By default all drive
   types are accepted.

   The permitted drivetype names are:

   removable, fixed, remote, cdrom, ramdisk

   You may have multiple Driveype directives, and thus permit matching
   of multiple drive types within a single Options resource.  If
   the type specified on the drivetype directive does not match the
   filesystem for a particular directive, that directory will not be
   backed up.  This directive can be used to prevent backing up
   non-local filesystems. Normally, when you use this directive, you
   would also set :config:option:`dir/fileset/include/options/OneFs=no`
   so that Bareos will traverse filesystems.

   This option is not implemented in Unix/Linux systems.


.. config:option:: dir/fileset/include/options/HfsPlusSupport

   :type: yes|no

   This option allows you to turn on support for Mac OSX HFS plus
   finder information.


.. config:option:: dir/fileset/include/options/StripPath

   :type: <integer>

   This option will cause :strong:`integer` paths to be stripped from
   the front of the full path/filename being backed up. This can
   be useful if you are migrating data from another vendor or if
   you have taken a snapshot into some subdirectory.  This directive
   can cause your filenames to be overlayed with regular backup data,
   so should be used only by experts and with great care.


.. config:option:: dir/fileset/include/options/Size

   :type: sizeoption

   This option will allow you to select files by their actual size.
   You can select either files smaller than a certain size or bigger
   then a certain size, files of a size in a certain range or files
   of a size which is within 1 \% of its actual size.

   The following settings can be used:

   <size>-<size>
      Select file in range size - size.

   <size
      Select files smaller than size.

   >size
      Select files bigger than size.

   size
      Select files which are within 1 \% of size.


.. config:option:: dir/fileset/include/options/Shadowing

   :type: none|localwarn|localremove|globalwarn|globalremove
   :default: none

   This option performs a check within the
   fileset for any file-list entries which are shadowing each other.
   Lets say you specify / and /usr but /usr is not a separate filesystem.
   Then in the normal situation both / and /usr would lead to data being
   backed up twice.

   The following settings can be used:

   none
      Do NO shadowing check

   localwarn
      Do shadowing check within one include block and warn

   localremove
      Do shadowing check within one include block and remove duplicates

   globalwarn
      Do shadowing check between all include blocks and warn

   globalremove
      Do shadowing check between all include blocks and remove duplicates

   The local and global part of the setting relate to the fact if the check
   should be performed only within one include block (local) or between multiple
   include blocks of the same fileset (global). The warn and remove part of the
   keyword sets the action e.g. warn the user about shadowing or remove
   the entry shadowing the other.

   Example for a fileset resource with fileset shadow warning enabled:

   .. code-block:: bareosconfig
      :caption: FileSet resource with fileset shadow warning enabled

      FileSet {
        Name = "Test Set"
        Include {
          Options {
            Signature = XXH128
            shadowing = localwarn
          }
          File = /
          File = /usr
        }
      }


.. config:option:: dir/fileset/include/options/Meta

   :type: tag

   This option will add a meta tag to a fileset. These meta tags are used
   by the Native NDMP protocol to pass NDMP backup or restore environment
   variables via the Data Management Agent (DMA) in Bareos to the remote
   NDMP Data Agent. You can have zero or more metatags which are all passed
   to the remote NDMP Data Agent.


.. _FilesetExamples:

FileSet Examples
~~~~~~~~~~~~~~~~

.. index::
   pair: Example; FileSet

The following is an example of a valid FileSet resource definition. Note, the first Include pulls in the contents of the file :file:`/etc/backup.list` when Bareos is started (i.e. the @), and that file must have each filename to be backed up preceded by a File = and on a separate line.

.. code-block:: bareosconfig
   :caption: FileSet using import

   FileSet {
     Name = "Full Set"
     Include {
       Options {
         Compression=GZIP
         signature=SHA1
         Sparse = yes
       }
       @/etc/backup.list
     }
     Include {
        Options {
           wildfile = "*.o"
           wildfile = "*.exe"
           Exclude = yes
        }
        File = /root/myfile
        File = /usr/lib/another_file
     }
   }

In the above example, all the files contained in :file:`/etc/backup.list` will be compressed with LZ4 compression, an XXH128 signature will be computed on the file’s contents (its data), and sparse file handling will apply.

The two directories :file:`/root/myfile` and :file:`/usr/lib/another_file` will also be saved without any options, but all files in those directories with the extensions :file:`.o` and :file:`.exe` will be excluded.

Let’s say that you now want to exclude the directory :file:`/tmp`. The simplest way to do so is to add an exclude directive that lists :file:`/tmp`. The example above would then become:

.. code-block:: bareosconfig
   :caption: extended FileSet excluding /tmp

   FileSet {
     Name = "Full Set"
     Include {
       Options {
         Compression = LZ4
         Signature = XXH128
         Sparse = yes
       }
       @/etc/backup.list
     }
     Include {
        Options {
           wildfile = "*.o"
           wildfile = "*.exe"
           Exclude = yes
        }
        File = /root/myfile
        File = /usr/lib/another_file
     }
     Exclude {
        File = /tmp                          # don't add trailing /
     }
   }

You can add wild-cards to the File directives listed in the Exclude directory, but you need to take care because if you exclude a directory, it and all files and directories below it will also be excluded.

Now lets take a slight variation on the above and suppose you want to save all your whole filesystem except :file:`/tmp`. The problem that comes up is that Bareos will not normally cross from one filesystem to another. Doing a :command:`df` command, you get the following output:

.. code-block:: shell-session
   :caption: df

   user@host:~$ df
   Filesystem      1k-blocks      Used Available Use% Mounted on
   /dev/hda5         5044156    439232   4348692  10% /
   /dev/hda1           62193      4935     54047   9% /boot
   /dev/hda9        20161172   5524660  13612372  29% /home
   /dev/hda2           62217      6843     52161  12% /rescue
   /dev/hda8         5044156     42548   4745376   1% /tmp
   /dev/hda6         5044156   2613132   2174792  55% /usr
   none               127708         0    127708   0% /dev/shm
   //minimatou/c$   14099200   9895424   4203776  71% /mnt/mmatou
   lmatou:/          1554264    215884   1258056  15% /mnt/matou
   lmatou:/home      2478140   1589952    760072  68% /mnt/matou/home
   lmatou:/usr       1981000   1199960    678628  64% /mnt/matou/usr
   lpmatou:/          995116    484112    459596  52% /mnt/pmatou
   lpmatou:/home    19222656   2787880  15458228  16% /mnt/pmatou/home
   lpmatou:/usr      2478140   2038764    311260  87% /mnt/pmatou/usr
   deuter:/          4806936     97684   4465064   3% /mnt/deuter
   deuter:/home      4806904    280100   4282620   7% /mnt/deuter/home
   deuter:/files    44133352  27652876  14238608  67% /mnt/deuter/files

And we see that there are a number of separate filesystems (/ /boot /home /rescue /tmp and /usr not to mention mounted systems). If you specify only / in your Include list, Bareos will only save the Filesystem /dev/hda5. To save all filesystems except /tmp with out including any of the Samba or NFS mounted systems, and explicitly excluding a /tmp, /proc, .journal, and .autofsck, which you will not want to be saved and restored, you can use the following:

.. code-block:: bareosconfig
   :caption: FileSet mount points

   FileSet {
     Name = Include_example
     Include {
       Options {
          wilddir = /proc
          wilddir = /tmp
          wildfile = "/.journal"
          wildfile = "/.autofsck"
          exclude = yes
       }
       File = /
       File = /boot
       File = /home
       File = /rescue
       File = /usr
     }
   }

Since :file:`/tmp` is on its own filesystem and it was not explicitly named in the Include list, it is not really needed in the exclude list. It is better to list it in the Exclude list for clarity, and in case the disks are changed so that it is no longer in its own partition.

Now, lets assume you only want to backup .Z and .gz files and nothing else. This is a bit trickier because Bareos by default will select everything to backup, so we must exclude everything but .Z and .gz files. If we take the first example above and make the obvious modifications to it, we might come up with a FileSet that looks like this:

.. code-block:: bareosconfig
   :caption: Non-working example

   FileSet {
     Name = "Full Set"
     Include {                    !!!!!!!!!!!!
        Options {                    This
           wildfile = "*.Z"          example
           wildfile = "*.gz"         doesn't
                                     work
        }                          !!!!!!!!!!!!
        File = /myfile
     }
   }

The \*.Z and \*.gz files will indeed be backed up, but all other files that are not matched by the Options directives will automatically be backed up too (i.e. that is the default rule).

To accomplish what we want, we must explicitly exclude all other files. We do this with the following:

.. code-block:: bareosconfig
   :caption: Exclude all except specific wildcards

   FileSet {
     Name = "Full Set"
     Include {
        Options {
           wildfile = "*.Z"
           wildfile = "*.gz"
        }
        Options {
           Exclude = yes
           RegexFile = ".*"
        }
        File = /myfile
     }
   }

The "trick" here was to add a RegexFile expression that matches all files. It does not match directory names, so all directories in /myfile will be backed up (the directory entry) and any \*.Z and \*.gz files contained in them. If you know that certain directories do not contain any \*.Z or \*.gz files and you do not want the directory entries backed up, you will need to explicitly exclude those directories. Backing up a directory entries is not very expensive.

Bareos uses the system regex library and some of them are different on different OSes.
This can be tested by using the :bcommand:`estimate job=job-name listing` command in the console and adapting the RegexFile expression appropriately.

Please be aware that allowing Bareos to traverse or change file systems can be very dangerous. For example, with the following:

.. code-block:: bareosconfig
   :caption: backup all filesystem below /mnt/matou (use with care)

   FileSet {
     Name = "Bad example"
     Include {
       Options {
         onefs=no
       }
       File = /mnt/matou
     }
   }

you will be backing up an NFS mounted partition (/mnt/matou), and since onefs is set to no, Bareos will traverse file systems. Now if /mnt/matou has the current machine’s file systems mounted, as is often the case, you will get yourself into a recursive loop and the backup will never end.

As a final example, let’s say that you have only one or two subdirectories of /home that you want to backup. For example, you want to backup only subdirectories beginning with the letter a and the letter b – i.e. :file:`/home/a*` and :file:`/home/b*`. Now, you might first try:

.. code-block:: bareosconfig
   :caption: Non-working example

   FileSet {
     Name = "Full Set"
     Include {
        Options {
           wilddir = "/home/a*"
           wilddir = "/home/b*"
        }
        File = /home
     }
   }

The problem is that the above will include everything in /home. To get things to work correctly, you need to start with the idea of exclusion instead of inclusion. So, you could simply exclude all directories except the two you want to use:

.. code-block:: bareosconfig
   :caption: Exclude by regex

   FileSet {
     Name = "Full Set"
     Include {
        Options {
           RegexDir = "^/home/[c-z]"
           exclude = yes
        }
        File = /home
     }
   }

And assuming that all subdirectories start with a lowercase letter, this would work.

An alternative would be to include the two subdirectories desired and exclude everything else:

.. code-block:: bareosconfig
   :caption: Include and Exclude

   FileSet {
     Name = "Full Set"
     Include {
        Options {
           wilddir = "/home/a*"
           wilddir = "/home/b*"
        }
        Options {
           RegexDir = ".*"
           exclude = yes
        }
        File = /home
     }
   }

The following example shows how to back up only the My Pictures directory inside the My Documents directory for all users in C:/Documents and Settings, i.e. everything matching the pattern:

:file:`C:/Documents and Settings/*/My Documents/My Pictures/*`

To understand how this can be achieved, there are two important points to remember:

Firstly, Bareos walks over the filesystem depth-first starting from the File = lines. It stops descending when a directory is excluded, so you must include all ancestor directories of each directory containing files to be included.

Secondly, each directory and file is compared to the Options clauses in the order they appear in the FileSet. When a match is found, no further clauses are compared and the directory or file is either included or excluded.

The FileSet resource definition below implements this by including specific directories and files and excluding everything else.

.. code-block:: bareosconfig
   :caption: Include/Exclude example

   FileSet {
     Name = "AllPictures"

     Include {

       File  = "C:/Documents and Settings"

       Options {
         signature = SHA1
         verify = s1
         IgnoreCase = yes

         # Include all users' directories so we reach the inner ones.  Unlike a
         # WildDir pattern ending in *, this RegExDir only matches the top-level
         # directories and not any inner ones.
         RegExDir = "^C:/Documents and Settings/[^/]+$"

         # Ditto all users' My Documents directories.
         WildDir = "C:/Documents and Settings/*/My Documents"

         # Ditto all users' My Documents/My Pictures directories.
         WildDir = "C:/Documents and Settings/*/My Documents/My Pictures"

         # Include the contents of the My Documents/My Pictures directories and
         # any subdirectories.
         Wild = "C:/Documents and Settings/*/My Documents/My Pictures/*"
       }

       Options {
         Exclude = yes
         IgnoreCase = yes

         # Exclude everything else, in particular any files at the top level and
         # any other directories or files in the users' directories.
         Wild = "C:/Documents and Settings/*"
       }
     }
   }


Windows FileSets
~~~~~~~~~~~~~~~~

:index:`\ <single: Windows; FileSet>`\  :index:`\ <single: FileSet; Windows>`\

If you are entering Windows file names, the directory path may be preceded by the drive and a colon (as in c:). However, the path separators must be specified in Unix convention (i.e. forward slash (/)). If you wish to include a quote in a file name, precede the quote with a backslash (\). For example you might use the following for a Windows machine to backup the "My Documents"
directory:

.. code-block:: bareosconfig
   :caption: Windows FileSet

   FileSet {
     Name = "Windows Set"
     Include {
       Options {
          WildFile = "*.obj"
          WildFile = "*.exe"
          exclude = yes
        }
        File = "c:/My Documents"
     }
   }

For exclude lists to work correctly on Windows, you must observe the following rules:

-  Filenames are case sensitive, so you must use the correct case.

-  To exclude a directory, you must not have a trailing slash on the directory name.

-  If you have spaces in your filename, you must enclose the entire name in double-quote characters ("). Trying to use a backslash before the space will not work.

-  If you are using the old Exclude syntax (noted below), you may not specify a drive letter in the exclude. The new syntax noted above should work fine including driver letters.

Thanks to Thiago Lima for summarizing the above items for us. If you are having difficulties getting includes or excludes to work, you might want to try using the :bcommand:`estimate job=job-name listing` command documented in the :ref:`section-ConsoleCommands` section of this manual.

On Win32 systems, if you move a directory or file or rename a file into the set of files being backed up, and a Full backup has already been made, Bareos will not know there are new files to be saved during an Incremental or Differential backup (blame Microsoft, not us). To avoid this problem, please copy any new directory or files into the backup area. If you do not have enough disk to copy the directory or files, move them, but then initiate a Full backup.

Example Fileset for Windows
^^^^^^^^^^^^^^^^^^^^^^^^^^^

:index:`\ <single: FileSet; Windows Example>`\  :index:`\ <single: Windows; FileSet; Example>`\

The following example demonstrates a Windows FileSet. It backups all data from all fixed drives and only excludes some Windows temporary data.

.. code-block:: bareosconfig
   :caption: Windows All Drives FileSet

   FileSet {
     Name = "Windows All Drives"
     Enable VSS = yes
     Include {
       Options {
         Signature = XXH128
         Drive Type = fixed
         IgnoreCase = yes
         WildFile = "[A-Z]:/pagefile.sys"
         WildDir = "[A-Z]:/RECYCLER"
         WildDir = "[A-Z]:/$RECYCLE.BIN"
         WildDir = "[A-Z]:/System Volume Information"
         Exclude = yes
       }
       File = /
     }
   }

``File = /``\  includes all Windows drives. Using ``Drive Type = fixed``\  excludes drives like USB-Stick or CD-ROM Drive. Using ``WildDir = "[A-Z]:/RECYCLER"``\  excludes the backup of the directory :file:`RECYCLER` from all drives.

Testing Your FileSet
~~~~~~~~~~~~~~~~~~~~

:index:`\ <single: FileSet; Testing Your>`
:index:`\ <single: Testing Your FileSet>`

If you wish to get an idea of what your FileSet will really backup or if your exclusion rules will work correctly, you can test it by using the :ref:`estimate <estimate>` command.

As an example, suppose you add the following test FileSet:

.. code-block:: bareosconfig
   :caption: FileSet for all \*.c files

   FileSet {
     Name = Test
     Include {
       File = /home/xxx/test
       Options {
          regex = ".*\.c$"
       }
     }
   }

You could then add some test files to the directory /home/xxx/test and use the following command in the console:

.. code-block:: bconsole
   :caption: estimate

   estimate job=<any-job-name> listing client=<desired-client> fileset=Test

to give you a listing of all files that match. In the above example, it should be only files with names ending in .c.

.. _DirectorResourceClient:

Client Resource
---------------

:index:`\ <single: Resource; Client>`\  :index:`\ <single: Client Resource>`\

The Client (or FileDaemon) resource defines the attributes of the Clients that are served by this Director; that is the machines that are to be backed up. You will need one Client resource definition for each machine to be backed up.

.. include:: /include/autogenerated/bareos-dir-resource-client-table.rst.inc

.. include:: /include/autogenerated/bareos-dir-resource-client-description.rst.inc

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

.. code-block:: bareosconfig
   :caption: Minimal client resource definition in bareos-dir.conf

   Client {
     Name = client1-fd
     Address = client1.example.com
     Password = "secret"
   }

The following is an example of a Quota Configuration in Client resource:

.. code-block:: bareosconfig
   :caption: Quota Configuration in Client resource

   Client {
     Name = client1-fd
     Address = client1.example.com
     Password = "secret"

     # Quota
     Soft Quota = 50 mb
     Soft Quota Grace Period = 2 days
     Strict Quotas = Yes
     Hard Quota = 150 mb
     Quota Include Failed Jobs = yes
   }

.. _DirectorResourceStorage:

Storage Resource
----------------

:index:`\ <single: Resource; Storage>`\  :index:`\ <single: Storage Resource>`\

The Storage resource defines which Storage daemons are available for use by the Director.

.. include:: /include/autogenerated/bareos-dir-resource-storage-table.rst.inc

.. include:: /include/autogenerated/bareos-dir-resource-storage-description.rst.inc

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

.. code-block:: bareosconfig
   :caption: Storage resource (tape) example

   Storage {
     Name = DLTDrive
     Address = lpmatou
     Password = storage\_password # password for Storage daemon
     Device = "HP DLT 80"    # same as Device in Storage daemon
     Media Type = DLT8000    # same as MediaType in Storage daemon
   }

.. _DirectorResourcePool:

Pool Resource
-------------

:index:`\ <single: Resource; Pool>`\  :index:`\ <single: Pool Resource>`\

The Pool resource defines the set of storage Volumes (tapes or files) to be used by Bareos to write the data. By configuring different Pools, you can determine which set of Volumes (media) receives the backup data. This permits, for example, to store all full backup data on one set of Volumes and all incremental backups on another set of Volumes. Alternatively, you could assign a different set of Volumes to each machine that you backup. This is most easily done by defining multiple Pools.

Another important aspect of a Pool is that it contains the default attributes (Maximum Jobs, Retention Period, Recycle flag, ...) that will be given to a Volume when it is created. This avoids the need for you to answer a large number of questions when labeling a new Volume. Each of these attributes can later be changed on a Volume by Volume basis using the :bcommand:`update` command in the console program. Note that you must explicitly specify which Pool Bareos is to use with each
Job. Bareos will not automatically search for the correct Pool.

To use a Pool, there are three distinct steps. First the Pool must be defined in the Director’s configuration. Then the Pool must be written to the Catalog database. This is done automatically by the Director each time that it starts. Finally, if you change the Pool definition in the Director’s configuration file and restart Bareos, the pool will be updated alternatively you can use the :bcommand:`update pool` console command to refresh the database image. It is this database image
rather than the Director’s resource image that is used for the default Volume attributes. Note, for the pool to be automatically created or updated, it must be explicitly referenced by a Job resource.

If automatic labeling is not enabled (see :ref:`AutomaticLabeling`) the physical media must be manually labeled. The labeling can either be done with the :bcommand:`label` command in the console program or using the :command:`btape` program. The preferred method is to use the :bcommand:`label` command in the console program. Generally, automatic labeling is enabled for :config:option:`sd/device/DeviceType = File`\
and disabled for :config:option:`sd/device/DeviceType = Tape`\ .

Finally, you must add Volume names (and their attributes) to the Pool. For Volumes to be used by Bareos they must be of the same :config:option:`sd/device/MediaType`\  as the archive device specified for the job (i.e. if you are going to back up to a DLT device, the Pool must have DLT volumes defined since 8mm volumes cannot be mounted on a DLT drive). The :config:option:`sd/device/MediaType`\  has particular importance if you are backing up to files.
When running a Job, you must explicitly specify which Pool to use. Bareos will then automatically select the next Volume to use from the Pool, but it will ensure that the :config:option:`sd/device/MediaType`\  of any Volume selected from the Pool is identical to that required by the Storage resource you have specified for the Job.

If you use the :bcommand:`label` command in the console program to label the Volumes, they will automatically be added to the Pool, so this last step is not normally required.

It is also possible to add Volumes to the database without explicitly labeling the physical volume. This is done with the :bcommand:`add` console command.

As previously mentioned, each time Bareos starts, it scans all the Pools associated with each Catalog, and if the database record does not already exist, it will be created from the Pool Resource definition. If you change the Pool definition, you manually have to call :bcommand:`update pool` command in the console program to propagate the changes to existing volumes.

The Pool Resource defined in the Director’s configuration may contain the following directives:

.. include:: /include/autogenerated/bareos-dir-resource-pool-table.rst.inc

.. include:: /include/autogenerated/bareos-dir-resource-pool-description.rst.inc

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

.. code-block:: bareosconfig
   :caption: Pool resource example

   Pool {
     Name = Default
     Pool Type = Backup
   }

.. _TheScratchPool:

Scratch Pool
~~~~~~~~~~~~

:index:`\ <single: Scratch Pool>`\  :index:`\ <single: Pool; Scratch>`\

In general, you can give your Pools any name you wish, but there is one important restriction: the Pool named Scratch, if it exists behaves like a scratch pool of Volumes in that when Bareos needs a new Volume for writing and it cannot find one, it will look in the Scratch pool, and if it finds an available Volume, it will move it out of the Scratch pool into the Pool currently being used by the job.

.. _DirectorResourceCatalog:

Catalog Resource
----------------

:index:`\ <single: Resource; Catalog>`\  :index:`\ <single: Catalog Resource>`\

The Catalog Resource defines what catalog to use for the current job.

.. include:: /include/autogenerated/bareos-dir-resource-catalog-table.rst.inc

.. include:: /include/autogenerated/bareos-dir-resource-catalog-description.rst.inc

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

.. code-block:: bareosconfig
   :caption: Catalog Resource for MyCatalog

   Catalog
   {
     Name = MyCatalog
     DB Name = bareos;
     DB User = bareos;
     DB Password = ""
   }

or for a Catalog on another machine:

.. code-block:: bareosconfig
   :caption: Catalog Resource for remote PostgreSQL

   Catalog
   {
     Name = RemoteCatalog
     DB Name = bareos
     DB User = bareos
     DB Password = "secret"
     DB Address = remote.example.com
     DB Port = 1234
   }

.. _DirectorResourceMessages:

Messages Resource
-----------------

:index:`\ <single: Resource; Messages>`\  :index:`\ <single: Messages Resource>`\

For the details of the Messages Resource, please see the :ref:`MessagesChapter` of this manual.

.. _DirectorResourceConsole:

Console Resource
----------------

:index:`\ <single: Console Resource>`\  :index:`\ <single: Resource; Console>`\

There are three different kinds of consoles, which the administrator or user can use to interact with the Director. These three kinds of consoles comprise three different security levels.

Default Console
   :index:`\ <single: Console; Default Console>`\  the first console type is an "anonymous" or "default" console, which has full privileges. There is no console resource necessary for this type since the password is specified in the Director’s resource and consequently such consoles do not have a name as defined on a :strong:`Name`\  directive. Typically you would use it only for administrators.

Named Console
   :index:`\ <single: Named Console>`\  :index:`\ <single: Console; Named Console>`\  :index:`\ <single: Console; Restricted Console>`\  the second type of console, is a "named" console (also called "Restricted Console") defined within a Console resource in both the Director’s configuration file and in the Console’s configuration file. Both the names and the passwords in these two entries must match much as is the case for Client programs.

   This second type of console begins with absolutely no privileges except those explicitly specified in the Director’s Console resource. Thus you can have multiple Consoles with different names and passwords, sort of like multiple users, each with different privileges. As a default, these consoles can do absolutely nothing – no commands whatsoever. You give them privileges or rather access to commands and resources by specifying access control lists in the Director’s Console resource. The ACLs
   are specified by a directive followed by a list of access names. Examples of this are shown below.

   -  The third type of console is similar to the above mentioned one in that it requires a Console resource definition in both the Director and the Console. In addition, if the console name, provided on the :config:option:`dir/console/Name`\  directive, is the same as a Client name, that console is permitted to use the :bcommand:`SetIP` command to change the Address directive in the Director’s client resource to the IP address of the Console. This permits
      portables or other machines using DHCP (non-fixed IP addresses) to "notify" the Director of their current IP address.

The Console resource is optional and need not be specified. The following directives are permitted within these resources:

.. include:: /include/autogenerated/bareos-dir-resource-console-table.rst.inc

.. include:: /include/autogenerated/bareos-dir-resource-console-description.rst.inc

The example at :ref:`section-ConsoleAccessExample` shows how to use a console resource for a connection from a client like :command:`bconsole`.

.. _DirectorResourceUser:

User Resource
-------------

:index:`\ <single: User Resource>`
:index:`\ <single: User>`

Each user who wants to login using PAM needs a dedicated User Resource in the |dir| configuration. The main purpose is to configure ACLs as shown in the table below, they are the same as in the :ref:`DirectorResourceConsole` and the :ref:`DirectorResourceProfile`.

If a user is authenticated with PAM but is not authorized by a user resource, the login will be denied by the |dir|.

Refer to chapter :ref:`PAMConfigurationChapter` for details how to configure PAM.

The following table contains all configurable directives in the User Resource:

.. include:: /include/autogenerated/bareos-dir-resource-user-table.rst.inc

.. include:: /include/autogenerated/bareos-dir-resource-user-description.rst.inc


.. _DirectorResourceProfile:

Profile Resource
----------------

:index:`\ <single: Profile Resource>`\  :index:`\ <single: Resource; Profile>`\

The Profile Resource defines a set of ACLs. :ref:`DirectorResourceConsole` can be tight to one or more profiles (:config:option:`dir/console/Profile`\ ), making it easier to use a common set of ACLs.

.. include:: /include/autogenerated/bareos-dir-resource-profile-table.rst.inc

.. include:: /include/autogenerated/bareos-dir-resource-profile-description.rst.inc

.. _DirectorResourceCounter:

Counter Resource
----------------

:index:`\ <single: Resource; Counter>`
:index:`\ <single: Counter Resource>`

The Counter Resource defines a counter variable that can be accessed by variable expansion used for creating Volume labels with the :config:option:`dir/pool/LabelFormat`\  directive.

.. include:: /include/autogenerated/bareos-dir-resource-counter-table.rst.inc

.. include:: /include/autogenerated/bareos-dir-resource-counter-description.rst.inc
