1 Index: src/dird/migrate.c
2 ===================================================================
3 --- src/dird/migrate.c (revision 7926)
4 +++ src/dird/migrate.c (working copy)
8 migration_cleanup(jcr, jcr->JobStatus);
11 - UAContext *ua = new_ua_context(jcr);
12 - edit_uint64(jcr->previous_jr.JobId, jobid);
13 - /* Purge all old file records, but leave Job record */
14 - purge_files_from_jobs(ua, jobid);
15 - free_ua_context(ua);
20 @@ -1087,11 +1079,26 @@
21 edit_uint64(mig_jcr->jr.JobId, ec2));
22 db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL);
24 - /* Now mark the previous job as migrated if it terminated normally */
25 - if (jcr->JobStatus == JS_Terminated) {
27 + * If we terminated a migration normally:
28 + * - mark the previous job as migrated
29 + * - move any Log records to the new JobId
30 + * - Purge the File records from the previous job
32 + if (jcr->JobType == JT_MIGRATE && jcr->JobStatus == JS_Terminated) {
33 + char old_jobid[50], new_jobid[50];
34 Mmsg(query, "UPDATE Job SET Type='%c' WHERE JobId=%s",
35 - (char)JT_MIGRATED_JOB, edit_uint64(jcr->previous_jr.JobId, ec1));
36 + (char)JT_MIGRATED_JOB, edit_uint64(jcr->previous_jr.JobId, new_jobid));
37 db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL);
38 + UAContext *ua = new_ua_context(jcr);
39 + /* Move JobLog to new JobId */
40 + Mmsg(query, "UPDATE Log SET JobId=%s WHERE JobId=%s",
42 + edit_uint64(jcr->previous_jr.JobId, old_jobid));
43 + db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL);
44 + /* Purge all old file records, but leave Job record */
45 + purge_files_from_jobs(ua, old_jobid);
46 + free_ua_context(ua);
49 if (!db_get_job_record(jcr, jcr->db, &jcr->jr)) {
51 set_jcr_job_status(jcr, JS_ErrorTerminated);
55 update_bootstrap_file(mig_jcr);
57 if (!db_get_job_volume_names(mig_jcr, mig_jcr->db, mig_jcr->jr.JobId, &mig_jcr->VolumeName)) {