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:

  <mailto:da...@icewatermedia.com> da...@icewatermedia.com
lgdavidmurphy  

 

<<image001.jpg>>

------------------------------------------------------------------------------
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to