Hi,
Do you always check what all programs you've launched have done? I mean,
if the program says "OK", do you check he is right to say "OK"?
To me, if Bacula says OK, I trust it, I don't check database/archives
content. I think I'm right because I had to restore 1 TeraBytes,
including users personnal data. No one complained, so I think they
didn't loose all their works.
As far as I am concerned, I use hobbit monitor to check bacula backups.
I use a script inspired from what you can find in
examples/nagios/nagios.txt.
It ouputs a summary of termination status:
Example:
# check_bacula.pl -H 72
job_mail01c 2009-02-21 00:11:01 2009-02-21 01:09:23 Terminated normally
No of errors: 1
For the past 72 hours, Bacula found 22 jobs:
21 successfull jobs
1 jobs terminated with warning
0 jobs in error
0 jobs with other status
Source:
==========================================================================================
#!/usr/bin/perl -w
use strict;
use POSIX;
use File::Basename;
use DBI;
use Getopt::Long;
use vars qw(
$opt_help
$opt_critical
$opt_warning
$opt_usage
$opt_verbose
$opt_version
$out
$sql
$date_start
$date_stop
$state
$count
);
my $dbuser = 'bacula' ;
my $dbpass = 'bacula' ;
my $opt_job = '' ;
my $opt_hours = 24 ;
# Taken from jcr.h in Bacula 2.2.3
my %status = ( 'A' => 'Canceled by user' ,
'B' => 'Blocked' ,
'C' => 'Created, but not running' ,
'c' => 'Waiting for client resource' ,
'D' => 'Verify differences' ,
'd' => 'Waiting for maximum jobs' ,
'E' => 'Terminated in error' ,
'e' => 'Non-fatal error' ,
'f' => 'fatal error' ,
'F' => 'Waiting on File Daemon' ,
'j' => 'Waiting for job resource' ,
'M' => 'Waiting for mount' ,
'm' => 'Waiting for new media' ,
'p' => 'Waiting for higher priority jobs to finish' ,
'R' => 'Running' ,
'S' => 'Scan' ,
's' => 'Waiting for storage resource' ,
'T' => 'Terminated normally' ,
't' => 'Waiting for start time' ) ;
my @error_status = ( 'E', 'e', 'f') ;
my %jobs_status = ( 'Success' => 0 ,
'Warning' => 0 ,
'Error' => 0 ,
'Other' => 0 ) ;
sub print_help();
sub print_usage();
sub get_now();
sub get_date;
my $progname = basename($0);
Getopt::Long::Configure('bundling');
GetOptions
(
"H=s" => \$opt_hours, "hours=s" => \$opt_hours,
"j=s" => \$opt_job, "job=s" => \$opt_job,
"v" => \$opt_verbose, "verbose" => \$opt_verbose,
"h" => \$opt_help, "help" => \$opt_help,
"usage" => \$opt_usage,
"V" => \$opt_version, "version" => \$opt_version
) || die "Try '$progname --help' for more information.\n";
sub print_help() {
print_usage() ;
}
sub print_usage() {
print "$progname [-H|--hours hours] [-j|--job partial_jobname]
[-h|--help|--usage] [-v|--version]\n";
print " -H, --hours NN Looking for jobs during last NN hours.
Default is 24 hours.\n" ;
print " -j, --job name Partial job name. Eg: 'web' will match
'job_web1' and 'job_web2'\n" ;
print " -v, --verbose Prints all jobs, even successfull.\n" ;
print " -h, --help\n" ;
print " --usage Print this message\n" ;
print " -V, --version Version of this script\n" ;
print "\n";
}
sub get_now() {
my $now = defined $_[0] ? $_[0] : time;
my $out = strftime("%Y-%m-%d %X", localtime($now));
return($out);
}
sub get_date {
my $day = shift;
my $now = defined $_[0] ? $_[0] : time;
my $new = $now - ((60*60*1) * $day);
my $out = strftime("%Y-%m-%d %X", localtime($new));
return ($out);
}
sub display_row
{
my @row = @_ ;
$row[3] = $status{$row[3]} ;
$row[4] = 'No of errors: ' . $row[4] ;
print "@row\n" ;
}
if ($opt_help) {
print_help();
exit 0 ;
}
if ($opt_usage) {
print_usage();
exit 0 ;
}
if ($opt_version) {
print "$progname 0.0.1\n";
exit 0 ;
}
my $dsn = "DBI:mysql:database=bacula;host=localhost";
my $dbh = DBI->connect( $dsn, $dbuser, $dbpass) or die "Error
connecting to: '$dsn': $DBI::errstr\n";
if ($opt_hours)
{
$date_stop = get_date($opt_hours);
}
else
{
$date_stop = '1970-01-01 01:00:00';
}
$date_start = get_now();
if ( "$opt_job" eq '' )
{
# $sql = "SELECT Name,StartTime,EndTime,JobStatus,JobErrors from Job
where (EndTime <> '') and ((EndTime <= '$date_start') and (EndTime >=
'$date_stop'));";
$sql = "SELECT Name,StartTime,EndTime,JobStatus,JobErrors from Job
where (StartTime >= '$date_stop');";
}
else
{
# $sql = "SELECT Name,StartTime,EndTime,JobStatus,JobErrors from Job
where (Name like '%$opt_job%') and (JobStatus='T') and (EndTime <> '')
and ((EndTime <= '$date_start') and (EndTime >= '$date_stop'));";
$sql = "SELECT Name,StartTime,EndTime,JobStatus,JobErrors from Job
where (StartTime >= '$date_stop') and (Name like '%$opt_job%');";
}
my $sth = $dbh->prepare($sql) or die "Error preparing
statemment",$dbh->errstr;
$sth->execute;
LINE: while (my @row = $sth->fetchrow_array()) {
# Checking termination status
foreach my $code (@error_status) {
if ( $code eq $row[3] )
{
display_row(@row) ;
$jobs_status{'Error'} ++;
next LINE ;
}
}
if ( $row[3] eq 'T')
{
if ( $row[4] == 0 )
{
$jobs_status{'Success'} ++ ;
display_row(@row) if ($opt_verbose) ;
}
else
{
$jobs_status{'Warning'} ++ ;
display_row(@row);
}
next LINE ;
}
$jobs_status{'Other'} ++ ;
display_row(@row);
}
my $jobs_total = 0 ;
foreach my $key (keys %jobs_status)
{
$jobs_total += $jobs_status{$key} ;
}
print "\n" if ($jobs_total != $jobs_status{'Success'}) || $opt_verbose ;
print "For the past $opt_hours hours, Bacula found $jobs_total jobs";
print " (like %". $opt_job . "%)" if ( "$opt_job" ne '' );
print ":\n" ;
print "$jobs_status{'Success'} successfull jobs\n";
print "$jobs_status{'Warning'} jobs terminated with warning\n";
print "$jobs_status{'Error'} jobs in error\n";
print "$jobs_status{'Other'} jobs with other status\n";
$dbh->disconnect();
==========================================================================================
Otherwise, you can use directives like RunScript, Run After Job, Run
After Failed Job in the Job resource
http://www.bacula.org/en/rel-manual/Configuring_Director.html#SECTION001430000000000000000
to send you an alert by email, launch a script...
I would recommend you not to try to check what Bacula has done, just
check jobs termination status.
Maybe you should take a look at:
http://www.bacula.org/en/rel-manual/Bacula_Freque_Asked_Questi.html#SECTION0037200000000000000000
Darryn Levitt a écrit :
> Hi all.
>
> I am new to bacula and and some help.
>
> Can some please give me an example of a job resource that I can use to
> verify that the data written to a tape from a job is the same as what
> was written to the tape?
> In other words, to verify that the files were successfully written to
> the tape, and that what is on the tape, is exactly the same what is on
> my hard disk?
> Any recommendations or comments?
>
> TIA.
>
> Darryn
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> -Strategies to boost innovation and cut costs with open source participation
> -Receive a $600 discount off the registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> Bacula-users mailing list
> Bacula-users AT lists.sourceforge DOT net
> https://lists.sourceforge.net/lists/listinfo/bacula-users
>
--
Maxime CHARPENNE
Université d'Avignon et des Pays de Vaucluse - CRI
Tél. : +33 4 90 16 26 05
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users
|