From: Eric Bollengier Date: Thu, 25 Nov 2010 14:49:45 +0000 (+0100) Subject: Add PurgeMigrateJob Job resource option to purge job on successful migration X-Git-Tag: Release-7.0.0~1336 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b7a4f3720475fba2751141238ffcb2ff078e0858;p=bacula%2Fbacula Add PurgeMigrateJob Job resource option to purge job on successful migration Submited by Blake Dunlap work. --- diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index a82289878c..2440f2e969 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -311,6 +311,7 @@ RES_ITEM job_items[] = { {"prunejobs", store_bool, ITEM(res_job.PruneJobs), 0, ITEM_DEFAULT, false}, {"prunefiles", store_bool, ITEM(res_job.PruneFiles), 0, ITEM_DEFAULT, false}, {"prunevolumes",store_bool, ITEM(res_job.PruneVolumes), 0, ITEM_DEFAULT, false}, + {"purgemigratejob", store_bool, ITEM(res_job.PurgeMigrateJob), 0, ITEM_DEFAULT, false}, {"enabled", store_bool, ITEM(res_job.enabled), 0, ITEM_DEFAULT, true}, {"spoolattributes",store_bool, ITEM(res_job.SpoolAttributes), 0, ITEM_DEFAULT, false}, {"spooldata", store_bool, ITEM(res_job.spool_data), 0, ITEM_DEFAULT, false}, diff --git a/bacula/src/dird/dird_conf.h b/bacula/src/dird/dird_conf.h index 48bb7703d5..1c5154012e 100644 --- a/bacula/src/dird/dird_conf.h +++ b/bacula/src/dird/dird_conf.h @@ -436,6 +436,8 @@ public: bool CancelLowerLevelDuplicates; /* Cancel lower level backup jobs */ bool CancelQueuedDuplicates; /* Cancel queued jobs */ bool CancelRunningDuplicates; /* Cancel Running jobs */ + bool PurgeMigrateJob; /* Purges source job on completion */ + alist *base; /* Base jobs */ /* Methods */ diff --git a/bacula/src/dird/migrate.c b/bacula/src/dird/migrate.c index 357250b334..2104b4deb2 100644 --- a/bacula/src/dird/migrate.c +++ b/bacula/src/dird/migrate.c @@ -1179,8 +1179,15 @@ void migration_cleanup(JCR *jcr, int TermCode) Mmsg(query, "UPDATE Log SET JobId=%s WHERE JobId=%s", 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); + + if (jcr->job->PurgeMigrateJob) { + /* Purge old Job record */ + purge_jobs_from_catalog(ua, old_jobid); + } else { + /* Purge all old file records, but leave Job record */ + purge_files_from_jobs(ua, old_jobid); + } + free_ua_context(ua); }