Changeset 143 for trunk

Show
Ignore:
Timestamp:
05/19/10 21:50:58 (4 years ago)
Author:
depesz
Message:

developer docs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/omnipitr/lib/OmniPITR/Program/Backup/Master.pm

    r140 r143  
    1818use Getopt::Long qw( :config no_ignore_case ); 
    1919 
     20=head1 run() 
     21 
     22Main function wrapping all work. 
     23 
     24Starts with getting list of compressions that have to be done, then it chooses where to compress to (important if we have remote-only destination), then it makes actual backup, and delivers to all 
     25destinations. 
     26 
     27=cut 
     28 
    2029sub run { 
    2130    my $self = shift; 
     
    3746} 
    3847 
     48=head1 deliver_to_all_destinations() 
     49 
     50Simple wrapper to have single point to call to deliver backups to all requested backups. 
     51 
     52=cut 
     53 
    3954sub deliver_to_all_destinations { 
    4055    my $self = shift; 
    4156 
    42     # $self->log->log( '%s', $self ); 
    43  
    4457    $self->deliver_to_all_local_destinations(); 
    4558 
     
    4861    return; 
    4962} 
     63 
     64=head1 deliver_to_all_local_destinations() 
     65 
     66Copies backups to all local destinations which are not also base destinations for their respective compressions. 
     67 
     68=cut 
    5069 
    5170sub deliver_to_all_local_destinations { 
     
    7998    return; 
    8099} 
     100 
     101=head1 deliver_to_all_remote_destinations() 
     102 
     103Delivers backups to remote destinations using rsync program. 
     104 
     105=cut 
    81106 
    82107sub deliver_to_all_remote_destinations { 
     
    111136} 
    112137 
     138=head1 compress_xlogs() 
     139 
     140Wrapper function which encapsulates all work required to compress xlog segments that accumulated during backup of data directory. 
     141 
     142=cut 
     143 
    113144sub compress_xlogs { 
    114145    my $self = shift; 
     
    125156} 
    126157 
     158=head1 compress_pgdata() 
     159 
     160Wrapper function which encapsulates all work required to compress data directory. 
     161 
     162=cut 
     163 
    127164sub compress_pgdata { 
    128165    my $self = shift; 
     
    139176    return; 
    140177} 
     178 
     179=head1 tar_and_compress() 
     180 
     181Worker function which does all of the actual tar, and sending data to compression filehandles. 
     182 
     183Takes hash (not hashref) as argument, and uses following keys from it: 
     184 
     185=over 
     186 
     187=item * tar_dir - which directory to compress 
     188 
     189=item * work_dir - what should be current working directory when executing tar 
     190 
     191=item * excludes - optional key, that (if exists) is treated as arrayref of shell globs (tar dir) of items to exclude from backup 
     192 
     193=back 
     194 
     195If tar will print anything to STDERR it will be logged. Error status code is ignored, as it is expected that tar will generate errors (due to files modified while archiving). 
     196 
     197=cut 
    141198 
    142199sub tar_and_compress { 
     
    202259} 
    203260 
     261=head1 start_writers() 
     262 
     263Starts set of filehandles, which write to file, or to compression program, to create final archives. 
     264 
     265Each compression schema gets its own filehandle, and printing data to it, will pass it to file directly or through compression program that has been chosen based on command line arguments. 
     266 
     267=cut 
     268 
    204269sub start_writers { 
    205270    my $self      = shift; 
     
    237302} 
    238303 
     304=head1 get_archive_filename() 
     305 
     306Helper function, which takes filetype and compression schema to use, and returns generated filename (based on filename-template command line option). 
     307 
     308=cut 
     309 
    239310sub get_archive_filename { 
    240311    my $self = shift; 
     
    250321} 
    251322 
     323=head1 stop_pg_backup() 
     324 
     325Runs pg_stop_backup() PostgreSQL function, which is crucial in backup process. 
     326 
     327This happens after data directory compression, but before compression of xlogs. 
     328 
     329This function also removes temporary destination for xlogs (dst-backup for omnipitr-archive). 
     330 
     331=cut 
     332 
    252333sub stop_pg_backup { 
    253334    my $self = shift; 
     
    272353    return; 
    273354} 
     355 
     356=head1 start_pg_backup() 
     357 
     358Executes pg_start_backup() postgresql function, and (before it) creates temporary destination for xlogs (dst-backup for omnipitr-archive). 
     359 
     360=cut 
    274361 
    275362sub start_pg_backup { 
     
    299386} 
    300387 
     388=head1 clean_and_die() 
     389 
     390Helper function called by other parts of code - removes temporary destination for xlogs, and exits program with logging passed message. 
     391 
     392=cut 
     393 
    301394sub clean_and_die { 
    302395    my $self          = shift; 
     
    306399} 
    307400 
     401=head1 choose_base_local_destinations() 
     402 
     403Chooses single local destination for every compression schema required by destinations specifications. 
     404 
     405In case some compression schema exists only for remote destination, local temp directory is created in --temp-dir location. 
     406 
     407=cut 
     408 
    308409sub choose_base_local_destinations { 
    309410    my $self = shift; 
     
    333434} 
    334435 
     436=head1 DESTROY() 
     437 
     438Destroctor for object - removes temp directory on program exit. 
     439 
     440=cut 
     441 
    335442sub DESTROY { 
    336443    my $self = shift; 
     
    344451Helper function, which builds path for temp directory, and creates it. 
    345452 
    346 Path is generated by using given temp-dir, 'omnipitr-archive' name, and filename of segment
    347  
    348 For example, for temp-dir '/tmp' and segment being pg_xlog/000000010000000000000003, actual, used temp directory would be /tmp/omnipitr-archive/000000010000000000000003/
     453Path is generated by using given temp-dir and 'omnipitr-backup-master' named
     454 
     455For example, for temp-dir '/tmp' used temp directory would be /tmp/omnipitr-backup-master
    349456 
    350457=cut 
     
    386493 
    387494Function which does all the parsing, and transformation of command line arguments. 
    388  
    389 It also verified base facts about passed WAL segment name, but all other validations, are being done in separate function: L<validate_args()>. 
    390495 
    391496=cut