From: Kern Sibbald Date: Tue, 15 Jul 2008 06:47:33 +0000 (+0000) Subject: Changes to get read storage correct for Virtual Backup. X-Git-Tag: Release-3.0.0~1146 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=cc8896a3a60b484b5638c2d313ec14c6eb812fc7;p=bacula%2Fbacula Changes to get read storage correct for Virtual Backup. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7383 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index 87b07a6087..73cdf0fa06 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -65,6 +65,9 @@ static char OldEndJob[] = "2800 End Job TermCode=%d JobFiles=%u " bool do_backup_init(JCR *jcr) { + if (jcr->JobLevel == L_VIRTUAL_FULL) { + return do_vbackup_init(jcr); + } free_rstorage(jcr); /* we don't read so release */ if (!get_or_create_fileset_record(jcr)) { @@ -129,7 +132,7 @@ bool send_accurate_current_files(JCR *jcr) { POOL_MEM buf; - if (jcr->accurate==false || job_canceled(jcr) || jcr->JobLevel==L_FULL) { + if (!jcr->accurate || job_canceled(jcr) || jcr->JobLevel==L_FULL) { return true; } POOLMEM *jobids = get_pool_memory(PM_FNAME); @@ -175,6 +178,9 @@ bool do_backup(JCR *jcr) STORE *store; char ed1[100]; + if (jcr->JobLevel == L_VIRTUAL_FULL) { + return do_vbackup(jcr); + } /* Print Job Start message */ Jmsg(jcr, M_INFO, 0, _("Start Backup JobId %s, Job=%s\n"), @@ -429,6 +435,10 @@ void backup_cleanup(JCR *jcr, int TermCode) double kbps, compression; utime_t RunTime; + if (jcr->JobLevel == L_VIRTUAL_FULL) { + vbackup_cleanup(jcr, TermCode); + } + Dmsg2(100, "Enter backup_cleanup %d %c\n", TermCode, TermCode); memset(&mr, 0, sizeof(mr)); memset(&cr, 0, sizeof(cr)); diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 7e08768a6e..828aa38cdb 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -456,6 +456,7 @@ struct s_jl joblevels[] = { {"Incremental", L_INCREMENTAL, JT_BACKUP}, {"Differential", L_DIFFERENTIAL, JT_BACKUP}, {"Since", L_SINCE, JT_BACKUP}, + {"VirtualFull", L_VIRTUAL_FULL, JT_BACKUP}, {"Catalog", L_VERIFY_CATALOG, JT_VERIFY}, {"InitCatalog", L_VERIFY_INIT, JT_VERIFY}, {"VolumeToCatalog", L_VERIFY_VOLUME_TO_CATALOG, JT_VERIFY}, diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index 536b4d0a5b..b0251cd16f 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -112,6 +112,7 @@ bool setup_job(JCR *jcr) if ((errstat = pthread_cond_init(&jcr->term_wait, NULL)) != 0) { berrno be; Jmsg1(jcr, M_FATAL, 0, _("Unable to init job cond variable: ERR=%s\n"), be.bstrerror(errstat)); + jcr->unlock(); goto bail_out; } jcr->term_wait_inited = true; @@ -148,6 +149,7 @@ bool setup_job(JCR *jcr) pm_strcpy(jcr->pool_source, _("unknown source")); } Dmsg2(500, "pool=%s (From %s)\n", jcr->pool->name(), jcr->pool_source); + /* ****FIXME**** */ if (jcr->JobType == JT_MIGRATE || jcr->JobType == JT_COPY) { if (!jcr->rpool_source) { jcr->rpool_source = get_pool_memory(PM_MESSAGE); @@ -1050,20 +1052,31 @@ void set_jcr_defaults(JCR *jcr, JOB *job) jcr->JobStatus = JS_Created; switch (jcr->JobType) { case JT_ADMIN: - case JT_RESTORE: jcr->JobLevel = L_NONE; break; + case JT_VERIFY: + case JT_RESTORE: case JT_COPY: case JT_MIGRATE: - if (!jcr->rpool_source) { - jcr->rpool_source = get_pool_memory(PM_MESSAGE); - pm_strcpy(jcr->rpool_source, _("unknown source")); + jcr->JobReads = true; + jcr->JobLevel = job->JobLevel; + break; + case JT_BACKUP: + jcr->JobLevel = job->JobLevel; + if (jcr->JobLevel == L_VIRTUAL_FULL) { + jcr->JobReads = true; } - /* Fall-through wanted */ + break; default: jcr->JobLevel = job->JobLevel; break; } + if (jcr->JobReads) { + if (!jcr->rpool_source) { + jcr->rpool_source = get_pool_memory(PM_MESSAGE); + pm_strcpy(jcr->rpool_source, _("unknown source")); + } + } if (!jcr->fname) { jcr->fname = get_pool_memory(PM_FNAME); } @@ -1141,16 +1154,10 @@ void set_jcr_defaults(JCR *jcr, JOB *job) */ void copy_rwstorage(JCR *jcr, alist *storage, const char *where) { - switch(jcr->JobType) { - case JT_RESTORE: - case JT_VERIFY: - case JT_COPY: - case JT_MIGRATE: + if (jcr->JobReads) { copy_rstorage(jcr, storage, where); - break; - default: + } else { copy_wstorage(jcr, storage, where); - break; } } @@ -1162,16 +1169,10 @@ void set_rwstorage(JCR *jcr, USTORE *store) Jmsg(jcr, M_FATAL, 0, _("No storage specified.\n")); return; } - switch(jcr->JobType) { - case JT_RESTORE: - case JT_VERIFY: - case JT_COPY: - case JT_MIGRATE: + if (jcr->JobReads) { set_rstorage(jcr, store); - break; - default: + } else { set_wstorage(jcr, store); - break; } } diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index a886f1d956..5fbb09ab9e 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -1120,7 +1120,7 @@ static int estimate_cmd(UAContext *ua, const char *cmd) } if (strcasecmp(ua->argk[i], NT_("level")) == 0) { if (!get_level_from_name(ua->jcr, ua->argv[i])) { - ua->error_msg(_("Level %s not valid.\n"), ua->argv[i]); + ua->error_msg(_("Level \"%s\" not valid.\n"), ua->argv[i]); } continue; } diff --git a/bacula/src/dird/ua_run.c b/bacula/src/dird/ua_run.c index c2ac7e981d..97b3590e19 100644 --- a/bacula/src/dird/ua_run.c +++ b/bacula/src/dird/ua_run.c @@ -528,7 +528,7 @@ static bool reset_restore_context(UAContext *ua, JCR *jcr, run_ctx &rc) } if (rc.level_name) { if (!get_level_from_name(jcr, rc.level_name)) { - ua->send_msg(_("Level %s not valid.\n"), rc.level_name); + ua->send_msg(_("Level \"%s\" not valid.\n"), rc.level_name); return false; } rc.level_name = NULL; @@ -683,6 +683,7 @@ static void select_job_level(UAContext *ua, JCR *jcr) add_prompt(ua, _("Incremental")); add_prompt(ua, _("Differential")); add_prompt(ua, _("Since")); + add_prompt(ua, _("VirtualFull")); switch (do_prompt(ua, "", _("Select level"), NULL, 0)) { case 0: jcr->JobLevel = L_BASE; @@ -699,6 +700,9 @@ static void select_job_level(UAContext *ua, JCR *jcr) case 4: jcr->JobLevel = L_SINCE; break; + case 5: + jcr->JobLevel = L_VIRTUAL_FULL; + break; default: break; } diff --git a/bacula/src/dird/vbackup.c b/bacula/src/dird/vbackup.c index 4368042547..4548a27bc5 100644 --- a/bacula/src/dird/vbackup.c +++ b/bacula/src/dird/vbackup.c @@ -140,24 +140,11 @@ bool do_vbackup(JCR *jcr) { char ed1[100]; BSOCK *sd; - JCR *mig_jcr = jcr->mig_jcr; /* newly backed up job */ - - /* - * If mig_jcr is NULL, there is nothing to do for this job, - * so set a normal status, cleanup and return OK. - */ - if (!mig_jcr) { - set_jcr_job_status(jcr, JS_Terminated); - vbackup_cleanup(jcr, jcr->JobStatus); - return true; - } /* Print Job Start message */ Jmsg(jcr, M_INFO, 0, _("Start Vbackup JobId %s, Job=%s\n"), edit_uint64(jcr->JobId, ed1), jcr->Job); - - /* * Open a message channel connection with the Storage * daemon. This is to let him know that our client @@ -166,7 +153,6 @@ bool do_vbackup(JCR *jcr) */ Dmsg0(110, "Open connection with storage daemon\n"); set_jcr_job_status(jcr, JS_WaitSD); - set_jcr_job_status(mig_jcr, JS_WaitSD); /* * Start conversation with Storage daemon */ @@ -177,7 +163,7 @@ bool do_vbackup(JCR *jcr) /* * Now start a job with the Storage daemon */ - Dmsg2(dbglevel, "Read store=%s, write store=%s\n", + Dmsg2(000, "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()) { @@ -216,23 +202,6 @@ bool do_vbackup(JCR *jcr) return false; } - - mig_jcr->start_time = time(NULL); - mig_jcr->jr.StartTime = mig_jcr->start_time; - mig_jcr->jr.JobTDate = mig_jcr->start_time; - set_jcr_job_status(mig_jcr, JS_Running); - - /* Update job start record for the real migration backup job */ - if (!db_update_job_start_record(mig_jcr, mig_jcr->db, &mig_jcr->jr)) { - Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(mig_jcr->db)); - return false; - } - - Dmsg4(dbglevel, "mig_jcr: Name=%s JobId=%d Type=%c Level=%c\n", - mig_jcr->jr.Name, (int)mig_jcr->jr.JobId, - mig_jcr->jr.JobType, mig_jcr->jr.JobLevel); - - /* * Start the job prior to starting the message thread below * to avoid two threads from using the BSOCK structure at @@ -251,7 +220,6 @@ bool do_vbackup(JCR *jcr) set_jcr_job_status(jcr, JS_Running); - set_jcr_job_status(mig_jcr, JS_Running); /* Pickup Job termination data */ /* Note, the SD stores in jcr->JobFiles/ReadBytes/JobBytes/Errors */ @@ -263,14 +231,6 @@ bool do_vbackup(JCR *jcr) } vbackup_cleanup(jcr, jcr->JobStatus); - if (mig_jcr) { - char jobid[50]; - UAContext *ua = new_ua_context(jcr); - edit_uint64(jcr->previous_jr.JobId, jobid); - /* Purge all old file records, but leave Job record */ - purge_files_from_jobs(ua, jobid); - free_ua_context(ua); - } return true; } diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index 75db3edd39..9db54c3b65 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -52,6 +52,7 @@ #define L_VERIFY_DATA 'A' /* verify data on volume */ #define L_BASE 'B' /* Base level job */ #define L_NONE ' ' /* None, for Restore and Admin */ +#define L_VIRTUAL_FULL 'f' /* Virtual full backup */ /* Job Types. These are stored in the DB */ @@ -201,6 +202,7 @@ public: int32_t JobType; /* backup, restore, verify ... */ int32_t JobLevel; /* Job level */ int32_t JobPriority; /* Job priority */ + bool JobReads; /* Set if job reads Volumes */ time_t sched_time; /* job schedule time, i.e. when it should start */ time_t start_time; /* when job actually started */ time_t run_time; /* used for computing speed */ diff --git a/bacula/src/version.h b/bacula/src/version.h index 86b24b3943..957e99062c 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.5.2" -#define BDATE "14 July 2008" -#define LSMDATE "14Jul08" +#define BDATE "15 July 2008" +#define LSMDATE "15Jul08" #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n" #define BYEAR "2008" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index 21158967a4..dfa94b14a4 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -30,6 +30,8 @@ vtape driver General: +15Jul08 +kes Changes to get read storage correct for Virtual Backup. 14Jul08 kes Remove old code from label.c kes Split display_display_info() out of write_bsr_file()