Bacula-users

[Bacula-users] StorageID not being set correctly in 2.4.2

2009-04-01 16:16:40
Subject: [Bacula-users] StorageID not being set correctly in 2.4.2
From: "David Murphy" <david AT icewatermedia DOT com>
To: <Bacula-users AT lists.sourceforge DOT net>
Date: Wed, 1 Apr 2009 15:08:23 -0500

I am running 2.4.2 on  Ubuntu and  we use multiple  Storage Devices (per host).

Recently we noticed any time you try to restore a job

 

Bacula  would  see  Stroage “”  not  Storage “<hostname>”, this was due to a bug in the mysql insert query that was causing StorageId to be “0” not the relivant id. 

 

As our jobs  always  are set to create a volume each time and label  with “<hostname>-<Year>-<Month>-<Day>-<HOUR>-<Minute>-<Second>”, I wrote the following Mysql trigger that other may find usefull.

 

 

delimiter |

 

CREATE TRIGGER FixStorageID BEFORE INSERT ON Media

  FOR EACH ROW BEGIN

    SET

                NEW.StorageId =

                                (Select

                                                StorageID from Storage where Name =

                                                                (SELECT

                                                                                SUBSTR(

                                                                                NEW.VolumeName,1,LOCATE(

                                                                                                                                '-',NEW.VolumeName)

                                                                                -1)

                                                                )

                                );

  END;

|

 

delimiter ;

 

I have  broken it out into  tabs above for readability here is a condenses version if the  spacing get upset by the  mailing list.

 

delimiter |

CREATE TRIGGER FixStorageID BEFORE INSERT ON Media

FOR EACH ROW BEGIN

SET NEW.StorageId = (Select StorageID from Storage where Name = (SELECT     SUBSTR(NEW.VolumeName,1,LOCATE('-',NEW.VolumeName)    -1)));

END;

|

delimiter ;

 

Hope this helps other who may have similar issue.

 

 David Murphy          Systems Adminsitrator

myLogo

 Email:                                           AIM:

 david AT icewatermedia DOT com         lgdavidmurphy  

 

------------------------------------------------------------------------------
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users
<Prev in Thread] Current Thread [Next in Thread>
  • [Bacula-users] StorageID not being set correctly in 2.4.2, David Murphy <=