Main function, called by actual script in bin/, wraps all work done by script with the sole exception of reading and validating command line arguments.

These tasks (reading and validating arguments) are in this module, but they are called from OmniPITR::Program::new()

Name of called method should be self explanatory, and if you need further information - simply check doc for the method you have questions about.


Does all the actual sending of segments to local and remote destinations.

It keeps it's state to be able to continue in case of error.

Since both local and remote destinations are handled in the same way, there is no point in duplicating the code to 2 methods.

Important notice - this function has to have the ability to choose whether to use temp file (for compressed destinations), or original segment (for uncompressed ones). This is done by this line:

my $local_file = $dst->{ 'compression' } eq 'none' ? $self->{ 'segment' } : $self->get_temp_filename_for( $dst->{ 'compression' } );


Simple function, that checks if segment has been already sent to given destination, and if yes - logs such information.


Function is called only if segment has been successfully compressed and sent to all destinations.

It basically removes tempdir with compressed copies of segment, and state file for given segment.


Wraps all work required to compress segment to all necessary formats.

Call to actuall compressor has to be done via "bash -c" to be able to easily use run_command() function which has side benefits of getting stdout, stderr, and proper fetching error codes.

Overhead of additional fork+exec for bash should be negligible.


Helper function which checks if segment has been already compressed.

It uses state file, and checks compressed file md5sum to be sure that the file wasn't damaged between prior run and now.


Helper function to build full (with path) filename for compressed segment, assuming given compression.


Helper function to read state from state file.

Name of state file is the same as filename of WAL segment being archived, but it is in state-dir.


Helper function to save state to state-file.


Defines which options are legal for this program.


Function called back from OmniPITR::Program::read_args(), with parsed args as hashref.

Is responsible for putting arguments to correct places, initializing logs, and so on.


Does all necessary validation of given command line arguments.

One exception is for compression programs paths - technically, it could be validated in here, but benefit would be pretty limited, and code to do so relatively complex, as compression program path might, but doesn't have to be actual file path - it might be just program name (without path), which is the default.