]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/2.4.3-migrate2.patch
ebl Update for scratchpool-pool-test
[bacula/bacula] / bacula / patches / 2.4.3-migrate2.patch
1
2  This patch should fix two bugs: 
3  - Bug #1206 -- sql error when there are no files to migrate. 
4  - Bug #1171 -- Job catalog log is not migrated during migration.
5
6  Apply it to a fully patched (requires two previous migration patches)
7  2.4.3 version  with:
8
9  cd <bacula-source>
10  patch -p0 <2.4.3-migrate2.patch
11  ./configure <your-options>
12  make
13  ...
14  make install
15
16
17 Index: src/dird/migrate.c
18 ===================================================================
19 --- src/dird/migrate.c  (revision 8152)
20 +++ src/dird/migrate.c  (working copy)
21 @@ -122,6 +122,12 @@
22  
23     Dmsg2(dbglevel, "Read pool=%s (From %s)\n", jcr->rpool->name(), jcr->rpool_source);
24  
25 +   if (!get_or_create_fileset_record(jcr)) {
26 +      Dmsg1(dbglevel, "JobId=%d no FileSet\n", (int)jcr->JobId);
27 +      Jmsg(jcr, M_FATAL, 0, _("Could not get or create the FileSet record.\n"));
28 +      return false;
29 +   }
30 +
31     /* If we find a job or jobs to migrate it is previous_jr.JobId */
32     count = get_job_to_migrate(jcr);
33     if (count < 0) {
34 @@ -139,12 +145,6 @@
35        return true;                    /* no work */
36     }
37  
38 -   if (!get_or_create_fileset_record(jcr)) {
39 -      Dmsg1(dbglevel, "JobId=%d no FileSet\n", (int)jcr->JobId);
40 -      Jmsg(jcr, M_FATAL, 0, _("Could not get or create the FileSet record.\n"));
41 -      return false;
42 -   }
43 -
44     create_restore_bootstrap_file(jcr);
45  
46     if (jcr->previous_jr.JobId == 0 || jcr->ExpectedFiles == 0) {
47 @@ -1062,6 +1062,11 @@
48      *  mig_jcr is jcr of the newly migrated job.
49      */
50     if (mig_jcr) {
51 +      char old_jobid[50], new_jobid[50];
52 +
53 +      edit_uint64(jcr->previous_jr.JobId, old_jobid);
54 +      edit_uint64(mig_jcr->jr.JobId, new_jobid);
55 +
56        mig_jcr->JobFiles = jcr->JobFiles = jcr->SDJobFiles;
57        mig_jcr->JobBytes = jcr->JobBytes = jcr->SDJobBytes;
58        mig_jcr->VolSessionId = jcr->VolSessionId;
59 @@ -1076,7 +1081,7 @@
60                    "JobTDate=%s WHERE JobId=%s", 
61           jcr->previous_jr.cStartTime, jcr->previous_jr.cEndTime, 
62           edit_uint64(jcr->previous_jr.JobTDate, ec1),
63 -         edit_uint64(mig_jcr->jr.JobId, ec2));
64 +         new_jobid);
65        db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL);
66  
67        /*
68 @@ -1086,15 +1091,13 @@
69         *   - Purge the File records from the previous job
70         */
71        if (jcr->JobType == JT_MIGRATE && jcr->JobStatus == JS_Terminated) {
72 -         char old_jobid[50], new_jobid[50];
73           Mmsg(query, "UPDATE Job SET Type='%c' WHERE JobId=%s",
74 -              (char)JT_MIGRATED_JOB, edit_uint64(jcr->previous_jr.JobId, new_jobid));
75 +              (char)JT_MIGRATED_JOB, old_jobid);
76           db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL);
77           UAContext *ua = new_ua_context(jcr);
78           /* Move JobLog to new JobId */
79           Mmsg(query, "UPDATE Log SET JobId=%s WHERE JobId=%s",
80 -           new_jobid,
81 -           edit_uint64(jcr->previous_jr.JobId, old_jobid));
82 +           new_jobid, old_jobid);
83           db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL);
84           /* Purge all old file records, but leave Job record */
85           purge_files_from_jobs(ua, old_jobid);