On 5/19/21 1:08 PM, Bill Damage via Bacula-users wrote:
> [root@tiger bacula]# ./update_mysql_tables
> 
> 
> This script will update a Bacula MySQL database
>  from any from version 12-15 or 1014-1021 to version 1022
>  which is needed to convert from any Bacula Enterprise
>  version 4.0.x or later to version 12.4.x
>  or Bacula Community versions 5.0.x, 5.2.x, 7.4.x, 9.x.x to
>  Community version 11.0
> 
> 
> Depending on the current version of your catalog, you may
>  have to run this script multiple times
> 
> 
> ERROR 1091 (42000) at line 9: Can't DROP INDEX `JobId`; check that it exists
> Update of Bacula MySQL tables from 16 to 1017 failed.
> [root@tiger bacula]#


There is what I would argue is an error in the latest
update_mysql_tables script.  The error has two side-effects:

1.  The update fails if either index JobId or JobId_2 does not exist
(and there's no point to them both existing, because they are redundant);

2.  Once failed, the update cannot be restarted.


This patch allows the script to be restarted if it fails, AND allows it
to continue if one of the two indexes it tries to drop is missing.



--- update_mysql_tables.orig    2021-05-19 12:54:15.226740443 -0400
+++ update_mysql_tables 2021-05-19 12:54:53.833949117 -0400
@@ -161,14 +161,14 @@
 ALTER TABLE RestoreObject
    MODIFY FileIndex INTEGER UNSIGNED DEFAULT 0;
 ALTER TABLE BaseFiles
    MODIFY FileIndex INTEGER UNSIGNED DEFAULT 0;

-DROP INDEX JobId on File;
-DROP INDEX JobId_2 on File;
+DROP INDEX IF EXISTS JobId on File;
+DROP INDEX IF EXISTS JobId_2 on File;

-CREATE TABLE file_temp (
+CREATE TABLE IF NOT EXISTS file_temp (
    FileId BIGINT UNSIGNED NOT NULL,
    FileIndex INTEGER DEFAULT 0,
    JobId INTEGER UNSIGNED NOT NULL,
    PathId INTEGER UNSIGNED NOT NULL,
    Filename BLOB NOT NULL,
@@ -176,10 +176,12 @@
    MarkId INTEGER UNSIGNED DEFAULT 0,
    LStat TINYBLOB NOT NULL,
    MD5 TINYBLOB
    );

+TRUNCATE TABLE file_temp;
+
 INSERT INTO file_temp (FileId, FileIndex, JobId, PathId, Filename,
DeltaSeq,
                       MarkId, LStat, Md5)
    SELECT FileId, FileIndex, JobId, PathId, Filename.Name, DeltaSeq,
          MarkId, LStat, Md5
     FROM File JOIN Filename USING (FilenameId);





-- 
  Phil Stracchino
  Babylon Communications
  ph...@caerllewys.net
  p...@co.ordinate.org
  Landline: +1.603.293.8485
  Mobile:   +1.603.998.6958


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

Reply via email to