Object contstructor.

Since all OmniPITR programs are based on object, and they start with doing the same things (namely reading and validating command line arguments) - this is wrapped in here, to avoid code duplication.

Constructor also handles pid file creation, in case it was requested.


Internal method providing --debug option handling to every omnipitr program.

If *first* argument to omnipitr program it will print to stderr all arguments, and environment variables.


Just a stub method, that has to be overriden in subclasses.


Shortcut to make code a bit nicer.

Returns values of (command line given) verbose switch.


Shortcut to make code a bit nicer.

Returns logger object.


Helper function, which builds path for temp directory, and creates it.

Path is generated by using given temp-dir and 'omnipitr-backup-master' named.

For example, for temp-dir '/tmp' used temp directory would be /tmp/omnipitr-backup-master.

If any arguments are passed - they are treated as subdirectories. For example, in above example, if ("xxx", "yyy") was passed, generated directory would be /tmp/omnipitr-backup-master/xxx/yyy.


Returns full path to temp file. Name of the file is passed as argument, temp directory is created (if needed) and full path is returned.


Destructor for object - removes temp directory on program exit.


Scans list of destinations, and gathers list of all compressions that have to be made.

This is to be able to compress file only once even when having multiple destinations that require compressed format.

This function is used by all programs that need to compress "stuff" - omnipitr-archive, omnipitr-backup-master and omnipitr-backup-slave.


Calls pg_controldata, and parses its output.

Verifies that output contains 2 critical pieces of information:

  • Latest checkpoint's REDO location

  • Latest checkpoint's TimeLineID


Runs given query via psql - assumes there is $self->{'psql-path'}.

Uses also:

  • username

  • database

  • port

  • host

  • optional keys from $self.

    On first run it will cache psql call arguments, so if you'd change them on subsequent calls, you have to delete $self->{'psql'}.

    In case of errors, it raises fatal error.

    Otherwise returns stdout of the psql.


Helper function. Takes no arguments. Uses pg_tblspc directory and returns a hashref of the physical locations of tablespaces. Keys in the hashref are tablespace OIDs (link names in pg_tblspc). Values are hashrefs with two keys:

  • pg_visible - what is the path to tablespace that PostgreSQL sees

  • real_path - what is the real absolute path to tablespace directory

The two can be different in case tablespace got moved and symlinked back to original location, or if tablespace path itself contains symlinks.


Function which does all the parsing of command line argument.

Additionally, it starts logger object (and stores it in $self->{'log'}), because it works this way in virtually all omnipitr programs.

It should be either overloaded in subclasses, or there should be additional methods:

  • read_args_specification() - providing specification of options for given program

  • read_args_normalization()

read_args_specification is supposed to return hashref, where keys are names of options, and values are hashrefs with two optional keys:

  • default - default value.

  • aliases - option aliases passed as arrayref

  • optional - wheter value for given argument is optional (i.e. you can have --option, or --option "value").

  • type - Getopt::Long based type. This can be ignored for simple boolean options, or can be something like "s", "s@", "i".

read_args_normalization() is called after option parsing, and only if there are no unknown options, there is no --version, nor --help. It is passed single hashref, with all parsed options, and default values applied.


Just as the name suggests - calling this method will print help for program, and exit it with error-code (1).

If there are any arguments, they are treated as arguments to printf() function, and are printed to STDERR.


Loads options from config file.

File name should be passed as argument.

Format of the file is very simple - each line is treated as option with optional value.



It is important that you don't need to quote the values - value will always be up to the end of line (trailing spaces will be removed). So if you'd want, for example, to have dst-local set to "/mnt/badly named directory", you'd need to quote it when setting from command line:

omnipitr-archive --dst-local="/mnt/badly named directory"

but not in config:

--dst-local=/mnt/badly named directory

Empty lines, and comment lines (starting with #) are ignored.


Hey! The above document had some coding errors, which are explained below:

Around line 308:

You forgot a '=back' before '=head1'