barman.wal_archiver module#

class barman.wal_archiver.FileWalArchiver(backup_manager)View on GitHub#

Bases: WalArchiver

Manager of file-based WAL archiving operations (aka ‘log shipping’).

__init__(backup_manager)View on GitHub#

Base class init method.

Parameters:
  • backup_manager – The backup manager

  • name – The name of this archiver

Returns:

_abc_impl = <_abc._abc_data object>#
check(check_strategy)View on GitHub#

Perform additional checks for FileWalArchiver - invoked by server.check_postgres

Parameters:

check_strategy (CheckStrategy) – the strategy for the management of the results of the various checks

fetch_remote_status()View on GitHub#

Returns the status of the FileWalArchiver.

This method does not raise any exception in case of errors, but set the missing values to None in the resulting dictionary.

Return type:

dict[str, None|str]

get_next_batch()View on GitHub#

Returns the next batch of WAL files that have been archived through a PostgreSQL’s ‘archive_command’ (in the ‘incoming’ directory)

Returns:

WalArchiverQueue: list of WAL files

status()View on GitHub#

Set additional status info - invoked by Server.status()

class barman.wal_archiver.StreamingWalArchiver(backup_manager)View on GitHub#

Bases: WalArchiver

Object used for the management of streaming WAL archive operation.

__init__(backup_manager)View on GitHub#

Base class init method.

Parameters:
  • backup_manager – The backup manager

  • name – The name of this archiver

Returns:

_abc_impl = <_abc._abc_data object>#
_is_synchronous()View on GitHub#

Check if receive-wal process is eligible for synchronous replication

The receive-wal process is eligible for synchronous replication if synchronous_standby_names is configured and contains the value of streaming_archiver_name

Return type:

bool

_reset_streaming_status(postgres_status, streaming_status)View on GitHub#

Reset the status of receive-wal by removing the .partial file that is marking the current position and creating one that is current with the PostgreSQL insert location

_truncate_partial_file_if_needed(xlog_segment_size)View on GitHub#

Truncate .partial WAL file if size is not 0 or xlog_segment_size

Parameters:

xlog_segment_size (int)

check(check_strategy)View on GitHub#

Perform additional checks for StreamingWalArchiver - invoked by server.check_postgres

Parameters:

check_strategy (CheckStrategy) – the strategy for the management of the results of the various checks

fetch_remote_status()View on GitHub#

Execute checks for replication-based wal archiving

This method does not raise any exception in case of errors, but set the missing values to None in the resulting dictionary.

Return type:

dict[str, None|str]

get_next_batch()View on GitHub#

Returns the next batch of WAL files that have been archived via streaming replication (in the ‘streaming’ directory)

This method always leaves one file in the “streaming” directory, because the ‘pg_receivexlog’ process needs at least one file to detect the current streaming position after a restart.

Returns:

WalArchiverQueue: list of WAL files

receive_wal(reset=False)View on GitHub#

Creates a PgReceiveXlog object and issues the pg_receivexlog command for a specific server

Parameters:

reset (bool) – When set reset the status of receive-wal

Raises:

ArchiverFailure – when something goes wrong

status()View on GitHub#

Set additional status info - invoked by Server.status()

class barman.wal_archiver.WalArchiver(backup_manager, name)View on GitHub#

Bases: RemoteStatusMixin

Base class for WAL archiver objects

__init__(backup_manager, name)View on GitHub#

Base class init method.

Parameters:
  • backup_manager – The backup manager

  • name – The name of this archiver

Returns:

_abc_impl = <_abc._abc_data object>#
archive(verbose=True)View on GitHub#

Archive WAL files, discarding duplicates or those that are not valid.

Parameters:

verbose (boolean) – Flag for verbose output

archive_wal(compressor, wal_info)View on GitHub#

Archive a WAL segment and update the wal_info object

Parameters:
  • compressor – the compressor for the file (if any)

  • wal_info (WalFileInfo) – the WAL file is being processed

abstract check(check_strategy)View on GitHub#

Perform specific checks for the archiver - invoked by server.check_postgres

Parameters:

check_strategy (CheckStrategy) – the strategy for the management of the results of the various checks

abstract get_next_batch()View on GitHub#

Return a WalArchiverQueue containing the WAL files to be archived.

Return type:

WalArchiverQueue

receive_wal(reset=False)View on GitHub#

Manage reception of WAL files. Does nothing by default. Some archiver classes, like the StreamingWalArchiver, have a full implementation.

Parameters:

reset (bool) – When set, resets the status of receive-wal

Raises:

ArchiverFailure – when something goes wrong

abstract status()View on GitHub#

Set additional status info - invoked by Server.status()

static summarise_error_files(error_files)View on GitHub#

Summarise a error files list

Parameters:

error_files (list[str]) – Error files list to summarise

Return str:

A summary, None if there are no error files

class barman.wal_archiver.WalArchiverQueue(items, errors=None, skip=None, batch_size=0)View on GitHub#

Bases: list

__init__(items, errors=None, skip=None, batch_size=0)View on GitHub#

A WalArchiverQueue is a list of WalFileInfo which has two extra attribute list:

  • errors: containing a list of unrecognized files

  • skip: containing a list of skipped files.

It also stores batch run size information in case it is requested by configuration, in order to limit the number of WAL files that are processed in a single run of the archive-wal command.

Parameters:
  • items – iterable from which initialize the list

  • batch_size – size of the current batch run (0=unlimited)

  • errors – an optional list of unrecognized files

  • skip – an optional list of skipped files

property run_sizeView on GitHub#

Number of valid WAL files to be processed in this run - takes in consideration the batch size

Return int:

number of valid WAL files for this batch run

property sizeView on GitHub#

Number of valid WAL segments waiting to be processed (in total)

Return int:

total number of valid WAL files