+
+package BBM::Config;
+use strict;
+use Config::General;
+
+sub new {
+ my $self = shift;
+ my $class = ref($self) || $self;
+ my $file = shift;
+
+ my $config = new Config::General(-ConfigFile => $file, -LowerCaseNames => 1);
+ my $this = { $config->getall() };
+ bless($this, $class);
+}
+
+sub get {
+ my ($self, $section, $key) = @_;
+ my $h = $self;
+
+ # descend to [cluster] if $section not present in root tree
+ unless (exists $h->{$section}) {
+ $h = $h->{cluster};
+ }
+
+ # pay attention if callee wanted arrays
+ return wantarray ? () : undef unless exists $h->{$section};
+ return wantarray ? () : undef unless exists $h->{$section}->{$key};
+
+ # deref if wanted array and is arrayref
+ return @{$h->{$section}->{$key}} if wantarray && ref $h->{$section}->{$key} eq 'ARRAY';
+
+ return $h->{$section}->{$key};
+}
+
+
+__END__
+
+=head1 NAME
+
+bacula-backup-mysql - A hook for Bacula to backup mysql databases using mysqlhotcopy.
+
+=head1 SYNOPSIS
+
+ Job {
+ Name = "example.org-mysql"
+ ...
+ # This prepares the backup
+ Client Run Before Job = "/usr/sbin/bacula-backup-mysql"
+ # This deletes the copy of the catalog
+ Client Run After Job = "/usr/sbin/bacula-backup-mysql -cleanup"
+ }
+
+=head1 DESCRIPTION
+
+This is a script to be setup as C<Client Run Before Job> in Bacula.
+
+=head1 AUTHOR
+
+Copyright (C) 2009-2010, Elan RuusamE<auml>e <glen@delfi.ee>
+
+=head1 SEE ALSO
+
+http://www.bacula.org/
+
+=cut