added option to limit single host (-h) and POD documentation
authordpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Thu, 26 Jan 2006 00:40:37 +0000 (00:40 +0000)
committerdpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Thu, 26 Jan 2006 00:40:37 +0000 (00:40 +0000)
git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/BackupPC/trunk@293 8392b6e1-25fa-0310-8288-cc32f8e212ea

bin/BackupPC_incPartsUpdate

index 7f7313c..d602fd8 100755 (executable)
@@ -18,6 +18,40 @@ use Getopt::Std;
 use File::Slurp;
 use File::Pid;
 
+=head1 NAME
+
+BackupPC_incPartsUpdate
+
+=head1 DESCRIPTION
+
+Create C<.tar.gz> increments on disk calling C<BackupPC_tarIncCreate>.
+
+Following options are supported (but all are optional):
+
+=over 4
+
+=item -h hostname
+
+Update parts for just single C<hostname>
+
+=item -c
+
+Force check for tar archives which exist on disk
+
+=item -d
+
+Turn debugging output
+
+=back
+
+=cut
+
+my %opt;
+getopts("cdh:", \%opt );
+
+my $debug = $opt{d};
+my $check = $opt{c} && print STDERR "NOTICE: tar archive check forced\n";
+
 my $pid_path = abs_path($0);
 $pid_path =~ s/\W+/_/g;
 
@@ -52,12 +86,6 @@ foreach my $c (qw/gzip md5sum/) {
        $bin->{$c} = which($c) || die "$0 needs $c, install it\n";
 }
 
-my %opt;
-getopts("cd", \%opt );
-
-my $debug = $opt{d};
-my $check = $opt{c} && print STDERR "NOTICE: tar archive check forced\n";
-
 $|=1;
 
 my $start_t = time();
@@ -365,8 +393,17 @@ $sth->execute();
 my $num_backups = $sth->rows;
 my $curr_backup = 1;
 
+if ($opt{h}) {
+       warn "making increments just for host $opt{h}\n";
+}
+
 while (my $row = $sth->fetchrow_hashref) {
 
+       if ($opt{h} && $row->{host} ne $opt{h}) {
+               warn "skipped $row->{host}\n" if ($debug);
+               next;
+       }
+
        $curr_backup++;
 
        my $tar_file = BackupPC::SearchLib::getGzipName($row->{'host'}, $row->{'share'}, $row->{'num'});