run()

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.

delete_old_xlogs()

Function that does the actual removal of old xlogs from wal archive.

It's basing its work on "older_kept" meta file, set by ignore_new_backups.

delete_old_backups()

Removal of too old backups. Works on list provided by ignore_new_backups.

remove_file()

Helper function which runs unlink on a file, reporting error when needed.

This function exists, so that "dry-run" check can be in one place.

ignore_new_backups()

Scans meta information loaded, and classifies it into 3 parts:

  • older than keep-days - stacks meta info in $self->{'delete_backups'} - to be used later by delete_old_backups

  • single oldest, but within keep-days - puts the meta information in $self->{'oldest_kept'} - to be used later by delete_old_xlogs

  • newer than "oldest_kept" - ignored - nothing to be done about them.

find_and_read_all_meta_files()

Scans given backup directory for meta files.

Each file containing "meta" in ints name is read (first 8kB only, as the meta files are small, and there is no point in reading big files that accidentaly have "meta" in name).

From the meta file, it extracts information:

  • Timezone - what timezone was on the server that made the backup

  • Hostname - what was the hostname of machine making the backup

  • Min-Xlog - first xlog required to restore given backup

  • Started-epoch - when the backup was started - epoch time

Then, it tried to regenerate meta filename using fetched details, to make sure that they make sense (filename-template, compression).

If regenerated filename is the same as real - meta info is stacked. If not - error is logged, but processing continues for next metafile.

Afterwards, all hashes with information from meta files are sorted by Started-epoch, and stored in $self for further processing.

verify_regeneration_of_meta_filename()

Helped function called by find_and_read_all_meta_files. Actually checks if the filename of meta file can be rebuilt using information from it.

strftime_at_timezone()

Returns time formatted with given format (compatible with normal strftime) at a given time zone, like:

strftime_at_timezone( '%Y-%m-%d %H:%M:%S %Z', 1386976730, 'America/Los_Angeles' )   # '2013-12-13 15:18:50 PST'
strftime_at_timezone( '%Y-%m-%d %H:%M:%S %Z', 1386976730, 'UTC' )                   # '2013-12-13 23:18:50 UTC'
strftime_at_timezone( '%Y-%m-%d %H:%M:%S %Z', 1386976730, 'EST' )                   # '2013-12-13 18:18:50 EST'

read_args_specification

Defines which options are legal for this program.

read_args_normalization

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.

validate_args()

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.