From: Eric Bollengier Date: Fri, 12 Aug 2022 12:56:04 +0000 (+0200) Subject: Add SQL code to update Job::Encrypted field X-Git-Tag: Beta-15.0.0~455 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e31cda33d00eeeb57dd297397ed33d4732c49357;p=thirdparty%2Fbacula.git Add SQL code to update Job::Encrypted field --- diff --git a/bacula/src/cats/cats.h b/bacula/src/cats/cats.h index 4204c72dd..6de2842a9 100644 --- a/bacula/src/cats/cats.h +++ b/bacula/src/cats/cats.h @@ -158,6 +158,7 @@ struct JOB_DBR { double CompressRatio; DBId_t WriteStorageId; DBId_t LastReadStorageId; + int Encrypted; /* Note, FirstIndex, LastIndex, Start/End File and Block * are only used in the JobMedia record. diff --git a/bacula/src/cats/sql_get.c b/bacula/src/cats/sql_get.c index a6d9b1bf2..fa3243152 100644 --- a/bacula/src/cats/sql_get.c +++ b/bacula/src/cats/sql_get.c @@ -256,7 +256,8 @@ bool BDB::bdb_get_job_record(JCR *jcr, JOB_DBR *jr) Mmsg(cmd, "SELECT VolSessionId,VolSessionTime," "PoolId,StartTime,EndTime,JobFiles,JobBytes,JobTDate,Job,JobStatus," "Type,Level,ClientId,Job.Name,PriorJobId,RealEndTime,JobId,FileSetId," -"SchedTime,RealStartTime,ReadBytes,HasBase,PurgedFiles,PriorJob,Comment,Reviewed,Client.Name AS Client,isVirtualFull,WriteStorageId,LastReadstorageId " +"SchedTime,RealStartTime,ReadBytes,HasBase,PurgedFiles,PriorJob,Comment," +"Reviewed,Client.Name AS Client, isVirtualFull,WriteStorageId,LastReadstorageId,StatusInfo,LastReadDevice,WriteDevice,Encrypted " "FROM Job WHERE Job='%s'", esc); } else if (jr->PriorJob[0]) { @@ -264,7 +265,8 @@ bool BDB::bdb_get_job_record(JCR *jcr, JOB_DBR *jr) Mmsg(cmd, "SELECT VolSessionId,VolSessionTime," "PoolId,StartTime,EndTime,JobFiles,JobBytes,JobTDate,Job,JobStatus," "Type,Level,ClientId,Name,PriorJobId,RealEndTime,JobId,FileSetId," -"SchedTime,RealStartTime,ReadBytes,HasBase,PurgedFiles,PriorJob,Comment,Reviewed,Client.Name AS Client,isVirtualFull,WriteStorageId,LastReadstorageId " +"SchedTime,RealStartTime,ReadBytes,HasBase,PurgedFiles,PriorJob,Comment," +"Reviewed,Client.Name AS Client,isVirtualFull,WriteStorageId,LastReadstorageId,StatusInfo,LastReadDevice,WriteDevice,Encrypted " "FROM Job WHERE PriorJob='%s' ORDER BY Type ASC LIMIT 1", esc); } else { Mmsg0(errmsg, _("No Job found\n")); @@ -280,8 +282,8 @@ bool BDB::bdb_get_job_record(JCR *jcr, JOB_DBR *jr) "Type,Level,ClientId,Name,PriorJobId,RealEndTime,JobId,FileSetId," // 18 19 20 21 22 23 24 25 26 "SchedTime,RealStartTime,ReadBytes,HasBase,PurgedFiles,PriorJob,Comment,Reviewed,Client.Name AS Client," -// 27 28 29 30 31 32 -"isVirtualFull,WriteStorageId,LastReadStorageId,StatusInfo,LastReadDevice,WriteDevice " +// 27 28 29 30 31 32 33 +"isVirtualFull,WriteStorageId,LastReadStorageId,StatusInfo,LastReadDevice,WriteDevice,Encrypted " "FROM Job WHERE JobId=%s", edit_int64(jr->JobId, ed1)); } @@ -344,6 +346,7 @@ bool BDB::bdb_get_job_record(JCR *jcr, JOB_DBR *jr) bstrncpy(jr->StatusInfo, NPRTB(row[30]), sizeof(jr->StatusInfo)); bstrncpy(jr->LastReadDevice, NPRTB(row[31]), sizeof(jr->LastReadDevice)); bstrncpy(jr->WriteDevice, NPRTB(row[32]), sizeof(jr->WriteDevice)); + jr->Encrypted = str_to_int64(row[33]); sql_free_result(); bdb_unlock(); diff --git a/bacula/src/cats/sql_update.c b/bacula/src/cats/sql_update.c index fa6ccc5fd..6acdd271b 100644 --- a/bacula/src/cats/sql_update.c +++ b/bacula/src/cats/sql_update.c @@ -188,7 +188,8 @@ int BDB::bdb_update_job_end_record(JCR *jcr, JOB_DBR *jr) "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'," -"Rate=%.1f,CompressRatio=%.1f,WriteStorageId=%s,LastReadStorageId=%s,StatusInfo='%s',LastReadDevice='%s',WriteDevice='%s' WHERE JobId=%s", +"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, @@ -196,6 +197,7 @@ int BDB::bdb_update_job_end_record(JCR *jcr, JOB_DBR *jr) rdt, PriorJobId, jr->HasBase, jr->PurgedFiles, jr->PriorJob, jr->Rate, jr->CompressRatio, edit_uint64(jr->WriteStorageId, ed5), edit_uint64(jr->LastReadStorageId, ed6), esc1, esc2, esc3, + jr->Encrypted, edit_int64(jr->JobId, ed3)); stat = UpdateDB(jcr, cmd, false); diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index 033a0e230..f9142c799 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -1458,6 +1458,7 @@ void update_job_end_record(JCR *jcr) jcr->jr.VolSessionTime = jcr->VolSessionTime; jcr->jr.JobErrors = jcr->JobErrors + jcr->SDErrors; jcr->jr.HasBase = jcr->HasBase; + jcr->jr.Encrypted = jcr->Encrypt; /* Update when the SD can encrypt as well */ bstrncpy(jcr->jr.StatusInfo, jcr->StatusInfo, sizeof(jcr->jr.StatusInfo)); STORE *wstore = wjcr->store_mngr->get_wstore();