]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Take PluginObjects into account when copying a job
authorMichal Rakowski <michal.rakowski@baculasystems.com>
Mon, 11 Jan 2021 11:01:19 +0000 (12:01 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:02:59 +0000 (09:02 +0100)
bacula/src/dird/mac.c

index 45d3e0616e4e3242a104c48860db5ef3e43389cd..ab067ccc682bf810e320c20c0e1cd960b30927e7 100644 (file)
@@ -742,6 +742,11 @@ void mac_cleanup(JCR *jcr, int TermCode, int writeTermCode)
            new_jobid, old_jobid);
          db_sql_query(wjcr->db, query.c_str(), NULL, NULL);
 
+         /* Move PluginObjects */
+         Mmsg(query, "UPDATE PluginObject SET JobId=%s WHERE JobId=%s",
+           new_jobid, old_jobid);
+         db_sql_query(wjcr->db, query.c_str(), NULL, NULL);
+
          if (jcr->job->PurgeMigrateJob) {
             /* Purge old Job record */
             purge_jobs_from_catalog(ua, old_jobid);
@@ -779,6 +784,17 @@ void mac_cleanup(JCR *jcr, int TermCode, int writeTermCode)
           "ObjectCompression,FileIndex,%s FROM RestoreObject WHERE JobId=%s",
            new_jobid, old_jobid);
          db_sql_query(wjcr->db, query.c_str(), NULL, NULL);
+
+         /* Copy PluginObjects */
+         Mmsg(query, "INSERT INTO PluginObject (JobId, Path, Filename, PluginName, ObjectCategory,"
+              "ObjectType, ObjectName, ObjectSource, ObjectUUID, ObjectSize) "
+        "SELECT %s, Path, Filename, PluginName, ObjectCategory,"
+              "ObjectType, ObjectName, ObjectSource, ObjectUUID, ObjectSize FROM PluginObject WHERE JobId=%s",
+           new_jobid, old_jobid);
+
+         if (!db_sql_query(wjcr->db, query.c_str(), NULL, NULL)) {
+            Jmsg(jcr, M_WARNING, 0, _("Error copying PluginObject for JobId=%ld"), old_jobid);
+         }
       }
 
       if (!db_get_job_record(jcr, jcr->db, &jcr->jr)) {