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.
- 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:
- _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.
- 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, encryption, wal_info)View on GitHub#
Archive a WAL segment and update the wal_info object
- Parameters:
compressor – the compressor for the file (if any)
encryption (None|Encryption) – the encryptor for the file (if any)
wal_info (WalFileInfo) – the WAL file is being processed
- abstractmethod 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
- abstractmethod get_next_batch()View on GitHub#
Return a WalArchiverQueue containing the WAL files to be archived.
- Return type:
- 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
- abstractmethod 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
- class barman.wal_archiver.WalArchiverQueue(items, errors=None, skip=None, batch_size=0, total_size=0)View on GitHub#
Bases:
list
- __init__(items, errors=None, skip=None, batch_size=0, total_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.
Note
This class was originally designed to hold all the WAL files pending to be archived, and to process up to a certain number of files (the batch size). However, it is now used to hold only the files that are being processed in a single run of the archive-wal command. That change was made to avoid the overhead of having to create lots of WalFileInfo objects, even if only a subset of them would be used by the archiver in a given batch. We might want to rework or remove this class in the future, as it doesn’t seem to add much value to the archiving process anymore.
- Parameters:
items – iterable from which initialize the list
errors – an optional list of unrecognized files
skip – an optional list of skipped files
batch_size – size of the current batch run (0=unlimited)
total_size – the total number of WAL files available for archiving.