]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/2.4.3-migrate-log.patch
Fix bat.pro.in so that bat will install.
[bacula/bacula] / bacula / patches / 2.4.3-migrate-log.patch
1
2  This patch should cause all Job Log records to be migrated when the
3  Job is migrated. It fixes the second issue reported in bug #1171.
4
5  Apply it to Bacula 2.4.3 (possibly earlier versions)
6  with:
7
8  cd <bacula-source>
9  patch -p0 <2.4.3-migrate.patch
10  ./configure <your-options>
11  make
12  ...
13  make install
14
15 Index: src/dird/migrate.c
16 ===================================================================
17 --- src/dird/migrate.c  (revision 7926)
18 +++ src/dird/migrate.c  (working copy)
19 @@ -402,14 +402,6 @@
20     }
21  
22     migration_cleanup(jcr, jcr->JobStatus);
23 -   if (mig_jcr) {
24 -      char jobid[50];
25 -      UAContext *ua = new_ua_context(jcr);
26 -      edit_uint64(jcr->previous_jr.JobId, jobid);
27 -      /* Purge all old file records, but leave Job record */
28 -      purge_files_from_jobs(ua, jobid);
29 -      free_ua_context(ua);
30 -   }
31     return true;
32  }
33  
34 @@ -1087,11 +1079,26 @@
35           edit_uint64(mig_jcr->jr.JobId, ec2));
36        db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL);
37  
38 -      /* Now mark the previous job as migrated if it terminated normally */
39 -      if (jcr->JobStatus == JS_Terminated) {
40 +      /*
41 +       * If we terminated a migration normally:
42 +       *   - mark the previous job as migrated
43 +       *   - move any Log records to the new JobId
44 +       *   - Purge the File records from the previous job
45 +       */
46 +      if (jcr->JobType == JT_MIGRATE && jcr->JobStatus == JS_Terminated) {
47 +         char old_jobid[50], new_jobid[50];
48           Mmsg(query, "UPDATE Job SET Type='%c' WHERE JobId=%s",
49 -              (char)JT_MIGRATED_JOB, edit_uint64(jcr->previous_jr.JobId, ec1));
50 +              (char)JT_MIGRATED_JOB, edit_uint64(jcr->previous_jr.JobId, new_jobid));
51           db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL);
52 +         UAContext *ua = new_ua_context(jcr);
53 +         /* Move JobLog to new JobId */
54 +         Mmsg(query, "UPDATE Log SET JobId=%s WHERE JobId=%s",
55 +           new_jobid,
56 +           edit_uint64(jcr->previous_jr.JobId, old_jobid));
57 +         db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL);
58 +         /* Purge all old file records, but leave Job record */
59 +         purge_files_from_jobs(ua, old_jobid);
60 +         free_ua_context(ua);
61        } 
62  
63        if (!db_get_job_record(jcr, jcr->db, &jcr->jr)) {
64 @@ -1100,7 +1107,6 @@
65           set_jcr_job_status(jcr, JS_ErrorTerminated);
66        }
67  
68 -
69        update_bootstrap_file(mig_jcr);
70  
71        if (!db_get_job_volume_names(mig_jcr, mig_jcr->db, mig_jcr->jr.JobId, &mig_jcr->VolumeName)) {