Hi, 

Do you want to generate a list of files that was backupped or something?

I made the following Perl script to do that (of the last 200 jobs) and dump it 
to files. 
You can use the -f switch and feed it a jobname if you like.

--------------------%<------------------------
#!/usr/bin/perl
use Getopt::Easy;
get_options "f-name=", "usage => parsejoblist.pl [-f name]", "h";
my $outputdir="/home/ger/temp/jobs";
system("rm ". $outputdir."/*.txt");


my $inputfile = "";
# Lijst maken met jobs

$inputfile = "[EMAIL PROTECTED] $outputdir/joblista.txt w\n";
$inputfile .= "list jobs\n";
$inputfile .= "[EMAIL PROTECTED]";
$inputfile .= "quit\n";
open(OUTPUT, '>'.$outputdir.'/bacinput.txt');
print OUTPUT $inputfile;
close(OUTPUT);
system("bconsole -c /etc/bacula/bconsole.conf <$outputdir/bacinput.txt > 
/dev/null");

#Alleen laaste jobs meenemen
system("tail -n 200 $outputdir/joblista.txt > $outputdir/joblist.txt");
unlink($outputdir."/joblista.txt");

$file=$outputdir.'/joblist.txt';
open(FILE, $file);
@lines = <FILE>;
close(FILE);

foreach (@lines) {
    @line = split(/\|/);
#        print $O{name}, "naam\r\n";
    if ((($O{name}) && (index($line[2], $O{name}) > 0)) || ($O{name} eq "")) {
        if ((index($line[2], "BackupCatalog") < 0) && (index($line[5], "F") > 
0) && (index($line[3], "E") < 0)) {
            print "Processing job: ", $line[2], "\n";
            # print index($line[2], "BackupCatalog"), $line[2], "\n";
            $line[1] =~ s/,//;    #trailing
            $line[1] =~ s/^\s+//; #en eerste spaties verwijderen
            $line[2] =~ s/ +//g; #alle spaties verwijderen
            $inputfile = "[EMAIL PROTECTED] \"".$outputdir."/$line[2].txt\" 
w\n";
            $inputfile .= "llist files jobid=$line[1]\n";
            $inputfile .= "[EMAIL PROTECTED]";
            $inputfile .= "quit\n";
            open(OUTPUT, '>'.$outputdir.'/bacinput.txt');
            print OUTPUT $inputfile;
            close(OUTPUT);
            system("bconsole -c /etc/bacula/bconsole.conf 
<".$outputdir."/bacinput.txt >> /dev/null");
            $grepcommand="egrep '/ +\\\| \*\$|----|JobId|[0-9],[0-9]|: \' 
".$outputdir."/$line[2].txt > ".$outputdir."/$line[2]folders.txt";
            #print $grepcommand, "\n";
            system($grepcommand);
            system($grepcommand);
            unlink("$outputdir/$line[2].txt");
            #die("end");
        }
    }
}

unlink($outputdir."/joblist.txt");
unlink($outputdir."/bacinput.txt");

#Second stage, spit out the job configuration lists.
my $printlineflag = false;

$file='/etc/bacula/bacula-dir.conf';
open(CONFFILE, $file);
@lines = <CONFFILE>;
close(CONFFILE);

foreach (@lines) {
    if (index($_, "FileSet") eq 0){
        $printlineflag = 1;
        $fileset = "";
        $jobname = "";
    }

    if ((index($_, "Name") > 0) && ($printlineflag)) {
        $jobname = substr($_, index($_, "\"")+1, -2);
        $jobname =~ s/ +//g;
    }

    $fileset .= $_ if ($printlineflag);

    if (index($_, "}") eq 0) {
        $printlineflag = 0;
        $file=($outputdir."/".$jobname."_Jobdef.txt");
        open(JOBDEF, ">".$file);
        print JOBDEF "Job configuration for " . $jobname . "\n";
        print JOBDEF $fileset;
        close(JOBDEF);
        #print $fileset;
    }
}

--------------------%<------------------------

I realize this is probably overkill, but perhaps you can get something useful 
out of it.

Greetings,
Ger.



-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to