]> git.sur5r.net Git - bacula/bacula/commitdiff
Add SQLite support.
authorScott Barninger <scott@barninger.com>
Sun, 14 May 2006 15:33:35 +0000 (15:33 +0000)
committerScott Barninger <scott@barninger.com>
Sun, 14 May 2006 15:33:35 +0000 (15:33 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3021 91ce42f0-d328-0410-95d8-f526ca767f89

gui/bimagemgr/ChangeLog
gui/bimagemgr/README
gui/bimagemgr/ReleaseNotes
gui/bimagemgr/bimagemgr.pl
gui/bimagemgr/config.pm

index 2e988681fec1efa5bdeb35d6b5f9bb1236183839..007972ea5aa1df423e607b3c5d12d40a5fab8924 100644 (file)
@@ -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
+
 
index af682ee9c13fd95bb90aa960c1a2fbcc439ff528..aee131b9afcf6533943033a42207fb5cc895c244 100644 (file)
@@ -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 
index 5249aea088f1b04e180dad44565075dad309d839..7cd1d1bcf1c5fe99b39414d0c0c6580c31859f45 100644 (file)
@@ -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.
index a22103eebf702a2f2a5236776bbe50a6eb1d5fee..5384c681c94e7c68cb9e7b399f196e32b6466ff8 100755 (executable)
@@ -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\"");
index 5e5eb03132710c1c51d4d692f818cb588f27f3bc..3e0900f47e6991a6c2b20dd05b6337927eeb044d 100755 (executable)
@@ -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