bool PreferMountedVols; /* Prefer mounted vols rather than new */
bool Resched; /* Job may be rescheduled */
bool bscan_insert_jobmedia_records; /*Bscan: needs to insert job media records */
+ bool bscan_created; /* Flag for bscan to know if this jcr was created by it or not */
bool sd_client; /* Set if acting as client */
bool use_new_match_all; /* TODO: Remove when the match_bsr() will be well tested */
break;
}
- ro.JobId = mjcr->JobId;
-
- if (db_get_restoreobject_record(mjcr, db, &ro)) {
- if (verbose) {
- Pmsg1(0, _("RESTORE_OBJECT: Found Restore Object \"%s\" in the catalog\n"), ro.object_name);
- }
- } else if (update_db) {
- /* Send it */
- Pmsg1(0, _("RESTORE_OBJECT: Inserting Restore Object \"%s\" into the catalog\n"), ro.object_name);
- if (!db_create_restore_object_record(mjcr, db, &ro)) {
- Jmsg1(mjcr, M_FATAL, 0, _("Restore object create error. %s"), db_strerror(db));
+ if (mjcr->bscan_created) {
+ // bscan created this job record so we need to recreate objects as well
+ if (update_db) {
+ /* Send it */
+ Pmsg1(0, _("RESTORE_OBJECT: Inserting Restore Object \"%s\" into the catalog\n"), ro.object_name);
+ // Create record with updated jobid
+ ro.JobId = mjcr->JobId;
+ if (!db_create_restore_object_record(mjcr, db, &ro)) {
+ Jmsg1(mjcr, M_FATAL, 0, _("Restore object create error. %s"), db_strerror(db));
+ }
}
} else {
Pmsg1(0, _("RESTORE_OBJECT: Found Restore Object \"%s\" on the volume\n"), ro.object_name);
}
+ mjcr->dec_use_count(); /* Decrease reference counter increased by get_jcr_by_session call */
break;
}
Pmsg2(000, _("Created new JobId=%u record for original JobId=%u\n"), jr->JobId,
label->JobId);
mjcr->JobId = jr->JobId; /* set new JobId */
+ mjcr->bscan_created = true;
return mjcr;
}