X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fdird%2Fmigrate.c;h=357250b3348bd826814674f494d8bae965cdf0a8;hb=04d2e746550ef971dcbd3253026b1c97979f3bbe;hp=2ffadb76fc04d502d81d4f33dfee6d96960b9ed8;hpb=51f54360499bd4bcb9ac9fb63adda2f4fd02d40d;p=bacula%2Fbacula diff --git a/bacula/src/dird/migrate.c b/bacula/src/dird/migrate.c index 2ffadb76fc..357250b334 100644 --- a/bacula/src/dird/migrate.c +++ b/bacula/src/dird/migrate.c @@ -1,12 +1,12 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2004-2009 Free Software Foundation Europe e.V. + Copyright (C) 2004-2010 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. This program is Free Software; you can redistribute it and/or - modify it under the terms of version two of the GNU General Public + modify it under the terms of version three of the GNU Affero General Public License as published by the Free Software Foundation and included in the file LICENSE. @@ -15,7 +15,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Affero General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -41,7 +41,6 @@ * to do the backup. * When the Storage daemon finishes the job, update the DB. * - * Version $Id$ */ #include "bacula.h" @@ -55,7 +54,7 @@ static const int dbglevel = 10; -static int get_job_to_migrate(JCR *jcr); +static int getJob_to_migrate(JCR *jcr); struct idpkt; static bool regex_find_jobids(JCR *jcr, idpkt *ids, const char *query1, const char *query2, const char *type); @@ -134,7 +133,7 @@ bool do_migration_init(JCR *jcr) } /* If we find a job or jobs to migrate it is previous_jr.JobId */ - count = get_job_to_migrate(jcr); + count = getJob_to_migrate(jcr); if (count < 0) { return false; } @@ -143,7 +142,7 @@ bool do_migration_init(JCR *jcr) return true; /* no work */ } - Dmsg1(dbglevel, "Back from get_job_to_migrate JobId=%d\n", (int)jcr->JobId); + Dmsg1(dbglevel, "Back from getJob_to_migrate JobId=%d\n", (int)jcr->JobId); if (jcr->previous_jr.JobId == 0) { Dmsg1(dbglevel, "JobId=%d no previous JobId\n", (int)jcr->JobId); @@ -317,7 +316,8 @@ bool do_migration(JCR *jcr) return true; } /* Make sure this job was not already migrated */ - if (jcr->previous_jr.JobType != JT_BACKUP) { + if (jcr->previous_jr.JobType != JT_BACKUP && + jcr->previous_jr.JobType != JT_JOB_COPY) { Jmsg(jcr, M_INFO, 0, _("JobId %s already %s probably by another Job. %s stopped.\n"), edit_int64(jcr->previous_jr.JobId, ed1), jcr->get_ActionName(1), @@ -353,11 +353,7 @@ bool do_migration(JCR *jcr) Dmsg2(dbglevel, "Read store=%s, write store=%s\n", ((STORE *)jcr->rstorage->first())->name(), ((STORE *)jcr->wstorage->first())->name()); - if (((STORE *)jcr->rstorage->first())->name() == ((STORE *)jcr->wstorage->first())->name()) { - Jmsg(jcr, M_FATAL, 0, _("Read storage \"%s\" same as write storage.\n"), - ((STORE *)jcr->rstorage->first())->name()); - return false; - } + if (!start_storage_daemon_job(jcr, jcr->rstorage, jcr->wstorage, /*send_bsr*/true)) { return false; } @@ -651,7 +647,7 @@ const char *sql_jobids_of_pool_uncopied_jobs = * 0 if no jobs to migrate * 1 if OK and jcr->previous_jr filled in */ -static int get_job_to_migrate(JCR *jcr) +static int getJob_to_migrate(JCR *jcr) { char ed1[30], ed2[30]; POOL_MEM query(PM_MESSAGE); @@ -855,7 +851,7 @@ static int get_job_to_migrate(JCR *jcr) for (int i=1; i < (int)ids.count; i++) { JobId = 0; stat = get_next_jobid_from_list(&p, &JobId); - Dmsg3(dbglevel, "get_jobid_no=%d stat=%d JobId=%u\n", i, stat, JobId); + Dmsg3(dbglevel, "getJobid_no=%d stat=%d JobId=%u\n", i, stat, JobId); if (stat < 0) { Jmsg(jcr, M_FATAL, 0, _("Invalid JobId found.\n")); goto bail_out; @@ -997,7 +993,7 @@ static bool find_jobids_of_pool_uncopied_jobs(JCR *jcr, idpkt *ids) POOL_MEM query(PM_MESSAGE); /* Only a copy job is allowed */ - if (jcr->get_JobType() != JT_COPY) { + if (jcr->getJobType() != JT_COPY) { Jmsg(jcr, M_FATAL, 0, _("Selection Type 'pooluncopiedjobs' only applies to Copy Jobs")); goto bail_out; @@ -1174,7 +1170,7 @@ void migration_cleanup(JCR *jcr, int TermCode) * - move any Log records to the new JobId * - Purge the File records from the previous job */ - if (jcr->get_JobType() == JT_MIGRATE && jcr->JobStatus == JS_Terminated) { + if (jcr->getJobType() == JT_MIGRATE && jcr->JobStatus == JS_Terminated) { Mmsg(query, "UPDATE Job SET Type='%c' WHERE JobId=%s", (char)JT_MIGRATED_JOB, old_jobid); db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL); @@ -1189,11 +1185,11 @@ void migration_cleanup(JCR *jcr, int TermCode) } /* - * If we terminated a copy normally: + * If we terminated a Copy (rather than a Migration) normally: * - copy any Log records to the new JobId * - set type="Job Copy" for the new job */ - if (jcr->get_JobType() == JT_COPY && jcr->JobStatus == JS_Terminated) { + if (jcr->getJobType() == JT_COPY && jcr->JobStatus == JS_Terminated) { /* Copy JobLog to new JobId */ Mmsg(query, "INSERT INTO Log (JobId, Time, LogText ) " "SELECT %s, Time, LogText FROM Log WHERE JobId=%s", @@ -1273,7 +1269,7 @@ void migration_cleanup(JCR *jcr, int TermCode) break; } } else { - if (jcr->get_JobType() == JT_MIGRATE && jcr->previous_jr.JobId != 0) { + if (jcr->getJobType() == JT_MIGRATE && jcr->previous_jr.JobId != 0) { /* Mark previous job as migrated */ Mmsg(query, "UPDATE Job SET Type='%c' WHERE JobId=%s", (char)JT_MIGRATED_JOB, edit_uint64(jcr->previous_jr.JobId, ec1)); @@ -1294,7 +1290,7 @@ void migration_cleanup(JCR *jcr, int TermCode) jobstatus_to_ascii(jcr->SDJobStatus, sd_term_msg, sizeof(sd_term_msg)); - Jmsg(jcr, msg_type, 0, _("%s %s %s (%s): %s\n" + Jmsg(jcr, msg_type, 0, _("%s %s %s (%s):\n" " Build OS: %s %s %s\n" " Prev Backup JobId: %s\n" " Prev Backup Job: %s\n" @@ -1323,14 +1319,14 @@ void migration_cleanup(JCR *jcr, int TermCode) " SD Errors: %d\n" " SD termination status: %s\n" " Termination: %s\n\n"), - BACULA, my_name, VERSION, LSMDATE, edt, + BACULA, my_name, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER, edit_uint64(jcr->previous_jr.JobId, ec6), jcr->previous_jr.Job, mig_jcr ? edit_uint64(mig_jcr->jr.JobId, ec7) : "0", edit_uint64(jcr->jr.JobId, ec8), jcr->jr.Job, - level_to_str(jcr->get_JobLevel()), jcr->since, + level_to_str(jcr->getJobLevel()), jcr->since, jcr->client->name(), jcr->fileset->name(), jcr->FSCreateTime, jcr->rpool->name(), jcr->rpool_source,