General commands
================

Barman has many commands and, for the sake of exposition, we can
organize them by scope.

The scope of the **general commands** is the entire Barman server, that
can backup many PostgreSQL servers. **Server commands**, instead, act
only on a specified server. **Backup commands** work on a backup, which
is taken from a certain server.

The following list includes the general commands.

cron
----

``barman`` doesn’t include a long-running daemon or service file
(there’s nothing to ``systemctl start`` , ``service start`` , etc.).
Instead, the ``barman cron`` subcommand is provided to perform
``barman`` ’s background “steady-state” backup operations.

You can perform maintenance operations, on both WAL files and backups,
using the ``cron`` command:

.. code:: bash

   barman cron

..  NOTE::
   This command should be executed in a _cron `script_`. Our recommendation is to schedule `barman cron`  to run every minute.  If you installed Barman using the rpm or debian package, a cron entry running on every minute will be created for you.

``barman cron`` executes WAL archiving operations concurrently on a
server basis, and this also enforces retention policies on those servers
that have:

-  ``retention_policy`` not empty and valid;

-  ``retention_policy_mode`` set to ``auto`` .

The ``cron`` command ensures that WAL streaming is started for those
servers that have requested it, by transparently executing the
``receive-wal`` command.

In order to stop the operations started by the ``cron`` command, comment
out the cron entry and execute:

.. code:: bash

   barman receive-wal --stop SERVER_NAME

You might want to check ``barman list-servers`` to make sure you get all
of your servers.

..  NOTE::
   `barman cron`  runs background maintenance tasks only and is not responsible for running scheduled backups. Any regularly scheduled backup jobs you require must be scheduled separately, for example in another cron entry which runs `barman backup all` .

diagnose
--------

The ``diagnose`` command creates a JSON report useful for diagnostic and
support purposes. This report contains information for all configured
servers.

..  NOTE::
   From Barman `3.10.0`  onwards you can optionally specify the `--show-config-source`  argument to the command. In that case, for each configuration option of Barman and of the Barman servers, the output will include not only the configuration value, but also the configuration file which provides the effective value.

..  IMPORTANT::
   Even if the diagnose is written in JSON and that format is thought to be machine readable, its structure is not to be considered part of the interface. Format can change between different Barman versions.

list-servers
------------

You can display the list of active servers that have been configured for
your backup system with:

.. code:: bash

   barman list-servers

A machine readable output can be obtained with the ``--minimal`` option:

.. code:: bash

   barman list-servers --minimal
