構成
====

Barmanには3種類の構成ファイルがあります。

-  **グローバル/一般構成**

-  **サーバー構成**

-  **モデル構成**

メイン構成ファイルデフォルトで\ ``/etc/barman.conf``
に設定されには、メインディレクトリ、システムユーザー、ログファイルなどの一般的なオプションが含まれています。

サーバー構成ファイルは、
Barmanによってバックアップされるサーバーごとに1つですが、
``/etc/barman.d`` ディレクトリにあり、 ``.conf``
サフィックスが必要です。

同様に、モデル構成ファイルは\ ``/etc/barman.d``
ディレクトリにあり、\ ``.conf`` サフィックスが必要です。

   *注意* モデルは、
   :ref:`barman config-switch <#config-switch>` コマンドを介して、モデルと同じクラスターの一部であるBarmanサーバーの構成に適用できる構成オーバーライドを定義します。

..  IMPORTANT::
   歴史的な理由から、グローバルオプションとサーバーオプションとモデルオプションの両方を含む単一の構成ファイルを使用できます。ただし、メンテナンス上の理由から、このアプローチは非推奨です。

Barmanの構成ファイルは_INI_形式に従います。

構成ファイルは、異なるタイプのパラメーターを受け入れます。

-  文字列

-  enum

-  整数

-  ブール値、\ ``on/true/1`` も\ ``off/false/0``
   と同様に受け入れられます。

どれも引用する必要はありません。

   *注意* 一部の\ ``enum`` では、\ ``off`` は許可されますが、\ ``false``
   は許可されません。

オプションスコープ
------------------

すべての構成オプションには_scope_があります。

-  グローバル

-  サーバー

-  モデル

-  global/server 通常グローバルレベルで設定できるサーバーオプション

グローバルオプションは、INIファイルで\ ``[barman]``
labelによって指定される_generalセクション_で使用できます。

.. code:: ini

   [barman]
   ; ... global and global/server options go here

サーバーオプションは、構成ファイルの行、角かっこ ``[`` および\ ``]``
で指定される_serverセクション_でのみ指定できます。 serverセクションは、
BarmanのそのサーバーのIDを表します。次の例は、 ``my-cluster``
クラスターに属する\ ``pg``
という名前のサーバーのセクションを指定します。

.. code:: ini

   [pg]
   cluster=my-cluster
   ; Configuration options for the
   ; server named pg go here

モデルオプションは、\_modelセクション_でのみ指定できます。これは、\_serverセクション_と同じ方法で識別されます。
\_serverセクション_と_モデルセクション_の識別子の間に競合があってはなりません。次の例では、
``my-cluster`` クラスターに属する\ ``pg:switchover``
という名前のモデルのセクションを指定します。

.. code:: ini

   [pg:switchover]
   cluster=my-cluster
   model=true
   ; Configuration options for the model named pg:switchover, which belongs to
   ; the server which is configured with the option cluster=pg, go here

Barmanにはサーバー名としてもモデル名としても使用できない予約語が2つあります。

-  ``barman`` グローバルセクションの識別子

-  ``all``
   Barmanが管理するすべてのサーバーでいくつかのコマンドを順番に実行できる便利なショートカット

Barmanは、 **構成よりコンベンション**
デザインパラダイムを実装しています。これは、柔軟性を失うことなく構成が必要なオプションの数を削減しようとします。したがって、一部のサーバーオプションはグローバルレベルで定義し、サーバーレベルでオーバーライドできるため、ユーザーは汎用的な動作を指定し、1つ以上のサーバーに合わせて調整できます。これらのオプションには、グローバル/サーバースコープがあります。

使用可能なすべての構成とそのスコープのリストについては、[section 5 of
the ‘man’ page][man5]を参照してください。

.. code:: bash

   man 5 barman

構成の例
--------

以下は、メイン構成ファイルの基本的な例です。

.. code:: ini

   [barman]
   barman_user = barman
   configuration_files_directory = /etc/barman.d
   barman_home = /var/lib/barman
   log_file = /var/log/barman/barman.log
   log_level = INFO
   compression = gzip

一方、次の例は、ストリーミングバックアップを使用するサーバー構成ファイルです。

.. code:: ini

   [streaming-pg]
   description =  "Example of PostgreSQL Database (Streaming-Only)"
   conninfo = host=pg user=barman dbname=postgres
   streaming_conninfo = host=pg user=streaming_barman
   backup_method = postgres
   streaming_archiver = on
   slot_name = barman

次の例は、クラスターが\ ``streaming-pg``
であるサーバーに適用できるオーバーライドのセットを含む構成モデルを定義します。

.. code:: ini

   [streaming-pg:switchover]
   cluster=streaming-pg
   model=true
   conninfo = host=pg-2 user=barman dbname=postgres
   streaming_conninfo = host=pg-2 user=streaming_barman

次のコードは、\ ``rsync``
/SSHを使用した従来のバックアップの基本的な例を示しています。

.. code:: ini

   [ssh-pg]
   description =  "Example of PostgreSQL Database (via Ssh)"
   ssh_command = ssh postgres@pg
   conninfo = host=pg user=barman dbname=postgres
   backup_method = rsync
   parallel_jobs = 1
   reuse_backup = link
   archiver = on

詳細については、配布された\ ``barman.conf``
ファイル、および\ ``ssh-server.conf-template``
および\ ``streaming-server.conf-template``
テンプレートファイルを参照してください。
