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.
6 Apply it to a fully patched (requires two previous migration patches)
10 patch -p0 <2.4.3-migrate2.patch
11 ./configure <your-options>
17 Index: src/dird/migrate.c
18 ===================================================================
19 --- src/dird/migrate.c (revision 8152)
20 +++ src/dird/migrate.c (working copy)
23 Dmsg2(dbglevel, "Read pool=%s (From %s)\n", jcr->rpool->name(), jcr->rpool_source);
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"));
31 /* If we find a job or jobs to migrate it is previous_jr.JobId */
32 count = get_job_to_migrate(jcr);
35 return true; /* no work */
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"));
44 create_restore_bootstrap_file(jcr);
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.
51 + char old_jobid[50], new_jobid[50];
53 + edit_uint64(jcr->previous_jr.JobId, old_jobid);
54 + edit_uint64(mig_jcr->jr.JobId, new_jobid);
56 mig_jcr->JobFiles = jcr->JobFiles = jcr->SDJobFiles;
57 mig_jcr->JobBytes = jcr->JobBytes = jcr->SDJobBytes;
58 mig_jcr->VolSessionId = jcr->VolSessionId;
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));
65 db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL);
68 @@ -1086,15 +1091,13 @@
69 * - Purge the File records from the previous job
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",
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);