barman - Backup and Recovery Manager for PostgreSQL
barman [OPTIONS] COMMAND
Barman is an administration tool for disaster recovery of PostgreSQL servers written in Python and maintained by EnterpriseDB. Barman can perform remote backups of multiple servers in business critical environments and helps DBAs during the recovery phase.
Important: every command has a help option
archive_command
and streaming replication, where applicable) and moves them in the WAL archive for that server. If necessary, apply compression when requested by the user.
Perform a backup of SERVER_NAME
using parameters specified in the configuration file. Specify all
as SERVER_NAME
to perform a backup of all the configured servers. You can also specify SERVER_NAME
multiple times to perform a backup of the specified servers -- e.g. barman backup SERVER_1_NAME SERVER_2_NAME
.
immediate_checkpoint
, if present in the configuration file.
immediate_checkpoint
, if present in the configuration file.
BACKUP_ID
or backup ID shortcut of a previous backup must be provided, which references a previous backup in the catalog to be used as the parent backup from which the incremental is taken.
Overrides reuse_backup
option behaviour. Possible values for INCREMENTAL_TYPE
are:
link
is the default target if --reuse-backup
is used and INCREMENTAL_TYPE
is not explicit.
basebackup_retry_times
, if present in the configuration file.
--retry-times 0
basebackup_retry_sleep
, if present in the configuration file.
parallel_jobs
, if present in the configuration file.
parallel_jobs_start_batch_period
, if present in the configuration file. Defaults to 1 second.
parallel_jobs_start_batch_size
, if present in the configuration file. Defaults to 10 jobs.
autogenerate_manifest
, from the configuration file. Works with rsync backup method and strategies only
autogenerate_manifest
, from the configuration file. Works with rsync backup method and strategies only
cron
command and at the end of every backup operation.
Check that the WAL archive destination for SERVER_NAME is safe to use for a new PostgreSQL cluster. With no optional args (the default) this will pass if the WAL archive is empty and fail otherwise.
Show diagnostic information about SERVER_NAME
, including: Ssh connection check, PostgreSQL version, configuration and backup directories, archiving process, streaming process, replication slots, etc. Specify all
as SERVER_NAME
to show diagnostic information about all the configured servers.
MODEL_NAME
to the Barman server SERVER_NAME
. The final configuration is composed of the server configuration plus the overrides defined in the given model. Note: there can only be at most one model active at a time for a given server. config-update JSON_CHANGES
JSON_CHANGES
should be a JSON string containing an array of documents. Each document must contain the scope
key, which can be either server
or model
, and either the server_name
or model_name
key, depending on the value of scope
. Besides that, other keys are expected to be Barman configuration options along with their desired values.
Perform maintenance tasks, such as enforcing retention policies or WAL files management.
rsync
version, as well as current configuration and status of all servers.
Retrieve a WAL file from the xlog
archive of a given server. By default, the requested WAL file, if found, is returned as uncompressed content to STDOUT
. The following options allow users to change this behaviour:
get-wal
will deposit the requested WAL
Flag the specified backup as an archival backup which should be kept forever, regardless of any retention policies in effect. See the Backup ID shortcuts section below for available shortcuts.
Specify the recovery target for the archival backup. Possible values for RECOVERY_TARGET are:
SERVER_NAME
. This command is useful to retrieve a backup ID and the backup type. For example:
servername 20111104T102647 - F - Fri Nov 4 10:26:48 2011 - Size: 17.0 MiB - WAL Size: 100 B
In this case, 20111104T102647 is the backup ID, and F
is the backup type label for a full backup taken with pg_basebackup
. The backup type label displayed by this command uses one of the following values: - F
: for full backups taken with pg_basebackup
- I
: for incremental backups taken with pg_basebackup
- R
: for backups taken with rsync
- S
: for cloud snapshot backups list-files [OPTIONS] SERVER_NAME BACKUP_ID : List all the files in a particular backup, identified by the server name and the backup ID. See the Backup ID shortcuts section below for available shortcuts.
--target *TARGET_TYPE*
: Possible values for TARGET_TYPE are:
- *data*: lists just the data files;
- *standalone*: lists the base backup files, including required
WAL files;
- *wal*: lists all the WAL files between the start of the base
backup and the end of the log / the start of the following base
backup (depending on whether the specified base backup is the most
recent one available);
- *full*: same as data + wal.
The default value is `standalone`.
Receive a WAL file from a remote server and securely store it into the SERVER_NAME
incoming directory. The WAL file is retrieved from the STDIN
, and must be encapsulated in a tar stream together with a MD5SUMS
file to validate it. This command is meant to be invoked through SSH from a remote barman-wal-archive
utility (part of barman-cli
package). Do not use this command directly unless you take full responsibility of the content of files.
SERVER_NAME
(or every server, using the all
shortcut) guessing it from the disk content. The metadata of the WAL archive is contained in the xlog.db
file, and every Barman server has its own copy.
Start the stream of transaction logs for a server. The process relies on pg_receivewal
/pg_receivexlog
to receive WAL files from the PostgreSQL servers through the streaming protocol.
slot_name
configuration parameter
slot_name
configuration parameter
Recover a backup in a given directory (local or remote, depending on the --remote-ssh-command
option settings). See the Backup ID shortcuts section below for available shortcuts.
current
and latest
can be used in addition to a numeric timeline ID. The default behaviour for PostgreSQL versions >= 12 is to recover to the latest
timeline in the WAL archive. The default for PostgreSQL versions < 12 is to recover along the timeline which was current when the backup was taken.
Recover to the specified time.
You can use any valid unambiguous representation (e.g: "YYYY-MM-DD HH:MM:SS.mmm").
pg_create_restore_point(name)
.
pause
, shutdown
and promote
. This option requires a target to be defined, with one of the above options.
basebackup_retry_times
, if present in the configuration file.
--retry-times 0
basebackup_retry_sleep
, if present in the configuration file.
parallel_jobs
, if present in the configuration file. Works only for servers configured through rsync
/SSH.
parallel_jobs_start_batch_period
, if present in the configuration file. Defaults to 1 second.
parallel_jobs_start_batch_size
, if present in the configuration file. Defaults to 10 jobs.
get-wal
for WAL fetching during recovery. Default is based on recovery_options
setting.
network_compression
configuration setting.
backup_method = snapshot
.
gcp_zone
in the Barman config.
azure_resource_group
in the Barman config.
aws_region
in the Barman config.
Shows live information and status of any streaming client attached to the given server (or servers). Default behaviour can be changed through the following options:
Possible values for TARGET_TYPE are:
Possible values for SOURCE_TYPE are:
Backup 20240814T017504:
Server Name : quagmire
Status : DONE
PostgreSQL Version : 90402
PGDATA directory : /srv/postgresql/9.4/main/data
Estimated Cluster Size : 22.4 MiB
Server information:
Checksums : on
WAL summarizer : on
Base backup information:
Backup Method : postgres
Backup Type : incremental
Backup Size : 22.3 MiB (54.3 MiB with WALs)
WAL Size : 32.0 MiB
Resources saved : 19.5 MiB (86.80%)
Timeline : 1
Begin WAL : 0000000100000CFD000000AD
End WAL : 0000000100000D0D00000008
WAL number : 3932
WAL compression ratio: 79.51%
Begin time : 2015-08-28 13:00:01.633925+00:00
End time : 2015-08-29 10:27:06.522846+00:00
Copy time : 1 second
Estimated throughput : 2.0 MiB/s
Begin Offset : 1575048
End Offset : 13853016
Begin XLOG : CFD/AD180888
End XLOG : D0D/8D36158
WAL information:
No of files : 35039
Disk usage : 121.5 GiB
WAL rate : 275.50/hour
Compression ratio : 77.81%
Last available : 0000000100000D95000000E7
Catalog information:
Retention Policy : not enforced
Previous Backup : 20150821T130001
Next Backup : - (this is the latest base backup)
Root Backup : 20240814T015504
Parent Backup : 20240814T016504
Backup chain size : 3
Children Backup(s) : 20240814T018515
NOTE: Depending on the version of your Postgres Server and/or the type of the backup, the output of
barman show-backup
command may be different. For example, fields like "Root Backup", "Parent Backup", "Backup chain size", and "Children Backup(s)" only make sense when showing information about a block-level incremental backup taken withbackup_method = postgres
and using Postgres 17 or newer, thus those fields are omitted for other kind of backups or older versions of Postgres.Also note that
show-backup
relies on the backup metadata so if a backup was created with Barman version 3.10 or earlier, the backup will not contain the fields added in version 3.11 (which are those added after the introduction of "incremental" backups in PostgreSQL 17).These are the possible values for the field "Backup Type":
rsync
: for a backup taken withrsync
;full
: for a full backup taken withpg_basebackup
;incremental
: for an incremental backup taken withpg_basebackup
;snapshot
: for a snapshot-based backup taken in the cloud.Below you can find a list of fields that may be shown or omitted depending on the type of the backup:
Resources saved
: available for "rsync" and "incremental" backups;Root Backup
,Parent Backup
,Backup chain size
: available for "incremental" backups only;Children Backup(s)
: available for "full" and "incremental" backups;Snapshot information
: available for "snapshot" backups only.
SERVER_NAME
, including: conninfo
, backup_directory
, wals_directory
and many more. Specify all
as SERVER_NAME
to show information about all the configured servers.
archive_command
, archive_status
and many more. For example:
Server quagmire:
Description: The Giggity database
Passive node: False
PostgreSQL version: 9.3.9
PostgreSQL Data directory: /srv/postgresql/9.3/data
PostgreSQL 'archive_command' setting: rsync -a %p barman@backup:/var/lib/barman/quagmire/incoming
Last archived WAL: 0000000100003103000000AD
Current WAL segment: 0000000100003103000000AE
Retention policies: enforced (mode: auto, retention: REDUNDANCY 2, WAL retention: MAIN)
No. of available backups: 2
First available backup: 20150908T003001
Last available backup: 20150909T003001
Minimum redundancy requirements: satisfied (2/1)
Execute pg_switch_wal() on the target server (from PostgreSQL 10), or pg_switch_xlog (for PostgreSQL 8.3 to 9.6).
BACKUP_ID
that is present on SERVER_NAME
node. This command is available only for passive nodes, and uses the primary_ssh_command
option to establish a secure connection with the primary node.
Collect information regarding the current status of a Barman server, to be used for synchronisation purposes. Returns a JSON output representing SERVER_NAME
, that contains: all the successfully finished backup, all the archived WAL files, the configuration, last WAL file been read from the xlog.db
and the position in the file.
xlog.db
file (incremental synchronisation)
SERVER_NAME
node. This command is available only for passive nodes, and uses the primary_ssh_command
option to establish a secure connection with the primary node.
pg_verifybackup
against a backup manifest file (available since Postgres 13). For rsync backups, it can be used with generate-manifest command. Requires pg_verifybackup
installed on the backup server
Rather than using the timestamp backup ID, you can use any of the following shortcuts/aliases to identity a backup for a given server:
--incremental
option.
barman
(5).
Barman has been extensively tested, and is currently being used in several production environments. However, we cannot exclude the presence of bugs.
Any bug can be reported via the GitHub bug tracker. Along with the bug submission, users can provide developers with diagnostics information obtained through the barman diagnose
command.
Barman maintainers (in alphabetical order):
Past contributors (in alphabetical order):
Barman is the property of EnterpriseDB UK Limited and its code is distributed under GNU General Public License v3.
© Copyright EnterpriseDB UK Limited 2011-2023