barman.clients.walrestore module#
- class barman.clients.walrestore.RemoteGetWal(config, wal_name, dest_file, is_worker_process=False)View on GitHub#
Bases:
object
Class responsible for fetching requested WAL file from the remote Barman server via a
get-wal
command over ssh.If
--keep-compression
or one of the compression flags are used, the file arrives compressed and is decompressed before being written to the destination.- __init__(config, wal_name, dest_file, is_worker_process=False)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
is_worker_process (bool) – Whether this is a parallel worker process
- property returncodeView on GitHub#
Return the exit code of the RemoteGetWal processes.
- Returns:
exit code of the RemoteGetWal processe
- class barman.clients.walrestore.WorkerProcess(spool_file_name, *args, **kwargs)View on GitHub#
Bases:
Process
Class representing a parallel process.
In essense, this class is the same as
multiprocessing.Process
, but it also keeps track of the spool file name used by the process. This is useful for cleaning failed files later in case of errors.- __init__(spool_file_name, *args, **kwargs)View on GitHub#
- 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 withstatus
- 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
- 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