]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix copy/migration job selection
authorEric Bollengier <eric@baculasystems.com>
Wed, 3 Feb 2021 15:37:37 +0000 (16:37 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 4 Feb 2021 14:53:35 +0000 (15:53 +0100)
Description:
-----------

The Copy/Migration job selection with a Job name was selecting
Jobs that are already migrated. It is leading to a situation where
a new catalog record is created for the new job, but the job is not
used at the end. JobFiles=0 JobBytes=0.

In some conditions, the accurate code selects the incorrect job
record.

In the catalog, both Job records have the same attributes
(same JobTDate, same StartTime). So the selection process
was returning one or the other depending on the weather cast.

We no longer try to copy/migrate a job that is not a valid
Backup job, and we check that the Job status is T.

bacula/src/dird/mac.c
bacula/src/dird/mac_sql.c

index b043359f1814be559bf0e5e9725b0bdbfd80d4c4..072b12a7287a6b311d645ca60ccd1e2a28a02f8d 100644 (file)
@@ -377,7 +377,7 @@ bool do_mac(JCR *jcr)
            jcr->get_ActionName(0),
            db_strerror(jcr->db));
       jcr->setJobStatus(JS_Terminated);
-      mac_cleanup(jcr, JS_Terminated, JS_Terminated);
+      mac_cleanup(jcr, JS_Canceled, JS_Canceled);
       return true;
    }
    /* Make sure this job was not already migrated */
@@ -388,7 +388,7 @@ bool do_mac(JCR *jcr)
          jcr->get_ActionName(1),
          jcr->get_OperationName());
       jcr->setJobStatus(JS_Terminated);
-      mac_cleanup(jcr, JS_Terminated, JS_Terminated);
+      mac_cleanup(jcr, JS_Canceled, JS_Canceled);
       return true;
    }
 
index 466558546b717c66342802d42a1fe2ba8db5a3a9..976189854ef45670e2decb1ef2658da048ec8e8f 100644 (file)
@@ -72,7 +72,8 @@ static const char *sql_job =
 /* Get JobIds from regex'ed Job names */
 static const char *sql_jobids_from_job =
    "SELECT DISTINCT Job.JobId,Job.StartTime FROM Job,Pool"
-   " WHERE Job.Name='%s' AND Pool.Name='%s' AND Job.PoolId=Pool.PoolId"
+   " WHERE Job.Name='%s' AND Pool.Name='%s' AND Job.Type IN ('B','C') "
+   " AND Job.JobStatus IN ('T','W') AND Job.PoolId=Pool.PoolId "
    " ORDER by Job.StartTime";
 
 /* Get Client names in Pool */