]> git.sur5r.net Git - bacula/bacula/commitdiff
Commit migrate2 patch
authorKern Sibbald <kern@sibbald.com>
Sun, 14 Dec 2008 20:22:49 +0000 (20:22 +0000)
committerKern Sibbald <kern@sibbald.com>
Sun, 14 Dec 2008 20:22:49 +0000 (20:22 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8158 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/patches/2.4.3-migrate2.patch [new file with mode: 0644]

diff --git a/bacula/patches/2.4.3-migrate2.patch b/bacula/patches/2.4.3-migrate2.patch
new file mode 100644 (file)
index 0000000..9d37e8c
--- /dev/null
@@ -0,0 +1,85 @@
+
+ This patch should fix two bugs: 
+ - Bug #1206 -- sql error when there are no files to migrate. 
+ - Bug #1171 -- Job catalog log is not migrated during migration.
+
+ Apply it to a fully patched (requires two previous migration patches)
+ 2.4.3 version  with:
+
+ cd <bacula-source>
+ patch -p0 <2.4.3-migrate2.patch
+ ./configure <your-options>
+ make
+ ...
+ make install
+
+
+Index: src/dird/migrate.c
+===================================================================
+--- src/dird/migrate.c (revision 8152)
++++ src/dird/migrate.c (working copy)
+@@ -122,6 +122,12 @@
+    Dmsg2(dbglevel, "Read pool=%s (From %s)\n", jcr->rpool->name(), jcr->rpool_source);
++   if (!get_or_create_fileset_record(jcr)) {
++      Dmsg1(dbglevel, "JobId=%d no FileSet\n", (int)jcr->JobId);
++      Jmsg(jcr, M_FATAL, 0, _("Could not get or create the FileSet record.\n"));
++      return false;
++   }
++
+    /* If we find a job or jobs to migrate it is previous_jr.JobId */
+    count = get_job_to_migrate(jcr);
+    if (count < 0) {
+@@ -139,12 +145,6 @@
+       return true;                    /* no work */
+    }
+-   if (!get_or_create_fileset_record(jcr)) {
+-      Dmsg1(dbglevel, "JobId=%d no FileSet\n", (int)jcr->JobId);
+-      Jmsg(jcr, M_FATAL, 0, _("Could not get or create the FileSet record.\n"));
+-      return false;
+-   }
+-
+    create_restore_bootstrap_file(jcr);
+    if (jcr->previous_jr.JobId == 0 || jcr->ExpectedFiles == 0) {
+@@ -1062,6 +1062,11 @@
+     *  mig_jcr is jcr of the newly migrated job.
+     */
+    if (mig_jcr) {
++      char old_jobid[50], new_jobid[50];
++
++      edit_uint64(jcr->previous_jr.JobId, old_jobid);
++      edit_uint64(mig_jcr->jr.JobId, new_jobid);
++
+       mig_jcr->JobFiles = jcr->JobFiles = jcr->SDJobFiles;
+       mig_jcr->JobBytes = jcr->JobBytes = jcr->SDJobBytes;
+       mig_jcr->VolSessionId = jcr->VolSessionId;
+@@ -1076,7 +1081,7 @@
+                   "JobTDate=%s WHERE JobId=%s", 
+          jcr->previous_jr.cStartTime, jcr->previous_jr.cEndTime, 
+          edit_uint64(jcr->previous_jr.JobTDate, ec1),
+-         edit_uint64(mig_jcr->jr.JobId, ec2));
++         new_jobid);
+       db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL);
+       /*
+@@ -1086,15 +1091,13 @@
+        *   - Purge the File records from the previous job
+        */
+       if (jcr->JobType == JT_MIGRATE && jcr->JobStatus == JS_Terminated) {
+-         char old_jobid[50], new_jobid[50];
+          Mmsg(query, "UPDATE Job SET Type='%c' WHERE JobId=%s",
+-              (char)JT_MIGRATED_JOB, edit_uint64(jcr->previous_jr.JobId, new_jobid));
++              (char)JT_MIGRATED_JOB, old_jobid);
+          db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL);
+          UAContext *ua = new_ua_context(jcr);
+          /* Move JobLog to new JobId */
+          Mmsg(query, "UPDATE Log SET JobId=%s WHERE JobId=%s",
+-           new_jobid,
+-           edit_uint64(jcr->previous_jr.JobId, old_jobid));
++           new_jobid, old_jobid);
+          db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL);
+          /* Purge all old file records, but leave Job record */
+          purge_files_from_jobs(ua, old_jobid);