/*
- Bacula® - The Network Backup Solution
-
- Copyright (C) 2000-2007 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
- License as published by the Free Software Foundation and included
- in the file LICENSE.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- 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
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
- Bacula® is a registered trademark of Kern Sibbald.
- The licensor of Bacula is the Free Software Foundation Europe
- (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
- Switzerland, email:ftf@fsfeurope.org.
+ Bacula(R) - The Network Backup Solution
+
+ Copyright (C) 2000-2015 Kern Sibbald
+
+ The original author of Bacula is Kern Sibbald, with contributions
+ from many others, a complete list can be found in the file AUTHORS.
+
+ You may use this file and others of this release according to the
+ license defined in the LICENSE file, which includes the Affero General
+ Public License, v3.0 ("AGPLv3") and some additional permissions and
+ terms pursuant to its AGPLv3 Section 7.
+
+ This notice must be preserved when any source code is
+ conveyed and/or propagated.
+
+ Bacula(R) is a registered trademark of Kern Sibbald.
*/
/*
*
*
* Kern Sibbald, May MM, major revision December MMIII
*
- * Version $Id$
*/
#include "bacula.h"
#define DBGLVL 0
#else
#undef SCHED_DEBUG
-#define DBGLVL 200
+#define DBGLVL DT_SCHEDULER|200
#endif
const int dbglvl = DBGLVL;
/* Imported variables */
-/**
+/*
* called by reload_config to tell us that the schedules
* we may have based our next jobs to run queues have been
* invalidated. In fact the schedules may not have changed
* on are new and no longer have a valid last_run time which
* causes us to double run schedules that get put into the list
* because run_nh = 1.
- */
+ */
static bool schedules_invalidated = false;
void invalidate_schedules(void) {
schedules_invalidated = true;
time_t twait;
/** discard scheduled queue and rebuild with new schedule objects. **/
lock_jobs();
- if (schedules_invalidated) {
+ if (schedules_invalidated) {
dump_job(next_job, "Invalidated job");
free(next_job);
while (!jobs_to_run->empty()) {
jcr = new_jcr(sizeof(JCR), dird_free_jcr);
run = next_job->run; /* pick up needed values */
job = next_job->job;
- if (job->enabled) {
- dump_job(next_job, _("Run job"));
+ if (job->enabled && (!job->client || job->client->enabled)) {
+ dump_job(next_job, _("Run job")); /* no client and job enabled */
}
free(next_job);
- if (!job->enabled) {
+ if (!job->enabled || (job->client && !job->client->enabled)) {
free_jcr(jcr);
goto again; /* ignore this job */
}
ASSERT(job);
set_jcr_defaults(jcr, job);
if (run->level) {
- jcr->JobLevel = run->level; /* override run level */
+ jcr->setJobLevel(run->level); /* override run level */
}
if (run->pool) {
jcr->pool = run->pool; /* override pool */
jcr->run_pool_override = true;
}
+ if (run->next_pool) {
+ jcr->next_pool = run->next_pool; /* override next pool */
+ jcr->run_next_pool_override = true;
+ }
if (run->full_pool) {
jcr->full_pool = run->full_pool; /* override full pool */
jcr->run_full_pool_override = true;
}
+ if (run->vfull_pool) {
+ jcr->vfull_pool = run->vfull_pool; /* override virtual full pool */
+ jcr->run_vfull_pool_override = true;
+ }
if (run->inc_pool) {
jcr->inc_pool = run->inc_pool; /* override inc pool */
jcr->run_inc_pool_override = true;
if (run->spool_data_set) {
jcr->spool_data = run->spool_data;
}
+ if (run->accurate_set) { /* overwrite accurate mode */
+ jcr->accurate = run->accurate;
+ }
if (run->write_part_after_job_set) {
jcr->write_part_after_job = run->write_part_after_job;
}
+ if (run->MaxRunSchedTime_set) {
+ jcr->MaxRunSchedTime = run->MaxRunSchedTime;
+ }
Dmsg0(dbglvl, "Leave wait_for_next_job()\n");
return jcr;
}
JOB *job;
SCHED *sched;
struct tm tm;
- int minute;
- int hour, mday, wday, month, wom, woy;
+ int hour, mday, wday, month, wom, woy, ldom;
/* Items corresponding to above at the next hour */
- int nh_hour, nh_mday, nh_wday, nh_month, nh_wom, nh_woy, nh_year;
+ int nh_hour, nh_mday, nh_wday, nh_month, nh_wom, nh_woy, nh_ldom;
Dmsg0(dbglvl, "enter find_runs()\n");
-
/* compute values for time now */
now = time(NULL);
(void)localtime_r(&now, &tm);
hour = tm.tm_hour;
- minute = tm.tm_min;
mday = tm.tm_mday - 1;
wday = tm.tm_wday;
month = tm.tm_mon;
wom = mday / 7;
woy = tm_woy(now); /* get week of year */
+ ldom = tm_ldom(month, tm.tm_year + 1900);
Dmsg7(dbglvl, "now = %x: h=%d m=%d md=%d wd=%d wom=%d woy=%d\n",
now, hour, month, mday, wday, wom, woy);
nh_mday = tm.tm_mday - 1;
nh_wday = tm.tm_wday;
nh_month = tm.tm_mon;
- nh_year = tm.tm_year;
nh_wom = nh_mday / 7;
- nh_woy = tm_woy(now); /* get week of year */
+ nh_woy = tm_woy(next_hour); /* get week of year */
+ nh_ldom = tm_ldom(nh_month, tm.tm_year + 1900);
Dmsg7(dbglvl, "nh = %x: h=%d m=%d md=%d wd=%d wom=%d woy=%d\n",
next_hour, nh_hour, nh_month, nh_mday, nh_wday, nh_wom, nh_woy);
LockRes();
foreach_res(job, R_JOB) {
sched = job->schedule;
- if (sched == NULL || !job->enabled) { /* scheduled? or enabled? */
+ if (!sched || !job->enabled || (sched && !sched->enabled) ||
+ (job->client && !job->client->enabled)) {
continue; /* no, skip this job */
}
Dmsg1(dbglvl, "Got job: %s\n", job->hdr.name);
*/
#ifdef xxxx
Dmsg0(000, "\n");
- Dmsg6(000, "run h=%d m=%d md=%d wd=%d wom=%d woy=%d\n",
- hour, month, mday, wday, wom, woy);
- Dmsg6(000, "bitset bsh=%d bsm=%d bsmd=%d bswd=%d bswom=%d bswoy=%d\n",
+ Dmsg7(000, "run h=%d m=%d md=%d wd=%d wom=%d woy=%d ldom=%d\n",
+ hour, month, mday, wday, wom, woy, ldom);
+ Dmsg7(000, "bitset bsh=%d bsm=%d bsmd=%d bswd=%d bswom=%d bswoy=%d bsldom=%d\n",
bit_is_set(hour, run->hour),
bit_is_set(month, run->month),
bit_is_set(mday, run->mday),
bit_is_set(wday, run->wday),
bit_is_set(wom, run->wom),
- bit_is_set(woy, run->woy));
+ bit_is_set(woy, run->woy),
+ bit_is_set(31, run->mday));
+
- Dmsg6(000, "nh_run h=%d m=%d md=%d wd=%d wom=%d woy=%d\n",
- nh_hour, nh_month, nh_mday, nh_wday, nh_wom, nh_woy);
- Dmsg6(000, "nh_bitset bsh=%d bsm=%d bsmd=%d bswd=%d bswom=%d bswoy=%d\n",
+ Dmsg7(000, "nh_run h=%d m=%d md=%d wd=%d wom=%d woy=%d ldom=%d\n",
+ nh_hour, nh_month, nh_mday, nh_wday, nh_wom, nh_woy, nh_ldom);
+ Dmsg7(000, "nh_bitset bsh=%d bsm=%d bsmd=%d bswd=%d bswom=%d bswoy=%d bsldom=%d\n",
bit_is_set(nh_hour, run->hour),
bit_is_set(nh_month, run->month),
bit_is_set(nh_mday, run->mday),
bit_is_set(nh_wday, run->wday),
bit_is_set(nh_wom, run->wom),
- bit_is_set(nh_woy, run->woy));
+ bit_is_set(nh_woy, run->woy),
+ bit_is_set(31, run->mday));
#endif
run_now = bit_is_set(hour, run->hour) &&
- bit_is_set(mday, run->mday) &&
- bit_is_set(wday, run->wday) &&
- bit_is_set(month, run->month) &&
- bit_is_set(wom, run->wom) &&
- bit_is_set(woy, run->woy);
+ ((bit_is_set(mday, run->mday) &&
+ bit_is_set(wday, run->wday) &&
+ bit_is_set(month, run->month) &&
+ bit_is_set(wom, run->wom) &&
+ bit_is_set(woy, run->woy)) ||
+ (bit_is_set(month, run->month) &&
+ bit_is_set(31, run->mday) && mday == ldom));
run_nh = bit_is_set(nh_hour, run->hour) &&
- bit_is_set(nh_mday, run->mday) &&
- bit_is_set(nh_wday, run->wday) &&
- bit_is_set(nh_month, run->month) &&
- bit_is_set(nh_wom, run->wom) &&
- bit_is_set(nh_woy, run->woy);
+ ((bit_is_set(nh_mday, run->mday) &&
+ bit_is_set(nh_wday, run->wday) &&
+ bit_is_set(nh_month, run->month) &&
+ bit_is_set(nh_wom, run->wom) &&
+ bit_is_set(nh_woy, run->woy)) ||
+ (bit_is_set(nh_month, run->month) &&
+ bit_is_set(31, run->mday) && nh_mday == nh_ldom));
Dmsg3(dbglvl, "run@%p: run_now=%d run_nh=%d\n", run, run_now, run_nh);
*/
if (((runtime - run->last_run) < 61) || ((runtime+59) < now)) {
#ifdef SCHED_DEBUG
- char dt[50], dt1[50], dt2[50];
- bstrftime_nc(dt, sizeof(dt), runtime);
- bstrftime_nc(dt1, sizeof(dt1), run->last_run);
- bstrftime_nc(dt2, sizeof(dt2), now);
- Dmsg7(000, "Drop: Job=\"%s\" run=%s(%x). last_run=%s(%x). now=%s(%x)\n", job->hdr.name,
- dt, runtime, dt1, run->last_run, dt2, now);
+ Dmsg4(000, "Drop: Job=\"%s\" run=%lld. last_run=%lld. now=%lld\n", job->hdr.name,
+ (utime_t)runtime, (utime_t)run->last_run, (utime_t)now);
fflush(stdout);
#endif
return;
}
#ifdef SCHED_DEBUG
- Dmsg4(000, "Add: Job=\"%s\" run=%x last_run=%x now=%x\n", job->hdr.name,
- runtime, run->last_run, now);
+ Dmsg4(000, "Add: Job=\"%s\" run=%lld last_run=%lld now=%lld\n", job->hdr.name,
+ (utime_t)runtime, (utime_t)run->last_run, (utime_t)now);
#endif
/* accept to run this job */
job_item *je = (job_item *)malloc(sizeof(job_item));
{
#ifdef SCHED_DEBUG
char dt[MAX_TIME_LENGTH];
- int save_debug = debug_level;
- if (debug_level < dbglvl) {
+ int64_t save_debug = debug_level;
+
+ if (!chk_dbglvl(dbglvl)) {
return;
}
bstrftime_nc(dt, sizeof(dt), ji->runtime);
- Dmsg4(dbglvl, "%s: Job=%s priority=%d run %s\n", msg, ji->job->hdr.name,
+ Dmsg4(dbglvl, "%s: Job=%s priority=%d run %s\n", msg, ji->job->hdr.name,
ji->Priority, dt);
fflush(stdout);
debug_level = save_debug;