From: Eric Bollengier Date: Wed, 30 Aug 2023 07:42:18 +0000 (+0200) Subject: Update PriorJob and PriorJobId in db_update_job_start_record() X-Git-Tag: Beta-15.0.0~126 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dd4d95a8456adfef626742fe298ac8979a842c54;p=thirdparty%2Fbacula.git Update PriorJob and PriorJobId in db_update_job_start_record() --- diff --git a/bacula/src/cats/sql_update.c b/bacula/src/cats/sql_update.c index 2b7f1d5ac..602912703 100644 --- a/bacula/src/cats/sql_update.c +++ b/bacula/src/cats/sql_update.c @@ -93,6 +93,7 @@ bool BDB::bdb_update_job_start_record(JCR *jcr, JOB_DBR *jr) btime_t JobTDate; int stat; char ed1[50], ed2[50], ed3[50], ed4[50], ed5[50]; + char PriorJobId[50]; stime = jr->StartTime; (void)localtime_r(&stime, &tm); @@ -105,12 +106,19 @@ bool BDB::bdb_update_job_start_record(JCR *jcr, JOB_DBR *jr) if (!is_name_valid(jr->LastReadDevice, NULL)) { *jr->LastReadDevice = 0; // Not valid, not used } - + + if (jr->PriorJobId) { + bstrncpy(PriorJobId, edit_int64(jr->PriorJobId, ed1), sizeof(PriorJobId)); + } else { + bstrncpy(PriorJobId, "0", sizeof(PriorJobId)); + } + bdb_lock(); Mmsg(cmd, "UPDATE Job SET JobStatus='%c',Level='%c',StartTime='%s'," "ClientId=%s,JobTDate=%s,PoolId=%s,FileSetId=%s,RealStartTime='%s'," "isVirtualFull=%d,LastReadStorageId=%d,LastReadDevice='%s'," - "WriteStorageId=%d,WriteDevice='%s',StatusInfo='%s',Encrypted=%d WHERE JobId=%s", + "WriteStorageId=%d,WriteDevice='%s',StatusInfo='%s',Encrypted=%d,PriorJobId=%s,PriorJob='%s' " + "WHERE JobId=%s", (char)(jcr->JobStatus), (char)(jr->JobLevel), dt, edit_int64(jr->ClientId, ed1), @@ -125,6 +133,8 @@ bool BDB::bdb_update_job_start_record(JCR *jcr, JOB_DBR *jr) jr->WriteDevice, jr->StatusInfo, jr->Encrypted, + PriorJobId, + jr->PriorJob, edit_int64(jr->JobId, ed5)); stat = UpdateDB(jcr, cmd, false); @@ -174,13 +184,6 @@ int BDB::bdb_update_job_end_record(JCR *jcr, JOB_DBR *jr) int stat; char ed1[30], ed2[30], ed3[50], ed4[50], ed5[50], ed6[50]; btime_t JobTDate; - char PriorJobId[50]; - - if (jr->PriorJobId) { - bstrncpy(PriorJobId, edit_int64(jr->PriorJobId, ed1), sizeof(PriorJobId)); - } else { - bstrncpy(PriorJobId, "0", sizeof(PriorJobId)); - } ttime = jr->EndTime; (void)localtime_r(&ttime, &tm); @@ -203,14 +206,14 @@ int BDB::bdb_update_job_end_record(JCR *jcr, JOB_DBR *jr) "UPDATE Job SET JobStatus='%c',EndTime='%s'," "ClientId=%u,JobBytes=%s,ReadBytes=%s,JobFiles=%u,JobErrors=%u,VolSessionId=%u," "VolSessionTime=%u,PoolId=%u,FileSetId=%u,JobTDate=%s," -"RealEndTime='%s',PriorJobId=%s,HasBase=%u,PurgedFiles=%u,PriorJob='%s'," +"RealEndTime='%s',HasBase=%u,PurgedFiles=%u," "Rate=%.1f,CompressRatio=%.1f,WriteStorageId=%s,LastReadStorageId=%s,StatusInfo='%s'," "LastReadDevice='%s',WriteDevice='%s',Encrypted=%d WHERE JobId=%s", (char)(jr->JobStatus), dt, jr->ClientId, edit_uint64(jr->JobBytes, ed1), edit_uint64(jr->ReadBytes, ed4), jr->JobFiles, jr->JobErrors, jr->VolSessionId, jr->VolSessionTime, jr->PoolId, jr->FileSetId, edit_uint64(JobTDate, ed2), - rdt, PriorJobId, jr->HasBase, jr->PurgedFiles, jr->PriorJob, + rdt, jr->HasBase, jr->PurgedFiles, jr->Rate, jr->CompressRatio, edit_uint64(jr->WriteStorageId, ed5), edit_uint64(jr->LastReadStorageId, ed6), esc1, esc2, esc3, jr->Encrypted, diff --git a/bacula/src/dird/mac.c b/bacula/src/dird/mac.c index c47c65dd6..a4a317b99 100644 --- a/bacula/src/dird/mac.c +++ b/bacula/src/dird/mac.c @@ -638,6 +638,12 @@ bool do_mac(JCR *jcr) wjcr->jr.JobTDate = wjcr->start_time; wjcr->setJobStatus(JS_Running); + wjcr->jr.PriorJobId = jcr->previous_jr.JobId; + if (jcr->previous_jr.PriorJob[0]) { + bstrncpy(wjcr->jr.PriorJob, jcr->previous_jr.PriorJob, sizeof(wjcr->jr.PriorJob)); + } else { + bstrncpy(wjcr->jr.PriorJob, jcr->previous_jr.Job, sizeof(wjcr->jr.PriorJob)); + } /* Update job start record for the real mac backup job */ if (!db_update_job_start_record(wjcr, wjcr->db, &wjcr->jr)) { @@ -812,12 +818,6 @@ void mac_cleanup(JCR *jcr, int TermCode, int writeTermCode) wjcr->JobFiles = jcr->JobFiles = wjcr->SDJobFiles; wjcr->JobBytes = jcr->JobBytes = wjcr->SDJobBytes; wjcr->jr.RealEndTime = 0; - wjcr->jr.PriorJobId = jcr->previous_jr.JobId; - if (jcr->previous_jr.PriorJob[0]) { - bstrncpy(wjcr->jr.PriorJob, jcr->previous_jr.PriorJob, sizeof(wjcr->jr.PriorJob)); - } else { - bstrncpy(wjcr->jr.PriorJob, jcr->previous_jr.Job, sizeof(wjcr->jr.PriorJob)); - } wjcr->JobErrors += wjcr->SDErrors; update_job_end(wjcr, TermCode);