From: Eric Bollengier Date: Wed, 3 Feb 2021 15:37:37 +0000 (+0100) Subject: Fix copy/migration job selection X-Git-Tag: Release-11.0.1~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c79970929dc00265c8a097009e44d8416199c106;p=thirdparty%2Fbacula.git Fix copy/migration job selection 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. --- diff --git a/bacula/src/dird/mac.c b/bacula/src/dird/mac.c index b043359f1..072b12a72 100644 --- a/bacula/src/dird/mac.c +++ b/bacula/src/dird/mac.c @@ -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; } diff --git a/bacula/src/dird/mac_sql.c b/bacula/src/dird/mac_sql.c index 466558546..976189854 100644 --- a/bacula/src/dird/mac_sql.c +++ b/bacula/src/dird/mac_sql.c @@ -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 */