first version which stores backup parts
[BackupPC.git] / bin / BackupPC_ASA_SearchUpdate
index 5cff61f..ede665f 100755 (executable)
@@ -59,7 +59,7 @@ my $dbh = DBI->connect($dsn, $user, "", { RaiseError => 1, AutoCommit => 0 });
 
 my %opt;
 
-if ( !getopts("cdm:v:ijfq", \%opt ) ) {
+if ( !getopts("cdm:v:ijfqh:", \%opt ) ) {
        print STDERR <<EOF;
 usage: $0 [-c|-d] [-m num] [-v|-v level] [-i|-j|-f]
 
@@ -67,6 +67,7 @@ Options:
        -c      create database on first use
        -d      delete database before import
        -m num  import just num increments for one host
+       -h "h1 h2" import just single HostList hosts
        -v num  set verbosity (debug) level (default $debug)
        -i      update Hyper Estraier full text index
        -j      update full text, don't check existing files
@@ -358,6 +359,8 @@ if ($opt{c}) {
                $dbh->do( qq{ CREATE SEQUENCE $seq } );
        }
 
+=cut
+
        print " creating triggers ";
        $dbh->do( <<__END_OF_TRIGGER__ );
 
@@ -419,6 +422,8 @@ create trigger do_backup_backup_parts_check
 
 __END_OF_TRIGGER__
 
+=cut
+
        print "...\n";
 
        $dbh->commit;
@@ -479,11 +484,20 @@ INSERT INTO files
 my @hosts = keys %{$hosts};
 my $host_nr = 0;
 
+my $host_regex;
+if ( exists $opt{h} ) {
+       $host_regex = $opt{h};
+       $host_regex =~ s/\s+/|/g;
+       $host_regex = '^' . $host_regex . '$';
+}
+
 foreach my $host_key (@hosts) {
 
        my $hostname = $hosts->{$host_key}->{'host'} || die "can't find host for $host_key";
 
-       $sth->{hosts_by_name}->execute($hosts->{$host_key}->{'host'});
+       next if $host_regex && $hostname =~ m/$host_regex/;
+
+       $sth->{hosts_by_name}->execute($hostname);
 
        unless (($hostID) = $sth->{hosts_by_name}->fetchrow_array()) {
                $sth->{insert_hosts}->execute(