From: Scott Barninger Date: Sun, 14 May 2006 15:33:35 +0000 (+0000) Subject: Add SQLite support. X-Git-Tag: Release-2.0.0~863 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bacb4ea2939789aa7d695583f8a48519821649d8;p=bacula%2Fbacula Add SQLite support. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3021 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/gui/bimagemgr/ChangeLog b/gui/bimagemgr/ChangeLog index 2e988681fe..007972ea5a 100644 --- a/gui/bimagemgr/ChangeLog +++ b/gui/bimagemgr/ChangeLog @@ -33,4 +33,7 @@ separate program configuration into config.pm add COPYING file add post install script to rpm to add web server user to group bacula + 0.3 14 May 2006 + add support for SQLite databases + diff --git a/gui/bimagemgr/README b/gui/bimagemgr/README index af682ee9c1..aee131b9af 100644 --- a/gui/bimagemgr/README +++ b/gui/bimagemgr/README @@ -1,11 +1,11 @@ bimagemgr.pl -07 May 2006 +14 May 2006 This is a utility to monitor and burn file backups to CDR. It is a web based interface written in perl. It requires perl and an apache or other http server. It also requires the perl DBI module and the driver for the database used to store your bacula catalog. It has been tested on MySQL -catalogs but an untested configuration is present for Postgresql. +catalogs but an untested configuration is present for Postgresql and SQLite. It can be run on the same server as bacula or on another machine on the network if you are willing to relax permissions on the backup Volume files diff --git a/gui/bimagemgr/ReleaseNotes b/gui/bimagemgr/ReleaseNotes index 5249aea088..7cd1d1bcf1 100644 --- a/gui/bimagemgr/ReleaseNotes +++ b/gui/bimagemgr/ReleaseNotes @@ -11,3 +11,5 @@ new config.pm file. A post install script in the rpm package will add the web server user to the group bacula. + +Support for SQLite databases has been added. diff --git a/gui/bimagemgr/bimagemgr.pl b/gui/bimagemgr/bimagemgr.pl index a22103eebf..5384c681c9 100755 --- a/gui/bimagemgr/bimagemgr.pl +++ b/gui/bimagemgr/bimagemgr.pl @@ -70,6 +70,8 @@ my $password = $prog_config->{'password'}; my $db_driver = $prog_config->{'db_driver'}; my $db_name_param = $prog_config->{'db_name_param'}; my $catalog_dump = $prog_config->{'catalog_dump'}; +my $sqlitebindir = $prog_config->{'sqlitebindir'}; +my $bacula_working_dir = $prog_config->{'bacula_working_dir'}; # path to backup files my $image_path = $prog_config->{'image_path'}; @@ -141,8 +143,15 @@ sub Display { &UpdateImageTable(); # connect to database - my $dbh = DBI->connect("DBI:$db_driver:$db_name_param=$database;host=$host","$user","$password", + my ($dbh); + if ( $db_driver eq "SQLite" ) { + $dbh = DBI->connect("DBI:$db_driver:$db_name_param=$bacula_working_dir/$database.db","","", {'RaiseError' => 1}) || &HTMLdie("Unable to connect to database."); + } + else { + $dbh = DBI->connect("DBI:$db_driver:$db_name_param=$database;host=$host","$user","$password", + {'RaiseError' => 1}) || &HTMLdie("Unable to connect to database."); + } my $sth = $dbh->prepare("SELECT Media.VolumeName,Media.LastWritten,CDImages.LastBurn, Media.VolWrites,Media.VolStatus FROM CDImages,Media @@ -328,8 +337,13 @@ sub Burn { my $burndate = "$sysdate $systime"; # connect to database - my $dbh = DBI->connect("DBI:$db_driver:$db_name_param=$database;host=$host","$user","$password", - {'RaiseError' => 1}) || &HTMLdie("Unable to connect to database."); + my ($dbh); + if ( $db_driver eq "SQLite" ) { + $dbh = DBI->connect("DBI:$db_driver:$db_name_param=$bacula_working_dir/$database.db","","",{'RaiseError' => 1}) || &HTMLdie("Unable to connect to database."); + } + else { + $dbh = DBI->connect("DBI:$db_driver:$db_name_param=$database;host=$host","$user","$password",{'RaiseError' => 1}) || &HTMLdie("Unable to connect to database."); + } # get the MediaId for our volume my $sth = $dbh->prepare("SELECT MediaId from Media WHERE VolumeName = \"$vol\""); $sth->execute(); @@ -353,8 +367,15 @@ sub UpdateImageTable { my ($data,@MediaId,$id,$exists,$sth1,$sth2); # connect to database - my $dbh = DBI->connect("DBI:$db_driver:$db_name_param=$database;host=$host","$user","$password", + my ($dbh); + if ( $db_driver eq "SQLite" ) { + $dbh = DBI->connect("DBI:$db_driver:$db_name_param=$bacula_working_dir/$database.db","","", {'RaiseError' => 1}) || &HTMLdie("Unable to connect to database."); + } + else { + $dbh = DBI->connect("DBI:$db_driver:$db_name_param=$database;host=$host","$user","$password", + {'RaiseError' => 1}) || &HTMLdie("Unable to connect to database."); + } # get the list of current MediaId $sth1 = $dbh->prepare("SELECT MediaId from Media"); @@ -390,8 +411,15 @@ sub Reset { my ($id,$sth); # connect to database - my $dbh = DBI->connect("DBI:$db_driver:$db_name_param=$database;host=$host","$user","$password", + my ($dbh); + if ( $db_driver eq "SQLite" ) { + $dbh = DBI->connect("DBI:$db_driver:$db_name_param=$bacula_working_dir/$database.db","","", {'RaiseError' => 1}) || &HTMLdie("Unable to connect to database."); + } + else { + $dbh = DBI->connect("DBI:$db_driver:$db_name_param=$database;host=$host","$user","$password", + {'RaiseError' => 1}) || &HTMLdie("Unable to connect to database."); + } # get the MediaId $sth = $dbh->prepare("SELECT MediaId FROM Media WHERE VolumeName=\"$vol\""); diff --git a/gui/bimagemgr/config.pm b/gui/bimagemgr/config.pm index 5e5eb03132..3e0900f47e 100755 --- a/gui/bimagemgr/config.pm +++ b/gui/bimagemgr/config.pm @@ -71,6 +71,12 @@ sub new { # $self->{db_driver} = "Pg"; # $self->{db_name_param} = "dbname"; # $self->{catalog_dump} = "pg_dump --host=$self->{'host'} --username=$self->{'user'} --password=$self->{'password'} $self->{'database'}"; + # SQLite + $self->{sqlitebindir} = "/usr/lib/bacula/sqlite"; + $self->{bacula_working_dir} = "/var/bacula"; + # $self->{db_driver} = "SQLite"; + # $self->{db_name_param} = "dbname"; + # $self->{catalog_dump} = "echo \".dump\" | $self->{'sqlitebindir'}/sqlite $self->{'bacula_working_dir'}/$self->{'database'}.db"; ## # path to backup files