]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Add SQL code to update Job::Encrypted field
authorEric Bollengier <eric@baculasystems.com>
Fri, 12 Aug 2022 12:56:04 +0000 (14:56 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:56:59 +0000 (13:56 +0200)
bacula/src/cats/cats.h
bacula/src/cats/sql_get.c
bacula/src/cats/sql_update.c
bacula/src/dird/job.c

index 4204c72dde21b45152b7f2b0d517c28e5ec75f9b..6de2842a9d7a701e65edfddae6b1627127277b0f 100644 (file)
@@ -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.
index a6d9b1bf24440907b14b219ec65c0c44697186c8..fa3243152a56e986e30b0120959ba31f4f34b1f3 100644 (file)
@@ -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();
index fa6ccc5fd0cc5397a8f3d7bcb6679f56a231a8be..6acdd271b294cd5c394cbd3b8b2ca582b8e61988 100644 (file)
@@ -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);
index 033a0e2302c9e23268c5d7b54f765fe916843cf6..f9142c79985e1e04072d14f795f4127abe87219e 100644 (file)
@@ -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();