barman.hooks module#
This module contains the logic to run hook scripts
- class barman.hooks.HookScriptRunner(backup_manager, name, phase=None, error=None, retry=False, **extra_env)View on GitHub#
Bases:
object
- __init__(backup_manager, name, phase=None, error=None, retry=False, **extra_env)View on GitHub#
Execute a hook script managing its environment
- env_from_backup_info(backup_info)View on GitHub#
Prepare the environment for executing a script
- Parameters:
backup_info (BackupInfo) – the backup metadata
- env_from_recover(backup_info, dest, tablespaces, remote_command, error=None, **kwargs)View on GitHub#
Prepare the environment for executing a script
- env_from_wal_info(wal_info, full_path=None, error=None)View on GitHub#
Prepare the environment for executing a script
- Parameters:
wal_info (WalFileInfo) – the backup metadata
full_path (str) – override wal_info.fullpath() result
- reset()View on GitHub#
Reset the status of the class.
- run()View on GitHub#
Run a a hook script if configured. This method must never throw any exception
- class barman.hooks.RetryHookScriptRunner(backup_manager, name, phase=None, error=None, **extra_env)View on GitHub#
Bases:
HookScriptRunner
A ‘retry’ hook script is a special kind of hook script that Barman tries to run indefinitely until it either returns a SUCCESS or ABORT exit code. Retry hook scripts are executed immediately before (pre) and after (post) the command execution. Standard hook scripts are executed immediately before (pre) and after (post) the retry hook scripts.
- ATTEMPTS_BEFORE_NAP = 5#
- BREAK_TIME = 3#
- EXIT_ABORT_CONTINUE = 62#
- EXIT_ABORT_STOP = 63#
- EXIT_SUCCESS = 0#
- NAP_TIME = 60#
- __init__(backup_manager, name, phase=None, error=None, **extra_env)View on GitHub#
Execute a hook script managing its environment
- run()View on GitHub#
Run a a ‘retry’ hook script, if required by configuration.
Barman will retry to run the script indefinitely until it returns a EXIT_SUCCESS, or an EXIT_ABORT_CONTINUE, or an EXIT_ABORT_STOP code. There are BREAK_TIME seconds of sleep between every try. Every ATTEMPTS_BEFORE_NAP failures, Barman will sleep for NAP_TIME seconds.