barman.clients.walrestore module#

class barman.clients.walrestore.RemoteGetWal(config, wal_name, dest_file)View on GitHub#

Bases: object

__init__(config, wal_name, dest_file)View on GitHub#

Spawn a process that download a WAL from remote.

If needed decompress the remote stream on the fly.

Parameters:
  • config (argparse.Namespace) – the configuration from command line

  • wal_name – The name of WAL to download

  • dest_file – The destination file name or a writable file object

_get_server_config_minimal(config)View on GitHub#

Returns a placeholder for a server config object with all compression parameters relevant to CompressionManager filled.

Parameters:

config (argparse.Namespace) – the configuration from command line

processes = {}#

The list of processes that has been spawned by RemoteGetWal

property returncodeView on GitHub#

Return the exit code of the RemoteGetWal processes.

A remote get-wal process return code is 0 only if both the remote get-wal process and the eventual decompressor return 0

Returns:

exit code of the RemoteGetWal processes

classmethod wait_for_all()View on GitHub#

Wait for the termination of all the registered spawned processes.

barman.clients.walrestore.build_ssh_command(config, wal_name, peek=0)View on GitHub#

Prepare an ssh command according to the arguments passed on command line

Parameters:
  • config (argparse.Namespace) – the configuration from command line

  • wal_name (str) – the wal_name get-wal parameter

  • peek (int) – in

Return list[str]:

the ssh command as list of string

barman.clients.walrestore.connectivity_test(config)View on GitHub#

Invoke remote get-wal –test to test the connection with Barman server

Parameters:

config (argparse.Namespace) – the configuration from command line

barman.clients.walrestore.execute_peek(config)View on GitHub#

Invoke remote get-wal –peek to receive a list of wal file to copy

Parameters:

config (argparse.Namespace) – the configuration from command line

Returns set:

a set of WAL file names from the peek command

barman.clients.walrestore.exit_with_error(message, status=2, sleep=0)View on GitHub#

Print message and terminate the script with status

Parameters:
  • message (str) – message to print

  • status (int) – script exit code

  • sleep (int) – second to sleep before exiting

barman.clients.walrestore.main(args=None)View on GitHub#

The main script entry point

barman.clients.walrestore.parse_arguments(args=None)View on GitHub#

Parse the command line arguments

Parameters:

args (list[str]) – the raw arguments list. When not provided it defaults to sys.args[1:]

Return type:

argparse.Namespace

barman.clients.walrestore.peek_additional_files(config)View on GitHub#

Invoke remote get-wal –peek to receive a list of wal files to copy

Parameters:

config (argparse.Namespace) – the configuration from command line

Returns set:

a set of WAL file names from the peek command

barman.clients.walrestore.spawn_additional_process(config, additional_files)View on GitHub#

Execute additional barman get-wal processes

Parameters:
  • config (argparse.Namespace) – the configuration from command line

  • additional_files – A list of WAL file to be downloaded in parallel

Return list[subprocess.Popen]:

list of created processes

barman.clients.walrestore.try_deliver_from_spool(config, dest_file)View on GitHub#

Search for the requested file in the spool directory. If is already present, then copy it locally and exit, return otherwise.

Parameters:
  • config (argparse.Namespace) – the configuration from command line

  • dest_file – The path to the destination file