Kern Sibbald
General:
+22Jun06
+- Update some very old licenses in src/cats.
+- Modify the database format for handling Migration jobs:
+ Add PriorJobId, RealEndTime to Job table
+ Delete MAC table
+ Remove Stripe from JobMedia record (not used, wasting space)
+ Add ScratchPoolId, RecyclePoolId, Enabled to Media record
+ Add Cost to Location table.
+- Delete mac_record subroutines.
+- Add new table values to create/update/get routines as appropriate.
+- Update the update_tables and make_tables scripts.
+- Make a first cut in using a union where multiple pointers (actually
+ pointers to pointers) are stored.
+- Make some changes to base64.c suggested by Robert and others and add
+ a small amount of documentation.
+- Add some changes suggested by Peter for Solaris (bregex...)
+- Make runscript.h always built because it needs to be pulled into
+ more places. In particular its RES was left out of a union.
+- Renumber the enum{} list in runscript.h to avoid starting from zero.
+ This makes it slightly easier to detect uninitialized variables.
14Jun06
- Remove xpg4 lib from FreeBSD build as it is no longer needed and
sometimes creates install problems.
*
*/
/*
- Copyright (C) 2000-2005 Kern Sibbald
+ Copyright (C) 2000-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
*/
/*
- Copyright (C) 2001-2003 Kern Sibbald and John Walker
+ Copyright (C) 2001-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License
+ version 2 as amended with additional clauses defined in the
+ file LICENSE in the main source directory.
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., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ the file LICENSE for additional details.
*/
/* The following is necessary so that we do not include
* the dummy external definition of DB.
*/
-#define __SQL_C /* indicate that this is sql.c */
+#define __SQL_C /* indicate that this is sql.c */
#include "bacula.h"
#include "cats.h"
* it is updated in bdb_update.c when the Job terminates.
*
* Returns: 0 on failure
- * 1 on success
+ * 1 on success
*/
int db_create_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
{
/* Create a JobMedia record for Volume used this job
* Returns: 0 on failure
- * record-id on success
+ * record-id on success
*/
bool db_create_jobmedia_record(JCR *jcr, B_DB *mdb, JOBMEDIA_DBR *jm)
{
/*
* Create a unique Pool record
* Returns: 0 on failure
- * 1 on success
+ * 1 on success
*/
bool db_create_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
{
/*
- * Create Unique Media record. This record
+ * Create Unique Media record. This record
* contains all the data pertaining to a specific
* Volume.
*
* Returns: 0 on failure
- * 1 on success
+ * 1 on success
*/
int db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
{
/*
* Create a unique Client record or return existing record
* Returns: 0 on failure
- * 1 on success
+ * 1 on success
*/
int db_create_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr)
{
* Note, here we write the FILESET_DBR structure
*
* Returns: 0 on failure
- * 1 on success
+ * 1 on success
*/
bool db_create_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr)
{
*/
/*
- Copyright (C) 2001-2003 Kern Sibbald and John Walker
+ Copyright (C) 2001-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License
+ version 2 as amended with additional clauses defined in the
+ file LICENSE in the main source directory.
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., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ the file LICENSE for additional details.
*/
/* The following is necessary so that we do not include
* the dummy external definition of DB.
*/
-#define __SQL_C /* indicate that this is sql.c */
+#define __SQL_C /* indicate that this is sql.c */
#include "bacula.h"
#include "cats.h"
* Delete a Pool record given the Name
*
* Returns: 0 on error
- * the number of records deleted on success
+ * the number of records deleted on success
*/
int db_delete_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
{
POOL_DBR opr;
db_lock(mdb);
- pr->PoolId = 0; /* Search on Pool Name */
+ pr->PoolId = 0; /* Search on Pool Name */
if (!db_get_pool_record(jcr, mdb, pr)) {
Mmsg1(&mdb->errmsg, "No pool record %s exists\n", pr->Name);
db_unlock(mdb);
*
* Version $Id$
*/
-
/*
- Copyright (C) 2001-2003 Kern Sibbald and John Walker
+ Copyright (C) 2001-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License
+ version 2 as amended with additional clauses defined in the
+ file LICENSE in the main source directory.
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., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ the file LICENSE for additional details.
*/
*
* Version $Id$
*/
-
/*
- Copyright (C) 2001-2003 Kern Sibbald and John Walker
+ Copyright (C) 2001-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License
+ version 2 as amended with additional clauses defined in the
+ file LICENSE in the main source directory.
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., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ the file LICENSE for additional details.
*/
*/
/*
- Copyright (C) 2001-2003 Kern Sibbald and John Walker
+ Copyright (C) 2001-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License
+ version 2 as amended with additional clauses defined in the
+ file LICENSE in the main source directory.
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., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ the file LICENSE for additional details.
*/
/* The following is necessary so that we do not include
* the dummy external definition of DB.
*/
-#define __SQL_C /* indicate that this is sql.c */
+#define __SQL_C /* indicate that this is sql.c */
#include "bacula.h"
#include "cats.h"
* Submit general SQL query
*/
int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit,
- void *ctx, int verbose)
+ void *ctx, int verbose)
{
sendit(ctx, "SQL Queries not implemented with internal database.\n");
return 0;
fseek(mdb->poolfd, 0L, SEEK_SET); /* rewind file */
len = sizeof(pr);
while (fread(&pr, len, 1, mdb->poolfd) > 0) {
- Mmsg(mdb->cmd, " %7d %6d %6d %-10s %s\n",
- pr.PoolId, pr.NumVols, pr.MaxVols, pr.PoolType, pr.Name);
- sendit(ctx, mdb->cmd);
+ Mmsg(mdb->cmd, " %7d %6d %6d %-10s %s\n",
+ pr.PoolId, pr.NumVols, pr.MaxVols, pr.PoolType, pr.Name);
+ sendit(ctx, mdb->cmd);
}
sendit(ctx, "===================================================\n");
db_unlock(mdb);
* List Media records
*/
void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr,
- DB_LIST_HANDLER *sendit, void *ctx)
+ DB_LIST_HANDLER *sendit, void *ctx)
{
char ewc[30];
int len;
}
sendit(ctx, " Status VolBytes MediaType VolumeName\n");
sendit(ctx, "=============================================================\n");
- fseek(mdb->mediafd, 0L, SEEK_SET); /* rewind file */
+ fseek(mdb->mediafd, 0L, SEEK_SET); /* rewind file */
len = sizeof(mr);
while (fread(&mr, len, 1, mdb->mediafd) > 0) {
- Mmsg(mdb->cmd, " %-10s %17s %-15s %s\n",
- mr.VolStatus, edit_uint64_with_commas(mr.VolBytes, ewc),
- mr.MediaType, mr.VolumeName);
- sendit(ctx, mdb->cmd);
+ Mmsg(mdb->cmd, " %-10s %17s %-15s %s\n",
+ mr.VolStatus, edit_uint64_with_commas(mr.VolBytes, ewc),
+ mr.MediaType, mr.VolumeName);
+ sendit(ctx, mdb->cmd);
}
sendit(ctx, "====================================================================\n");
db_unlock(mdb);
}
void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId,
- DB_LIST_HANDLER *sendit, void *ctx)
+ DB_LIST_HANDLER *sendit, void *ctx)
{
JOBMEDIA_DBR jm;
MEDIA_DBR mr;
while (fread(&jm, jmlen, 1, mdb->jobmediafd) > 0) {
/* List by JobId */
if (JobId != 0) {
- if (jm.JobId == JobId) {
- /* Now find VolumeName in corresponding Media record */
- fseek(mdb->mediafd, 0L, SEEK_SET);
- while (fread(&mr, mrlen, 1, mdb->mediafd) > 0) {
- if (mr.MediaId == jm.MediaId) {
- Mmsg(mdb->cmd, " %7d %-10s %10d %10d\n",
- jm.JobId, mr.VolumeName, jm.FirstIndex, jm.LastIndex);
- sendit(ctx, mdb->cmd);
- break;
- }
- }
- }
+ if (jm.JobId == JobId) {
+ /* Now find VolumeName in corresponding Media record */
+ fseek(mdb->mediafd, 0L, SEEK_SET);
+ while (fread(&mr, mrlen, 1, mdb->mediafd) > 0) {
+ if (mr.MediaId == jm.MediaId) {
+ Mmsg(mdb->cmd, " %7d %-10s %10d %10d\n",
+ jm.JobId, mr.VolumeName, jm.FirstIndex, jm.LastIndex);
+ sendit(ctx, mdb->cmd);
+ break;
+ }
+ }
+ }
} else {
- /* List all records */
- fseek(mdb->mediafd, 0L, SEEK_SET);
- while (fread(&mr, mrlen, 1, mdb->mediafd) > 0) {
- if (mr.MediaId == jm.MediaId) {
- Mmsg(mdb->cmd, " %7d %-10s %10d %10d\n",
- jm.JobId, mr.VolumeName, jm.FirstIndex, jm.LastIndex);
- sendit(ctx, mdb->cmd);
- break;
- }
- }
+ /* List all records */
+ fseek(mdb->mediafd, 0L, SEEK_SET);
+ while (fread(&mr, mrlen, 1, mdb->mediafd) > 0) {
+ if (mr.MediaId == jm.MediaId) {
+ Mmsg(mdb->cmd, " %7d %-10s %10d %10d\n",
+ jm.JobId, mr.VolumeName, jm.FirstIndex, jm.LastIndex);
+ sendit(ctx, mdb->cmd);
+ break;
+ }
+ }
}
}
* List Job records
*/
void db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr,
- DB_LIST_HANDLER *sendit, void *ctx)
+ DB_LIST_HANDLER *sendit, void *ctx)
{
int jrlen;
JOB_DBR ojr;
jrlen = sizeof(ojr);
while (!done && fread(&ojr, jrlen, 1, mdb->jobfd) > 0) {
if (jr->JobId != 0) {
- if (jr->JobId == ojr.JobId) {
- done = 1;
- } else {
- continue;
- }
+ if (jr->JobId == ojr.JobId) {
+ done = 1;
+ } else {
+ continue;
+ }
}
localtime_r(&ojr.StartTime, &tm);
strftime(dt, sizeof(dt), "%m-%d %H:%M", &tm);
Mmsg(mdb->cmd, " %7d %-10s %c %c %14s %10s %c %s\n",
- ojr.JobId, dt, (char)ojr.JobType, (char)ojr.JobLevel,
- edit_uint64_with_commas(ojr.JobBytes, ewc1),
- edit_uint64_with_commas(ojr.JobFiles, ewc2),
- (char)ojr.JobStatus, ojr.Name);
+ ojr.JobId, dt, (char)ojr.JobType, (char)ojr.JobLevel,
+ edit_uint64_with_commas(ojr.JobBytes, ewc1),
+ edit_uint64_with_commas(ojr.JobFiles, ewc2),
+ (char)ojr.JobStatus, ojr.Name);
sendit(ctx, mdb->cmd);
}
sendit(ctx, "============================================================================\n");
* List Job Totals
*/
void db_list_job_totals(JCR *jcr, B_DB *mdb, JOB_DBR *jr,
- DB_LIST_HANDLER *sendit, void *ctx)
+ DB_LIST_HANDLER *sendit, void *ctx)
{
char ewc1[30], ewc2[30], ewc3[30];
int jrlen;
total_jobs++;
}
Mmsg(mdb->cmd, " %7s %10s %15s\n",
- edit_uint64_with_commas(total_jobs, ewc1),
- edit_uint64_with_commas(total_files, ewc2),
- edit_uint64_with_commas(total_bytes, ewc3));
+ edit_uint64_with_commas(total_jobs, ewc1),
+ edit_uint64_with_commas(total_files, ewc2),
+ edit_uint64_with_commas(total_bytes, ewc3));
sendit(ctx, mdb->cmd);
sendit(ctx, "=======================================\n");
db_unlock(mdb);
{ }
int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit,
- void *ctx, int verbose, e_list_type type)
+ void *ctx, int verbose, e_list_type type)
{
return 0;
}
void
db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr,
- DB_LIST_HANDLER *sendit, void *ctx, e_list_type type)
+ DB_LIST_HANDLER *sendit, void *ctx, e_list_type type)
{ }
void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId,
- DB_LIST_HANDLER *sendit, void *ctx, e_list_type type)
+ DB_LIST_HANDLER *sendit, void *ctx, e_list_type type)
{ }
void
db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit,
- void *ctx, e_list_type type)
+ void *ctx, e_list_type type)
{ }
void
*/
/*
- Copyright (C) 2001-2003 Kern Sibbald and John Walker
+ Copyright (C) 2001-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License
+ version 2 as amended with additional clauses defined in the
+ file LICENSE in the main source directory.
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., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ the file LICENSE for additional details.
*/
/* The following is necessary so that we do not include
* the dummy external definition of DB.
*/
-#define __SQL_C /* indicate that this is sql.c */
+#define __SQL_C /* indicate that this is sql.c */
#include "bacula.h"
#include "cats.h"
Mmsg1(mdb->errmsg, _("Error updating DB Media file. ERR=%s\n"), strerror(errno));
stat = 0;
} else {
- memcpy(pr, &opr, len); /* return record written */
+ memcpy(pr, &opr, len); /* return record written */
}
fflush(mdb->poolfd);
DBId_t ClientId; /* Id of client */
DBId_t PoolId; /* Id of pool */
DBId_t FileSetId; /* Id of FileSet */
+ DBId_t PriorJobId; /* Id of migrated (prior) job */
time_t SchedTime; /* Time job scheduled */
time_t StartTime; /* Job start time */
- time_t EndTime; /* Job termination time */
+ time_t EndTime; /* Job termination time of orig job */
+ time_t RealEndTime; /* Job termination time of this job */
utime_t JobTDate; /* Backup time/date in seconds */
uint32_t VolSessionId;
uint32_t VolSessionTime;
faddr_t rec_addr;
};
-/*
- * Suplementary record for Migration, archive, copy jobs
- */
-/* MAC record */
-struct MAC_DBR {
- JobId_t JobId; /* Id of this job */
- JobId_t OriginalJobId; /* Id of job migrated, copied or archived */
- /*
- * The following are the actual values for this job. This
- * is needed because the values in the corresponding Job
- * record were set to the values of the original backup job.
- */
- int JobType; /* Actual job type */
- int JobLevel; /* Actual job level */
- time_t SchedTime; /* Actual time job scheduled */
- time_t StartTime; /* Actual Job start time */
- time_t EndTime; /* Actual Job termination time */
- utime_t JobTDate; /* Actual Backup time/date in seconds */
-
- char cSchedTime[MAX_TIME_LENGTH];
- char cStartTime[MAX_TIME_LENGTH];
- char cEndTime[MAX_TIME_LENGTH];
-
-};
-
-
-
/* Job Media information used to create the media records
* for each Volume used for the job.
*/
uint32_t StartBlock; /* start block on tape */
uint32_t EndBlock; /* last block */
uint32_t Copy; /* identical copy */
- uint32_t Stripe; /* RAIT strip number */
};
DBId_t StorageId; /* Storage record Id */
uint32_t EndFile; /* Last file on volume */
uint32_t EndBlock; /* Last block on volume */
- char VolStatus[20]; /* Volume status */
+ char VolStatus[20]; /* Volume status */
+ DBId_t DeviceId; /* Device where Vol last written */
+ DBId_t LocationId; /* Where Volume is -- user defined */
+ DBId_t ScratchPoolId; /* Where to move if scratch */
+ DBId_t RecyclePoolId; /* Where to move when recycled */
+ int32_t Enabled; /* disabled=0, enabled=1, archived=2 */
/* Extra stuff not in DB */
faddr_t rec_addr; /* found record address */
/* Since the database returns times as strings, this is how we pass
SchedTime DATETIME NOT NULL,
StartTime DATETIME NOT NULL,
EndTime DATETIME NOT NULL,
+ RealEndTime DATETIME NOT NULL,
JobTDate BIGINT UNSIGNED NOT NULL,
VolSessionId INTEGER UNSIGNED NOT NULL DEFAULT 0,
VolSessionTime INTEGER UNSIGNED NOT NULL DEFAULT 0,
JobMissingFiles INTEGER UNSIGNED NOT NULL DEFAULT 0,
PoolId INTEGER UNSIGNED NOT NULL REFERENCES Pool,
FileSetId INTEGER UNSIGNED NOT NULL REFERENCES FileSet,
+ PriorJobId INTEGER UNSIGNED DEFAULT 0 REFERENCES Job,
PurgedFiles TINYINT NOT NULL DEFAULT 0,
HasBase TINYINT NOT NULL DEFAULT 0,
PRIMARY KEY(JobId),
INDEX (Name(128))
);
-CREATE TABLE MAC (
- JobId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
- OriginalJobId INTEGER UNSIGNED NOT NULL,
- JobType BINARY(1) NOT NULL,
- JobLevel BINARY(1) NOT NULL,
- SchedTime DATETIME NOT NULL,
- StartTime DATETIME NOT NULL,
- EndTime DATETIME NOT NULL,
- JobTDate BIGINT UNSIGNED NOT NULL,
- PRIMARY KEY(JobId)
- );
CREATE TABLE Location (
LocationId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
Location TINYBLOB NOT NULL,
+ Cost INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY(LocationId)
);
VolCapacityBytes BIGINT UNSIGNED NOT NULL,
VolStatus ENUM('Full', 'Archive', 'Append', 'Recycle', 'Purged',
'Read-Only', 'Disabled', 'Error', 'Busy', 'Used', 'Cleaning') NOT NULL,
+ Enabled TINYINT DEFAULT 1,
Recycle TINYINT NOT NULL DEFAULT 0,
VolRetention BIGINT UNSIGNED NOT NULL DEFAULT 0,
VolUseDuration BIGINT UNSIGNED NOT NULL DEFAULT 0,
MaxVolFiles INTEGER UNSIGNED NOT NULL DEFAULT 0,
MaxVolBytes BIGINT UNSIGNED NOT NULL DEFAULT 0,
InChanger TINYINT NOT NULL DEFAULT 0,
- StorageId INTEGER UNSIGNED NOT NULL REFERENCES Storage,
- DeviceId INTEGER UNSIGNED NOT NULL REFERENCES Device,
+ StorageId INTEGER UNSIGNED DEFAULT 0 REFERENCES Storage,
+ DeviceId INTEGER UNSIGNED DEFAULT 0 REFERENCES Device,
MediaAddressing TINYINT NOT NULL DEFAULT 0,
VolReadTime BIGINT UNSIGNED NOT NULL DEFAULT 0,
VolWriteTime BIGINT UNSIGNED NOT NULL DEFAULT 0,
EndFile INTEGER UNSIGNED NOT NULL DEFAULT 0,
EndBlock INTEGER UNSIGNED NOT NULL DEFAULT 0,
- LocationId INTEGER UNSIGNED NOT NULL REFERENCES Location,
+ LocationId INTEGER UNSIGNED DEFAULT 0 REFERENCES Location,
RecycleCount INTEGER UNSIGNED DEFAULT 0,
InitialWrite DATETIME NOT NULL,
ScratchPoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool,
schedtime timestamp without time zone not null,
starttime timestamp without time zone,
endtime timestamp without time zone,
+ realendtime timestamp without time zone,
jobtdate bigint not null,
volsessionid integer not null default 0,
volsessiontime integer not null default 0,
filesetid integer,
purgedfiles smallint not null default 0,
hasbase smallint not null default 0,
+ priorjobid integer not null default 0,
primary key (jobid)
);
CREATE INDEX job_name_idx on job (name);
-CREATE TABLE MAC (
- JobId serial not null,
- OriginalJobId serial not null,
- JobType char(1) not null,
- JobLevel char(1) not null,
- schedtime timestamp without time zone not null,
- starttime timestamp without time zone,
- endtime timestamp without time zone,
- jobtdate bigint not null,
- primary key (jobid)
-);
-
CREATE TABLE Location (
LocationId serial not null,
Location text not null,
+ Cost integer not null default 0,
primary key (LocationId)
);
endblock bigint not null default 0,
volindex integer not null default 0,
copy integer not null default 0,
- stripe integer not null default 0,
primary key (jobmediaid)
);
check (volstatus in ('Full','Archive','Append',
'Recycle','Purged','Read-Only','Disabled',
'Error','Busy','Used','Cleaning','Scratch')),
+ enabled smallint not null default 1,
recycle smallint not null default 0,
volretention bigint not null default 0,
voluseduration bigint not null default 0,
SchedTime DATETIME NOT NULL,
StartTime DATETIME DEFAULT 0,
EndTime DATETIME DEFAULT 0,
+ RealEndTime DATETIME DEFAULT 0,
JobTDate BIGINT UNSIGNED DEFAULT 0,
VolSessionId INTEGER UNSIGNED DEFAULT 0,
VolSessionTime INTEGER UNSIGNED DEFAULT 0,
JobMissingFiles INTEGER UNSIGNED DEFAULT 0,
PoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
FileSetId INTEGER UNSIGNED REFERENCES FileSet DEFAULT 0,
+ PriorJobId INTEGER UNSIGNED REFERENCES Job DEFAULT 0,
PurgedFiles TINYINT DEFAULT 0,
HasBase TINYINT DEFAULT 0,
PRIMARY KEY(JobId)
CREATE INDEX inx6 ON Job (Name);
-CREATE TABLE MAC (
- JobId INTEGER,
- OriginalJobId INTEGER,
- JobType CHAR NOT NULL,
- JobLevel CHAR NOT NULL,
- SchedTime DATETIME NOT NULL,
- StartTime DATETIME DEFAULT 0,
- EndTime DATETIME DEFAULT 0,
- JobTDate BIGINT UNSIGNED DEFAULT 0,
- PRIMARY KEY(JobId)
- );
-
CREATE TABLE Location (
LocationId INTEGER,
Location TINYBLOB NOT NULL,
+ Cost INTEGER,
PRIMARY KEY(LocationId)
);
+
CREATE TABLE FileSet (
FileSetId INTEGER,
FileSet VARCHAR(128) NOT NULL,
EndBlock INTEGER UNSIGNED DEFAULT 0,
VolIndex INTEGER UNSIGNED DEFAULT 0,
Copy INTEGER UNSIGNED DEFAULT 0,
- Stripe INTEGER UNSIGNED DEFAULT 0,
PRIMARY KEY(JobMediaId)
);
VolWrites INTEGER UNSIGNED DEFAULT 0,
VolCapacityBytes BIGINT UNSIGNED DEFAULT 0,
VolStatus VARCHAR(20) NOT NULL,
+ Enabled TINYINT DEFAULT 1,
Recycle TINYINT DEFAULT 0,
VolRetention BIGINT UNSIGNED DEFAULT 0,
VolUseDuration BIGINT UNSIGNED DEFAULT 0,
MaxVolFiles INTEGER UNSIGNED DEFAULT 0,
MaxVolBytes BIGINT UNSIGNED DEFAULT 0,
InChanger TINYINT DEFAULT 0,
- StorageId INTEGER UNSIGNED REFERENCES Storage,
- DeviceId INTEGER UNSIGNED REFERENCES Device,
+ StorageId INTEGER UNSIGNED REFERENCES Storage DEFAULT 0,
+ DeviceId INTEGER UNSIGNED REFERENCES Device DEFAULT 0,
MediaAddressing TINYINT DEFAULT 0,
VolReadTime BIGINT UNSIGNED DEFAULT 0,
VolWriteTime BIGINT UNSIGNED DEFAULT 0,
EndFile INTEGER UNSIGNED DEFAULT 0,
EndBlock INTEGER UNSIGNED DEFAULT 0,
- LocationId INTEGER UNSIGNED REFERENCES Location,
+ LocationId INTEGER UNSIGNED REFERENCES Location DEFAULT 0,
RecycleCount INTEGER UNSIGNED DEFAULT 0,
InitialWrite DATETIME DEFAULT 0,
ScratchPoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
SchedTime DATETIME NOT NULL,
StartTime DATETIME DEFAULT 0,
EndTime DATETIME DEFAULT 0,
+ RealEndTime DATETIME DEFAULT 0,
JobTDate BIGINT UNSIGNED DEFAULT 0,
VolSessionId INTEGER UNSIGNED DEFAULT 0,
VolSessionTime INTEGER UNSIGNED DEFAULT 0,
JobMissingFiles INTEGER UNSIGNED DEFAULT 0,
PoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
FileSetId INTEGER UNSIGNED REFERENCES FileSet DEFAULT 0,
+ PriorJobId INTEGER UNSIGNED REFERENCES Job DEFAULT 0,
PurgedFiles TINYINT DEFAULT 0,
HasBase TINYINT DEFAULT 0,
PRIMARY KEY(JobId)
CREATE INDEX inx6 ON Job (Name);
-CREATE TABLE MAC (
- JobId INTEGER,
- OriginalJobId INTEGER,
- JobType CHAR NOT NULL,
- JobLevel CHAR NOT NULL,
- SchedTime DATETIME NOT NULL,
- StartTime DATETIME DEFAULT 0,
- EndTime DATETIME DEFAULT 0,
- JobTDate BIGINT UNSIGNED DEFAULT 0,
- PRIMARY KEY(JobId)
- );
-
CREATE TABLE Location (
LocationId INTEGER,
Location TINYBLOB NOT NULL,
+ Cost INTEGER,
PRIMARY KEY(LocationId)
);
EndBlock INTEGER UNSIGNED DEFAULT 0,
VolIndex INTEGER UNSIGNED DEFAULT 0,
Copy INTEGER UNSIGNED DEFAULT 0,
- Stripe INTEGER UNSIGNED DEFAULT 0,
PRIMARY KEY(JobMediaId)
);
VolWrites INTEGER UNSIGNED DEFAULT 0,
VolCapacityBytes BIGINT UNSIGNED DEFAULT 0,
VolStatus VARCHAR(20) NOT NULL,
+ Enabled TINYINT DEFAULT 1,
Recycle TINYINT DEFAULT 0,
VolRetention BIGINT UNSIGNED DEFAULT 0,
VolUseDuration BIGINT UNSIGNED DEFAULT 0,
MaxVolFiles INTEGER UNSIGNED DEFAULT 0,
MaxVolBytes BIGINT UNSIGNED DEFAULT 0,
InChanger TINYINT DEFAULT 0,
- StorageId INTEGER UNSIGNED REFERENCES Storage,
- DeviceId INTEGER UNSIGNED REFERENCES Device,
+ StorageId INTEGER UNSIGNED REFERENCES Storage DEFAULT 0,
+ DeviceId INTEGER UNSIGNED REFERENCES Device DEFAULT 0,
MediaAddressing TINYINT DEFAULT 0,
VolReadTime BIGINT UNSIGNED DEFAULT 0,
VolWriteTime BIGINT UNSIGNED DEFAULT 0,
EndFile INTEGER UNSIGNED DEFAULT 0,
EndBlock INTEGER UNSIGNED DEFAULT 0,
- LocationId INTEGER UNSIGNED REFERENCES Location,
+ LocationId INTEGER UNSIGNED REFERENCES Location DEFAULT 0,
RecycleCount INTEGER UNSIGNED DEFAULT 0,
InitialWrite DATETIME DEFAULT 0,
ScratchPoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
/* create.c */
int db_create_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar);
bool db_create_job_record(JCR *jcr, B_DB *db, JOB_DBR *jr);
-bool db_create_mac_record(JCR *jcr, B_DB *db, MAC_DBR *mr);
int db_create_media_record(JCR *jcr, B_DB *db, MEDIA_DBR *media_dbr);
int db_create_client_record(JCR *jcr, B_DB *db, CLIENT_DBR *cr);
bool db_create_fileset_record(JCR *jcr, B_DB *db, FILESET_DBR *fsr);
bool db_get_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pdbr);
int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr);
bool db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr);
-bool db_get_mac_record(JCR *jcr, B_DB *mdb, MAC_DBR *mr);
int db_get_job_volume_names(JCR *jcr, B_DB *mdb, JobId_t JobId, POOLMEM **VolumeNames);
int db_get_file_attributes_record(JCR *jcr, B_DB *mdb, char *fname, JOB_DBR *jr, FILE_DBR *fdbr);
int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr);
*/
/*
- Copyright (C) 2000-2005 Kern Sibbald
+ Copyright (C) 2000-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License
+ version 2 as amended with additional clauses defined in the
+ file LICENSE in the main source directory.
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., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ the file LICENSE for additional details.
*/
* Version $Id$
*/
/*
- Copyright (C) 2000-2005 Kern Sibbald
+ Copyright (C) 2000-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
return ok;
}
-/* Create a new migration, archive, copy
- * Returns: false on failure
- * true on success
- */
-bool
-db_create_mac_record(JCR *jcr, B_DB *mdb, MAC_DBR *mr)
-{
- char schedt[MAX_TIME_LENGTH], sdt[MAX_TIME_LENGTH], edt[MAX_TIME_LENGTH];
- time_t stime;
- struct tm tm;
- bool ok;
- utime_t JobTDate;
- char ed1[30], ed2[30];
-
- db_lock(mdb);
-
- stime = mr->SchedTime;
- ASSERT(stime != 0);
-
- localtime_r(&stime, &tm);
- strftime(schedt, sizeof(schedt), "%Y-%m-%d %T", &tm);
- JobTDate = (utime_t)stime;
- localtime_r(&mr->StartTime, &tm);
- strftime(sdt, sizeof(sdt), "%Y-%m-%d %T", &tm);
- localtime_r(&mr->EndTime, &tm);
- strftime(edt, sizeof(edt), "%Y-%m-%d %T", &tm);
-
- /* Must create it */
- Mmsg(mdb->cmd,
-"INSERT INTO MAC (OriginaJobId,JobType,JobLevel,SchedTime,"
-"StartTime,EndTime,JobTDate) VALUES "
-"('%s','%c','%c','%s','%s','%s',%s)",
- edit_int64(mr->OriginalJobId, ed1),
- (char)(mr->JobType), (char)(mr->JobLevel),
- schedt, sdt, edt, edit_uint64(JobTDate, ed2));
-
- if (!INSERT_DB(jcr, mdb, mdb->cmd)) {
- Mmsg2(&mdb->errmsg, _("Create DB MAC record %s failed. ERR=%s\n"),
- mdb->cmd, sql_strerror(mdb));
- mr->JobId = 0;
- ok = false;
- } else {
- mr->JobId = sql_insert_id(mdb, NT_("Job"));
- ok = true;
- }
- db_unlock(mdb);
- return ok;
-}
-
/* Create a JobMedia record for medium used this job
* Returns: false on failure
}
count++;
+ /* Note, jm->Strip is not used and is not likely to be used
+ * in the near future, so I have removed it from the insert
+ * to save space in the DB. KES June 2006.
+ */
Mmsg(mdb->cmd,
"INSERT INTO JobMedia (JobId,MediaId,FirstIndex,LastIndex,"
- "StartFile,EndFile,StartBlock,EndBlock,VolIndex,Copy,Stripe) "
- "VALUES (%s,%s,%u,%u,%u,%u,%u,%u,%u,%u,%u)",
+ "StartFile,EndFile,StartBlock,EndBlock,VolIndex,Copy) "
+ "VALUES (%s,%s,%u,%u,%u,%u,%u,%u,%u,%u)",
edit_int64(jm->JobId, ed1),
edit_int64(jm->MediaId, ed2),
jm->FirstIndex, jm->LastIndex,
jm->StartFile, jm->EndFile, jm->StartBlock, jm->EndBlock,count,
- jm->Copy, jm->Stripe);
+ jm->Copy);
Dmsg0(300, mdb->cmd);
if (!INSERT_DB(jcr, mdb, mdb->cmd)) {
{
int stat;
char ed1[50], ed2[50], ed3[50], ed4[50], ed5[50], ed6[50], ed7[50], ed8[50];
+ char ed9[50], ed10[50], ed11[50], ed12[50];
struct tm tm;
db_lock(mdb);
"INSERT INTO Media (VolumeName,MediaType,MediaTypeId,PoolId,MaxVolBytes,"
"VolCapacityBytes,Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,"
"VolStatus,Slot,VolBytes,InChanger,VolReadTime,VolWriteTime,VolParts,"
-"EndFile,EndBlock,LabelType,StorageId,DeviceId,LocationId) "
-"VALUES ('%s','%s',0,%u,%s,%s,%d,%s,%s,%u,%u,'%s',%d,%s,%d,%s,%s,%d,0,0,%d,%s,0,0)",
+"EndFile,EndBlock,LabelType,StorageId,DeviceId,LocationId,"
+"ScratchPoolId,RecyclePoolId,Enabled)"
+"VALUES ('%s','%s',0,%u,%s,%s,%d,%s,%s,%u,%u,'%s',%d,%s,%d,%s,%s,%d,0,0,%d,%s,"
+"%s,%s,%s,%s,%d)",
mr->VolumeName,
mr->MediaType, mr->PoolId,
edit_uint64(mr->MaxVolBytes,ed1),
edit_uint64(mr->VolWriteTime, ed7),
mr->VolParts,
mr->LabelType,
- edit_int64(mr->StorageId, ed8)
+ edit_int64(mr->StorageId, ed8),
+ edit_int64(mr->DeviceId, ed9),
+ edit_int64(mr->LocationId, ed10),
+ edit_int64(mr->ScratchPoolId, ed11),
+ edit_int64(mr->RecyclePoolId, ed12),
+ mr->Enabled
);
*/
/*
- Copyright (C) 2000-2005 Kern Sibbald
+ Copyright (C) 2000-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License
+ version 2 as amended with additional clauses defined in the
+ file LICENSE in the main source directory.
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., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ the file LICENSE for additional details.
*/
/* The following is necessary so that we do not include
* the dummy external definition of DB.
*/
-#define __SQL_C /* indicate that this is sql.c */
+#define __SQL_C /* indicate that this is sql.c */
#include "bacula.h"
#include "cats.h"
* Media records.
*
* Returns: 0 on error
- * 1 on success
- * PoolId = number of Pools deleted (should be 1)
- * NumVols = number of Media records deleted
+ * 1 on success
+ * PoolId = number of Pools deleted (should be 1)
+ * NumVols = number of Media records deleted
*/
int
db_delete_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
if (mdb->num_rows == 0) {
Mmsg(mdb->errmsg, _("No pool record %s exists\n"), pr->Name);
- sql_free_result(mdb);
- db_unlock(mdb);
- return 0;
+ sql_free_result(mdb);
+ db_unlock(mdb);
+ return 0;
} else if (mdb->num_rows != 1) {
Mmsg(mdb->errmsg, _("Expecting one pool record, got %d\n"), mdb->num_rows);
- sql_free_result(mdb);
- db_unlock(mdb);
- return 0;
+ sql_free_result(mdb);
+ db_unlock(mdb);
+ return 0;
}
if ((row = sql_fetch_row(mdb)) == NULL) {
Mmsg1(&mdb->errmsg, _("Error fetching row %s\n"), sql_strerror(mdb));
- db_unlock(mdb);
- return 0;
+ db_unlock(mdb);
+ return 0;
}
pr->PoolId = str_to_int64(row[0]);
sql_free_result(mdb);
struct s_del_ctx {
JobId_t *JobId;
- int num_ids; /* ids stored */
- int max_ids; /* size of array */
- int num_del; /* number deleted */
- int tot_ids; /* total to process */
+ int num_ids; /* ids stored */
+ int max_ids; /* size of array */
+ int num_del; /* number deleted */
+ int tot_ids; /* total to process */
};
/*
if (del->num_ids == del->max_ids) {
del->max_ids = (del->max_ids * 3) / 2;
del->JobId = (JobId_t *)brealloc(del->JobId, sizeof(JobId_t) *
- del->max_ids);
+ del->max_ids);
}
del->JobId[del->num_ids++] = (JobId_t)str_to_int64(row[0]);
return 0;
return 0;
}
/* Delete associated records */
- do_media_purge(mdb, mr); /* Note, always purge */
+ do_media_purge(mdb, mr); /* Note, always purge */
/* Mark Volume as purged */
strcpy(mr->VolStatus, "Purged");
return true;
}
-/*
- * Get MAC record for given JobId
- * Returns: false on failure
- * true on success
- */
-bool db_get_mac_record(JCR *jcr, B_DB *mdb, MAC_DBR *mr)
-{
- SQL_ROW row;
- char ed1[50];
-
- db_lock(mdb);
- Mmsg(mdb->cmd, "SELECT OriginalJobId,JobType,JobLevel,"
-"SchedTime,StartTime,EndTime,JobTDate"
-"FROM MAC WHERE JobId=%s",
- edit_int64(mr->JobId, ed1));
-
- if (!QUERY_DB(jcr, mdb, mdb->cmd)) {
- db_unlock(mdb);
- return 0; /* failed */
- }
- if ((row = sql_fetch_row(mdb)) == NULL) {
- Mmsg1(mdb->errmsg, _("No MAC record found for JobId %s\n"), ed1);
- sql_free_result(mdb);
- db_unlock(mdb);
- return false; /* failed */
- }
-
- mr->OriginalJobId = str_to_int64(row[0]);
- mr->JobType = (int)*row[1];
- mr->JobLevel = (int)*row[2];
- bstrncpy(mr->cSchedTime, row[3]!=NULL?row[3]:"", sizeof(mr->cSchedTime));
- bstrncpy(mr->cStartTime, row[4]!=NULL?row[4]:"", sizeof(mr->cStartTime));
- bstrncpy(mr->cEndTime, row[5]!=NULL?row[5]:"", sizeof(mr->cEndTime));
- mr->JobTDate = str_to_int64(row[6]);
- sql_free_result(mdb);
-
- db_unlock(mdb);
- return 1;
-}
-
-
/*
* Find VolumeNames for a given JobId
* Returns: 0 on error or no Volumes found
db_lock(mdb);
Mmsg(mdb->cmd,
"SELECT VolumeName,MediaType,FirstIndex,LastIndex,StartFile,"
-"JobMedia.EndFile,StartBlock,JobMedia.EndBlock,Copy,Stripe,"
+"JobMedia.EndFile,StartBlock,JobMedia.EndBlock,Copy,"
"Slot,StorageId"
" FROM JobMedia,Media WHERE JobMedia.JobId=%s"
" AND JobMedia.MediaId=Media.MediaId ORDER BY VolIndex,JobMediaId",
Vols[i].StartBlock = str_to_uint64(row[6]);
Vols[i].EndBlock = str_to_uint64(row[7]);
// Vols[i].Copy = str_to_uint64(row[8]);
-// Vols[i].Stripe = str_to_uint64(row[9]);
- Vols[i].Slot = str_to_uint64(row[10]);
- StorageId = str_to_uint64(row[11]);
+ Vols[i].Slot = str_to_uint64(row[9]);
+ StorageId = str_to_uint64(row[10]);
Vols[i].Storage[0] = 0;
SId[i] = StorageId;
}
if (JobId > 0) { /* do by JobId */
Mmsg(mdb->cmd, "SELECT JobMediaId,JobId,Media.MediaId,Media.VolumeName,"
"FirstIndex,LastIndex,StartFile,JobMedia.EndFile,StartBlock,"
- "JobMedia.EndBlock,Copy,Stripe "
+ "JobMedia.EndBlock,Copy "
"FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId "
"AND JobMedia.JobId=%s", edit_int64(JobId, ed1));
} else {
Mmsg(mdb->cmd, "SELECT JobMediaId,JobId,Media.MediaId,Media.VolumeName,"
"FirstIndex,LastIndex,StartFile,JobMedia.EndFile,StartBlock,"
- "JobMedia.EndBlock,Copy,Stripe "
+ "JobMedia.EndBlock,Copy "
"FROM JobMedia,Media WHERE Media.MediaId=JobMedia.MediaId");
}
db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
{
char dt[MAX_TIME_LENGTH];
+ char rdt[MAX_TIME_LENGTH];
time_t ttime;
struct tm tm;
int stat;
char ed1[30], ed2[30], ed3[50];
btime_t JobTDate;
- char PoolId [50];
- char FileSetId [50];
- char ClientId [50];
+ char PoolId[50], FileSetId[50], ClientId[50], PriorJobId[50];
/* some values are set to zero, which translates to NULL in SQL */
edit_num_or_null(FileSetId, sizeof(FileSetId), jr->FileSetId);
edit_num_or_null(ClientId, sizeof(ClientId), jr->ClientId);
+ if (jr->PriorJobId) {
+ bstrncpy(PriorJobId, edit_int64(jr->PriorJobId, ed1), sizeof(PriorJobId));
+ } else {
+ bstrncpy(PriorJobId, "0", sizeof(PriorJobId));
+ }
+
ttime = jr->EndTime;
localtime_r(&ttime, &tm);
strftime(dt, sizeof(dt), "%Y-%m-%d %H:%M:%S", &tm);
+
+ if (jr->RealEndTime == 0) {
+ jr->RealEndTime = jr->EndTime;
+ }
+ ttime = jr->RealEndTime;
+ localtime_r(&ttime, &tm);
+ strftime(rdt, sizeof(rdt), "%Y-%m-%d %H:%M:%S", &tm);
+
JobTDate = ttime;
db_lock(mdb);
Mmsg(mdb->cmd,
- "UPDATE Job SET JobStatus='%c', EndTime='%s', "
-"ClientId=%s, JobBytes=%s, JobFiles=%u, JobErrors=%u, VolSessionId=%u, "
-"VolSessionTime=%u, PoolId=%s, FileSetId=%s, JobTDate=%s WHERE JobId=%s",
+ "UPDATE Job SET JobStatus='%c',EndTime='%s',"
+"ClientId=%s,JobBytes=%s,JobFiles=%u,JobErrors=%u,VolSessionId=%u,"
+"VolSessionTime=%u,PoolId=%s,FileSetId=%s,JobTDate=%s,"
+"RealEndTime='%s',PriorJobId=%s WHERE JobId=%s",
(char)(jr->JobStatus), dt, ClientId, edit_uint64(jr->JobBytes, ed1),
jr->JobFiles, jr->JobErrors, jr->VolSessionId, jr->VolSessionTime,
PoolId, FileSetId, edit_uint64(JobTDate, ed2),
+ rdt,
+ PriorJobId,
edit_int64(jr->JobId, ed3));
stat = UPDATE_DB(jcr, mdb, mdb->cmd);
ALTER TABLE Media ADD COLUMN InitialWrite DATETIME DEFAULT 0;
ALTER TABLE Media ADD COLUMN ScratchPoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool;
ALTER TABLE Media ADD COLUMN RecyclePoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool;
+ALTER TABLE Media ADD COLUMN Enabled TINYINT DEFAULT 1;
+ALTER TABLE JobMedia DROP ADD COLUMN Stripe;
+
+ALTER TABLE Job ADD COLUMN PriorJobId INTEGER UNSIGNED DEFAULT 0 REFERENCES Job;
+ALTER TABLE Job ADD COLUMN RealEndTime DATETIME DEFAULT 0;
-CREATE TABLE MAC (
- JobId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
- OriginalJobId INTEGER UNSIGNED NOT NULL,
- JobType BINARY(1) NOT NULL,
- JobLevel BINARY(1) NOT NULL,
- SchedTime DATETIME NOT NULL,
- StartTime DATETIME NOT NULL,
- EndTime DATETIME NOT NULL,
- JobTDate BIGINT UNSIGNED NOT NULL,
- PRIMARY KEY(JobId)
- );
CREATE TABLE Location (
LocationId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
Location TINYBLOB NOT NULL,
+ Cost INTEGER DEFAULT 0,
PRIMARY KEY(LocationId)
);
UPDATE media SET scratchpoolid=0;
ALTER TABLE media ADD COLUMN recyclepoolid integer;
UPDATE media SET recyclepoolid=0;
+ALTER TABLE media ADD COLUMN enabled integer;
+UPDATE media SET enabled=1;
+
+ALTER TABLE job ADD COLUMN RealEndTime timestamp without time zone;
+UPDATE job SET RealEndTime=0;
+ALTER TABLE job ADD COLUMN PriorJobId integer;
+UPDATE job SET PriorJobId=0;
+
+ALTER TABLE jobmedia DROP COLUMN Stripe;
-CREATE TABLE MAC (
- JobId serial not null,
- OriginalJobId serial not null,
- JobType char(1) not null,
- JobLevel char(1) not null,
- SchedTime timestamp without time zone not null,
- StartTime timestamp without time zone,
- EndTime timestamp without time zone,
- JobTDate bigint not null,
- primary key (JobId)
-);
CREATE TABLE Location (
LocationId SERIAL NOT NULL,
Location TEXT NOT NULL,
+ Cost integer not null default 0,
PRIMARY KEY (LocationId)
);
VolWrites INTEGER UNSIGNED DEFAULT 0,
VolCapacityBytes BIGINT UNSIGNED DEFAULT 0,
VolStatus VARCHAR(20) NOT NULL,
+ Enabled TINYINT DEFAULT 1,
Recycle TINYINT DEFAULT 0,
VolRetention BIGINT UNSIGNED DEFAULT 0,
VolUseDuration BIGINT UNSIGNED DEFAULT 0,
MediaType, LabelType, 0, FirstWritten, LastWritten,
LabelDate, VolJobs, VolFiles, VolBlocks,
VolMounts, VolBytes, VolParts, VolErrors, VolWrites,
- VolCapacityBytes, VolStatus, Recycle,
+ VolCapacityBytes, VolStatus, 1, Recycle,
VolRetention, VolUseDuration, MaxVolJobs,
MaxVolFiles, MaxVolBytes, InChanger,
StorageId, 0, MediaAddressing,
VolWrites INTEGER UNSIGNED DEFAULT 0,
VolCapacityBytes BIGINT UNSIGNED DEFAULT 0,
VolStatus VARCHAR(20) NOT NULL,
+ Enabled TINYINT DEFAULT 1,
Recycle TINYINT DEFAULT 0,
VolRetention BIGINT UNSIGNED DEFAULT 0,
VolUseDuration BIGINT UNSIGNED DEFAULT 0,
MediaType, MediaTypeId, LabelType, FirstWritten, LastWritten,
LabelDate, VolJobs, VolFiles, VolBlocks,
VolMounts, VolBytes, VolParts, VolErrors, VolWrites,
- VolCapacityBytes, VolStatus, Recycle,
+ VolCapacityBytes, VolStatus, Enabled, Recycle,
VolRetention, VolUseDuration, MaxVolJobs,
MaxVolFiles, MaxVolBytes,
InChanger, StorageId, DeviceId, MediaAddressing,
DROP TABLE Media_backup;
CREATE INDEX inx8 ON Media (PoolId);
+CREATE TEMPORARY TABLE job_backup
+{
+ JobId INTEGER,
+ Job VARCHAR(128) NOT NULL,
+ Name VARCHAR(128) NOT NULL,
+ Type CHAR NOT NULL,
+ Level CHAR NOT NULL,
+ ClientId INTEGER REFERENCES Client DEFAULT 0,
+ JobStatus CHAR NOT NULL,
+ SchedTime DATETIME NOT NULL,
+ StartTime DATETIME DEFAULT 0,
+ EndTime DATETIME DEFAULT 0,
+ RealEndTime DATETIME DEFAULT 0,
+ JobTDate BIGINT UNSIGNED DEFAULT 0,
+ VolSessionId INTEGER UNSIGNED DEFAULT 0,
+ VolSessionTime INTEGER UNSIGNED DEFAULT 0,
+ JobFiles INTEGER UNSIGNED DEFAULT 0,
+ JobBytes BIGINT UNSIGNED DEFAULT 0,
+ JobErrors INTEGER UNSIGNED DEFAULT 0,
+ JobMissingFiles INTEGER UNSIGNED DEFAULT 0,
+ PoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
+ FileSetId INTEGER UNSIGNED REFERENCES FileSet DEFAULT 0,
+ PriorJobId INTEGER UNSIGNED REFERENCES Job DEFAULT 0,
+ PurgedFiles TINYINT DEFAULT 0,
+ HasBase TINYINT DEFAULT 0,
+ PRIMARY KEY(JobId)
+ );
+
+INSERT INTO Job_backup SELECT
+ JobId, Job, Name, Type, Level, ClientId, JobStatus,
+ SchedTime, StartTime, EndTime, 0,
+ JobTDate, VolSessionId, VolSessionTime,
+ JobFiles, JobBytes, JobErrors, JobMissingFiles,
+ PoolId, FileSetId, 0, PurgedFiles, HasBase,
+ PRIMARY KEY(JobId)
+ );
+ FROM Job;
-CREATE TABLE MAC (
+DROP TABLE Job;
+CREATE TEMPORARY TABLE Job
+{
JobId INTEGER,
- OriginalJobId INTEGER,
- JobType CHAR NOT NULL,
- JobLevel CHAR NOT NULL,
+ Job VARCHAR(128) NOT NULL,
+ Name VARCHAR(128) NOT NULL,
+ Type CHAR NOT NULL,
+ Level CHAR NOT NULL,
+ ClientId INTEGER REFERENCES Client DEFAULT 0,
+ JobStatus CHAR NOT NULL,
SchedTime DATETIME NOT NULL,
StartTime DATETIME DEFAULT 0,
EndTime DATETIME DEFAULT 0,
+ RealEndTime DATETIME DEFAULT 0,
JobTDate BIGINT UNSIGNED DEFAULT 0,
- PRIMARY KEY(JobId)
+ VolSessionId INTEGER UNSIGNED DEFAULT 0,
+ VolSessionTime INTEGER UNSIGNED DEFAULT 0,
+ JobFiles INTEGER UNSIGNED DEFAULT 0,
+ JobBytes BIGINT UNSIGNED DEFAULT 0,
+ JobErrors INTEGER UNSIGNED DEFAULT 0,
+ JobMissingFiles INTEGER UNSIGNED DEFAULT 0,
+ PoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
+ FileSetId INTEGER UNSIGNED REFERENCES FileSet DEFAULT 0,
+ PriorJobId INTEGER UNSIGNED REFERENCES Job DEFAULT 0,
+ PurgedFiles TINYINT DEFAULT 0,
+ HasBase TINYINT DEFAULT 0,
+ PRIMARY KEY(JobId)
);
+INSERT INTO Job SELECT
+ JobId, Job, Name, Type, Level, ClientId, JobStatus,
+ SchedTime, StartTime, EndTime, RealEndTime,
+ JobTDate, VolSessionId, VolSessionTime,
+ JobFiles, JobBytes, JobErrors, JobMissingFiles,
+ PoolId, FileSetId, PriorJobId, PurgedFiles, HasBase
+ FROM Job_backup;
+
+DROP TABLE Job_backup;
+
CREATE TABLE Location (
LocationId INTEGER,
Location VARCHAR(128) NOT NULL,
+ Counter INTEGER DEFAULT 0,
PRIMARY KEY(LocationId)
);
VolWrites INTEGER UNSIGNED DEFAULT 0,
VolCapacityBytes BIGINT UNSIGNED DEFAULT 0,
VolStatus VARCHAR(20) NOT NULL,
+ Enabled TINYINT DEFAULT 1,
Recycle TINYINT DEFAULT 0,
VolRetention BIGINT UNSIGNED DEFAULT 0,
VolUseDuration BIGINT UNSIGNED DEFAULT 0,
MediaType, LabelType, 0, FirstWritten, LastWritten,
LabelDate, VolJobs, VolFiles, VolBlocks,
VolMounts, VolBytes, VolParts, VolErrors, VolWrites,
- VolCapacityBytes, VolStatus, Recycle,
+ VolCapacityBytes, VolStatus, 1, Recycle,
VolRetention, VolUseDuration, MaxVolJobs,
MaxVolFiles, MaxVolBytes, InChanger,
StorageId, 0, MediaAddressing,
VolWrites INTEGER UNSIGNED DEFAULT 0,
VolCapacityBytes BIGINT UNSIGNED DEFAULT 0,
VolStatus VARCHAR(20) NOT NULL,
+ Enabled TINYINT DEFAULT 1,
Recycle TINYINT DEFAULT 0,
VolRetention BIGINT UNSIGNED DEFAULT 0,
VolUseDuration BIGINT UNSIGNED DEFAULT 0,
MediaType, MediaTypeId, LabelType, FirstWritten, LastWritten,
LabelDate, VolJobs, VolFiles, VolBlocks,
VolMounts, VolBytes, VolParts, VolErrors, VolWrites,
- VolCapacityBytes, VolStatus, Recycle,
+ VolCapacityBytes, VolStatus, Enabled, Recycle,
VolRetention, VolUseDuration, MaxVolJobs,
MaxVolFiles, MaxVolBytes,
InChanger, StorageId, DeviceId, MediaAddressing,
DROP TABLE Media_backup;
CREATE INDEX inx8 ON Media (PoolId);
+CREATE TEMPORARY TABLE job_backup
+{
+ JobId INTEGER,
+ Job VARCHAR(128) NOT NULL,
+ Name VARCHAR(128) NOT NULL,
+ Type CHAR NOT NULL,
+ Level CHAR NOT NULL,
+ ClientId INTEGER REFERENCES Client DEFAULT 0,
+ JobStatus CHAR NOT NULL,
+ SchedTime DATETIME NOT NULL,
+ StartTime DATETIME DEFAULT 0,
+ EndTime DATETIME DEFAULT 0,
+ RealEndTime DATETIME DEFAULT 0,
+ JobTDate BIGINT UNSIGNED DEFAULT 0,
+ VolSessionId INTEGER UNSIGNED DEFAULT 0,
+ VolSessionTime INTEGER UNSIGNED DEFAULT 0,
+ JobFiles INTEGER UNSIGNED DEFAULT 0,
+ JobBytes BIGINT UNSIGNED DEFAULT 0,
+ JobErrors INTEGER UNSIGNED DEFAULT 0,
+ JobMissingFiles INTEGER UNSIGNED DEFAULT 0,
+ PoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
+ FileSetId INTEGER UNSIGNED REFERENCES FileSet DEFAULT 0,
+ PriorJobId INTEGER UNSIGNED REFERENCES Job DEFAULT 0,
+ PurgedFiles TINYINT DEFAULT 0,
+ HasBase TINYINT DEFAULT 0,
+ PRIMARY KEY(JobId)
+ );
+
+INSERT INTO Job_backup SELECT
+ JobId, Job, Name, Type, Level, ClientId, JobStatus,
+ SchedTime, StartTime, EndTime, 0,
+ JobTDate, VolSessionId, VolSessionTime,
+ JobFiles, JobBytes, JobErrors, JobMissingFiles,
+ PoolId, FileSetId, 0, PurgedFiles, HasBase,
+ PRIMARY KEY(JobId)
+ );
+ FROM Job;
-CREATE TABLE MAC (
+DROP TABLE Job;
+CREATE TEMPORARY TABLE Job
+{
JobId INTEGER,
- OriginalJobId INTEGER,
- JobType CHAR NOT NULL,
- JobLevel CHAR NOT NULL,
+ Job VARCHAR(128) NOT NULL,
+ Name VARCHAR(128) NOT NULL,
+ Type CHAR NOT NULL,
+ Level CHAR NOT NULL,
+ ClientId INTEGER REFERENCES Client DEFAULT 0,
+ JobStatus CHAR NOT NULL,
SchedTime DATETIME NOT NULL,
StartTime DATETIME DEFAULT 0,
EndTime DATETIME DEFAULT 0,
+ RealEndTime DATETIME DEFAULT 0,
JobTDate BIGINT UNSIGNED DEFAULT 0,
- PRIMARY KEY(JobId)
+ VolSessionId INTEGER UNSIGNED DEFAULT 0,
+ VolSessionTime INTEGER UNSIGNED DEFAULT 0,
+ JobFiles INTEGER UNSIGNED DEFAULT 0,
+ JobBytes BIGINT UNSIGNED DEFAULT 0,
+ JobErrors INTEGER UNSIGNED DEFAULT 0,
+ JobMissingFiles INTEGER UNSIGNED DEFAULT 0,
+ PoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
+ FileSetId INTEGER UNSIGNED REFERENCES FileSet DEFAULT 0,
+ PriorJobId INTEGER UNSIGNED REFERENCES Job DEFAULT 0,
+ PurgedFiles TINYINT DEFAULT 0,
+ HasBase TINYINT DEFAULT 0,
+ PRIMARY KEY(JobId)
);
+INSERT INTO Job SELECT
+ JobId, Job, Name, Type, Level, ClientId, JobStatus,
+ SchedTime, StartTime, EndTime, RealEndTime,
+ JobTDate, VolSessionId, VolSessionTime,
+ JobFiles, JobBytes, JobErrors, JobMissingFiles,
+ PoolId, FileSetId, PriorJobId, PurgedFiles, HasBase
+ FROM Job_backup;
+
+DROP TABLE Job_backup;
+
CREATE TABLE Location (
LocationId INTEGER,
Location VARCHAR(128) NOT NULL,
+ Counter INTEGER DEFAULT 0,
PRIMARY KEY(LocationId)
);
int index, ok, label, writing;
POOLMEM *omsg;
POOL_DBR pr;
+ uint32_t Stripe;
memset(&mr, 0, sizeof(mr));
memset(&sdmr, 0, sizeof(sdmr));
*/
} else if (sscanf(bs->msg, Create_job_media, &Job,
&jm.FirstIndex, &jm.LastIndex, &jm.StartFile, &jm.EndFile,
- &jm.StartBlock, &jm.EndBlock, &jm.Copy, &jm.Stripe) == 9) {
+ &jm.StartBlock, &jm.EndBlock, &jm.Copy, &Stripe) == 9) {
if (jcr->previous_jcr) {
jm.JobId = jcr->previous_jcr->JobId;
*/
+#include "lib/runscript.h"
#include "dird_conf.h"
#define DIRECTOR_DAEMON 1
#include "protos.h"
#include "jobq.h"
-#include "lib/runscript.h"
/* Globals that dird.c exports */
extern DIRRES *director; /* Director resource */
{"tlskey", store_dir, ITEM(res_dir.tls_keyfile), 0, 0, 0},
{"tlsdhfile", store_dir, ITEM(res_dir.tls_dhfile), 0, 0, 0},
{"tlsallowedcn", store_alist_str, ITEM(res_dir.tls_allowed_cns), 0, 0, 0},
- {NULL, NULL, NULL, 0, 0, 0}
+ {NULL, NULL, {0}, 0, 0, 0}
};
/*
{"tlskey", store_dir, ITEM(res_con.tls_keyfile), 0, 0, 0},
{"tlsdhfile", store_dir, ITEM(res_con.tls_dhfile), 0, 0, 0},
{"tlsallowedcn", store_alist_str, ITEM(res_con.tls_allowed_cns), 0, 0, 0},
- {NULL, NULL, NULL, 0, 0, 0}
+ {NULL, NULL, {0}, 0, 0, 0}
};
{"tlscacertificatedir", store_dir, ITEM(res_client.tls_ca_certdir), 0, 0, 0},
{"tlscertificate", store_dir, ITEM(res_client.tls_certfile), 0, 0, 0},
{"tlskey", store_dir, ITEM(res_client.tls_keyfile), 0, 0, 0},
- {NULL, NULL, NULL, 0, 0, 0}
+ {NULL, NULL, {0}, 0, 0, 0}
};
/* Storage daemon resource
{"tlscacertificatedir", store_dir, ITEM(res_store.tls_ca_certdir), 0, 0, 0},
{"tlscertificate", store_dir, ITEM(res_store.tls_certfile), 0, 0, 0},
{"tlskey", store_dir, ITEM(res_store.tls_keyfile), 0, 0, 0},
- {NULL, NULL, NULL, 0, 0, 0}
+ {NULL, NULL, {0}, 0, 0, 0}
};
/*
{"dbsocket", store_str, ITEM(res_cat.db_socket), 0, 0, 0},
/* Turned off for the moment */
{"multipleconnections", store_bit, ITEM(res_cat.mult_db_connections), 0, 0, 0},
- {NULL, NULL, NULL, 0, 0, 0}
+ {NULL, NULL, {0}, 0, 0, 0}
};
/*
{"selectionpattern", store_str, ITEM(res_job.selection_pattern), 0, 0, 0},
{"selectiontype", store_migtype, ITEM(res_job.selection_type), 0, 0, 0},
{"runscript", store_runscript, ITEM(res_job.RunScripts), 0, ITEM_NO_EQUALS, 0},
- {NULL, NULL, NULL, 0, 0, 0}
+ {NULL, NULL, {0}, 0, 0, 0}
};
/* FileSet resource
static RES_ITEM fs_items[] = {
{"name", store_name, ITEM(res_fs.hdr.name), 0, ITEM_REQUIRED, 0},
{"description", store_str, ITEM(res_fs.hdr.desc), 0, 0, 0},
- {"include", store_inc, NULL, 0, ITEM_NO_EQUALS, 0},
- {"exclude", store_inc, NULL, 1, ITEM_NO_EQUALS, 0},
+ {"include", store_inc, {0}, 0, ITEM_NO_EQUALS, 0},
+ {"exclude", store_inc, {0}, 1, ITEM_NO_EQUALS, 0},
{"ignorefilesetchanges", store_bool, ITEM(res_fs.ignore_fs_changes), 0, ITEM_DEFAULT, false},
{"enablevss", store_bool, ITEM(res_fs.enable_vss), 0, ITEM_DEFAULT, false},
- {NULL, NULL, NULL, 0, 0, 0}
+ {NULL, NULL, {0}, 0, 0, 0}
};
/* Schedule -- see run_conf.c */
{"name", store_name, ITEM(res_sch.hdr.name), 0, ITEM_REQUIRED, 0},
{"description", store_str, ITEM(res_sch.hdr.desc), 0, 0, 0},
{"run", store_run, ITEM(res_sch.run), 0, 0, 0},
- {NULL, NULL, NULL, 0, 0, 0}
+ {NULL, NULL, {0}, 0, 0, 0}
};
/* Pool resource
{"storage", store_alist_res, ITEM(res_pool.storage), R_STORAGE, 0, 0},
{"autoprune", store_bool, ITEM(res_pool.AutoPrune), 0, ITEM_DEFAULT, true},
{"recycle", store_bool, ITEM(res_pool.Recycle), 0, ITEM_DEFAULT, true},
- {NULL, NULL, NULL, 0, 0, 0}
+ {NULL, NULL, {0}, 0, 0, 0}
};
/*
{"maximum", store_pint, ITEM(res_counter.MaxValue), 0, ITEM_DEFAULT, INT32_MAX},
{"wrapcounter", store_res, ITEM(res_counter.WrapCounter), R_COUNTER, 0, 0},
{"catalog", store_res, ITEM(res_counter.Catalog), R_CATALOG, 0, 0},
- {NULL, NULL, NULL, 0, 0, 0}
+ {NULL, NULL, {0}, 0, 0, 0}
};
if (pass == 2) {
if (strcmp(lc->str, "%c") == 0) {
- ((RUNSCRIPT*) item->value)->set_target(lc->str);
+ ((RUNSCRIPT*) item->value)->set_target(lc->str);
} else if (strcmp(lc->str, "yes") == 0) {
- ((RUNSCRIPT*) item->value)->set_target("%c");
+ ((RUNSCRIPT*) item->value)->set_target("%c");
} else if (strcmp(lc->str, "no") == 0) {
- /* store nothing, run on director */
+ /* store nothing, run on director */
} else {
- RES *res = GetResWithName(R_CLIENT, lc->str);
- if (res == NULL) {
- scan_err3(lc, _("Could not find config Resource %s referenced on line %d : %s\n"),
- lc->str, lc->line_no, lc->line);
- }
+ RES *res = GetResWithName(R_CLIENT, lc->str);
+ if (res == NULL) {
+ scan_err3(lc, _("Could not find config Resource %s referenced on line %d : %s\n"),
+ lc->str, lc->line_no, lc->line);
+ }
- ((RUNSCRIPT*) item->value)->set_target(lc->str);
+ ((RUNSCRIPT*) item->value)->set_target(lc->str);
}
}
scan_to_eol(lc);
script->set_command(lc->str);
if (strcmp(item->name, "runbeforejob") == 0) {
- script->when = SCRIPT_Before;
- script->abort_on_error = true;
+ script->when = SCRIPT_Before;
+ script->abort_on_error = true;
} else if (strcmp(item->name, "runafterjob") == 0) {
- script->when = SCRIPT_After;
- script->on_success = true;
- script->on_failure = false;
-
+ script->when = SCRIPT_After;
+ script->on_success = true;
+ script->on_failure = false;
+
} else if (strcmp(item->name, "clientrunafterjob") == 0) {
- script->when = SCRIPT_After;
- script->set_target("%c");
- script->on_success = true;
- script->on_failure = false;
+ script->when = SCRIPT_After;
+ script->set_target("%c");
+ script->on_success = true;
+ script->on_failure = false;
} else if (strcmp(item->name, "clientrunbeforejob") == 0) {
- script->when = SCRIPT_Before;
- script->set_target("%c");
- script->abort_on_error = true;
+ script->when = SCRIPT_Before;
+ script->set_target("%c");
+ script->abort_on_error = true;
} else if (strcmp(item->name, "runafterfailedjob") == 0) {
- script->when = SCRIPT_After;
- script->on_failure = true;
- script->on_success = false;
+ script->when = SCRIPT_After;
+ script->on_failure = true;
+ script->on_success = false;
}
if (*runscripts == NULL) {
* name handler value code flags default_value
*/
static RES_ITEM runscript_items[] = {
- {"command", store_runscript_cmd, (char **)&res_runscript, 0, ITEM_REQUIRED, 0},
- {"target", store_runscript_target, (char **)&res_runscript, 0, 0, 0},
- {"runsonsuccess", store_bool, (char **)&res_runscript.on_success, 0, 0, 0},
- {"runsonfailure", store_bool, (char **)&res_runscript.on_failure, 0, 0, 0},
- {"abortjobonerror", store_bool, (char **)&res_runscript.abort_on_error, 0, 0, 0},
- {"runswhen", store_runscript_when, (char **)&res_runscript.when, 0, 0, 0},
- {"runsonclient", store_runscript_target, (char **)&res_runscript, 0, 0, 0}, /* TODO */
-
- {NULL, NULL, NULL, 0, 0, 0}
+ {"command", store_runscript_cmd, ITEM(res_runscript), 0, ITEM_REQUIRED, 0},
+ {"target", store_runscript_target, ITEM(res_runscript), 0, 0, 0},
+ {"runsonsuccess", store_bool, ITEM(res_runscript.on_success), 0, 0, 0},
+ {"runsonfailure", store_bool, ITEM(res_runscript.on_failure), 0, 0, 0},
+ {"abortjobonerror", store_bool, ITEM(res_runscript.abort_on_error), 0, 0, 0},
+ {"runswhen", store_runscript_when, ITEM(res_runscript.when), 0, 0, 0},
+ {"runsonclient", store_runscript_target, ITEM(res_runscript), 0, 0, 0}, /* TODO */
+ {NULL, NULL, {0}, 0, 0, 0}
};
/*
if (pass == 2) {
if (res_runscript.command == NULL) {
- scan_err2(lc, _("%s item is required in %s resource, but not found.\n"),
- "command", "runscript");
+ scan_err2(lc, _("%s item is required in %s resource, but not found.\n"),
+ "command", "runscript");
}
/* run on client by default */
if (res_runscript.target == NULL) {
- res_runscript.set_target("%c");
+ res_runscript.set_target("%c");
}
RUNSCRIPT *script = new_runscript();
char *pool_type; /* Pool type */
char *label_format; /* Label format string */
char *cleaning_prefix; /* Cleaning label prefix */
- int LabelType; /* Bacula/ANSI/IBM label type */
+ int32_t LabelType; /* Bacula/ANSI/IBM label type */
uint32_t max_volumes; /* max number of volumes */
utime_t VolRetention; /* volume retention period in seconds */
utime_t VolUseDuration; /* duration volume can be used */
COUNTER res_counter;
DEVICE res_dev;
RES hdr;
+ RUNSCRIPT res_runscript;
};
* name handler value code flags default_value
*/
static RES_ITEM newinc_items[] = {
- {"file", store_fname, NULL, 0, 0, 0},
- {"options", options_res, NULL, 0, 0, 0},
- {NULL, NULL, NULL, 0, 0, 0}
+ {"file", store_fname, {0}, 0, 0, 0},
+ {"options", options_res, {0}, 0, 0, 0},
+ {NULL, NULL, {0}, 0, 0, 0}
};
/*
* Items that are valid in an Options resource
*/
static RES_ITEM options_items[] = {
- {"compression", store_opts, NULL, 0, 0, 0},
- {"signature", store_opts, NULL, 0, 0, 0},
- {"verify", store_opts, NULL, 0, 0, 0},
- {"onefs", store_opts, NULL, 0, 0, 0},
- {"recurse", store_opts, NULL, 0, 0, 0},
- {"sparse", store_opts, NULL, 0, 0, 0},
- {"hardlinks", store_opts, NULL, 0, 0, 0},
- {"readfifo", store_opts, NULL, 0, 0, 0},
- {"replace", store_opts, NULL, 0, 0, 0},
- {"portable", store_opts, NULL, 0, 0, 0},
- {"mtimeonly", store_opts, NULL, 0, 0, 0},
- {"keepatime", store_opts, NULL, 0, 0, 0},
- {"regex", store_regex, NULL, 0, 0, 0},
- {"regexdir", store_regex, NULL, 1, 0, 0},
- {"regexfile", store_regex, NULL, 2, 0, 0},
- {"base", store_base, NULL, 0, 0, 0},
- {"wild", store_wild, NULL, 0, 0, 0},
- {"wilddir", store_wild, NULL, 1, 0, 0},
- {"wildfile", store_wild, NULL, 2, 0, 0},
- {"exclude", store_opts, NULL, 0, 0, 0},
- {"aclsupport", store_opts, NULL, 0, 0, 0},
- {"reader", store_reader, NULL, 0, 0, 0},
- {"writer", store_writer, NULL, 0, 0, 0},
- {"ignorecase", store_opts, NULL, 0, 0, 0},
- {"fstype", store_fstype, NULL, 0, 0, 0},
- {"hfsplussupport", store_opts, NULL, 0, 0, 0},
- {"noatime", store_opts, NULL, 0, 0, 0},
- {NULL, NULL, NULL, 0, 0, 0}
+ {"compression", store_opts, {0}, 0, 0, 0},
+ {"signature", store_opts, {0}, 0, 0, 0},
+ {"verify", store_opts, {0}, 0, 0, 0},
+ {"onefs", store_opts, {0}, 0, 0, 0},
+ {"recurse", store_opts, {0}, 0, 0, 0},
+ {"sparse", store_opts, {0}, 0, 0, 0},
+ {"hardlinks", store_opts, {0}, 0, 0, 0},
+ {"readfifo", store_opts, {0}, 0, 0, 0},
+ {"replace", store_opts, {0}, 0, 0, 0},
+ {"portable", store_opts, {0}, 0, 0, 0},
+ {"mtimeonly", store_opts, {0}, 0, 0, 0},
+ {"keepatime", store_opts, {0}, 0, 0, 0},
+ {"regex", store_regex, {0}, 0, 0, 0},
+ {"regexdir", store_regex, {0}, 1, 0, 0},
+ {"regexfile", store_regex, {0}, 2, 0, 0},
+ {"base", store_base, {0}, 0, 0, 0},
+ {"wild", store_wild, {0}, 0, 0, 0},
+ {"wilddir", store_wild, {0}, 1, 0, 0},
+ {"wildfile", store_wild, {0}, 2, 0, 0},
+ {"exclude", store_opts, {0}, 0, 0, 0},
+ {"aclsupport", store_opts, {0}, 0, 0, 0},
+ {"reader", store_reader, {0}, 0, 0, 0},
+ {"writer", store_writer, {0}, 0, 0, 0},
+ {"ignorecase", store_opts, {0}, 0, 0, 0},
+ {"fstype", store_fstype, {0}, 0, 0, 0},
+ {"hfsplussupport", store_opts, {0}, 0, 0, 0},
+ {"noatime", store_opts, {0}, 0, 0, 0},
+ {NULL, NULL, {0}, 0, 0, 0}
};
#include "bacula.h"
+/*
+ * If compatible is true, the bin_to_base64 routine will be compatible
+ * with what the rest of the world uses. However, this would destroy
+ * existing database compatibility.
+ */
const bool compatible = false;
#ifdef TEST_MODE
if (rem < 6) {
reg <<= 8;
if (compatible) {
- reg |= (int8_t)bin[i++] & 0xFF;
+ reg |= (uint8_t)bin[i++];
} else {
- reg |= (int8_t)bin[i++];
+ reg |= (int8_t)bin[i++];
}
rem += 8;
}
rem -= 6;
}
if (rem) {
+#ifdef OLDxxxx
mask = 1;
for (i=1; i<rem; i++) {
mask = (mask << 1) | 1;
}
+#else
+ mask = (1 << rem) - 1;
+#endif
if (compatible) {
buf[j++] = base64_digits[(reg & mask) << 6 - rem];
} else {
*/
/*
- Copyright (C) 2000-2005 Kern Sibbald
+ Copyright (C) 2000-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
*/
/* Maximum size of len bytes after base64 encoding */
-#define BASE64_SIZE(len) (((len + 3 - (len % 3)) / 3) * 4)
+#define BASE64_SIZE(len) ((4 * len + 2) / 3 + 1)
+
+// #define BASE64_SIZE(len) (((len + 3 - (len % 3)) / 3) * 4)
#include "bacula.h"
#include "bregex.h"
-#define set_error(x) bufp->errmsg=(x)
+#define set_error(x) bufp->errmsg=((char *)(x))
#define got_error bufp->errmsg!=NULL
/* The original code blithely assumed that sizeof(short) == 2. Not
} \
}
-char *re_compile_pattern(regex_t * bufp, unsigned char *regex)
+const char *re_compile_pattern(regex_t * bufp, unsigned char *regex)
{
int a;
int pos;
/* This sets the syntax to use and returns the previous syntax. The
* syntax is specified by a bit mask of the above defined bits. */
-char *re_compile_pattern(regex_t *compiled, unsigned char *regex);
+const char *re_compile_pattern(regex_t *compiled, unsigned char *regex);
/* This compiles the regexp (given in regex and length in regex_size).
* This returns NULL if the regexp compiled successfully, and an error
* message if an error was encountered. The buffer field must be
{
int errstat;
- if ((errstat=pthread_mutex_trylock(m)) == 0) {
+ if ((errstat=pthread_mutex_tryunlock(m)) == 0) {
berrno be;
e_msg(file, line, M_ERROR, 0, _("Mutex unlock not locked. ERR=%s\n"),
be.strerror(errstat));
{"director", store_msgs, ITEM(res_msgs), MD_DIRECTOR, 0, 0},
{"console", store_msgs, ITEM(res_msgs), MD_CONSOLE, 0, 0},
{"operator", store_msgs, ITEM(res_msgs), MD_OPERATOR, 0, 0},
- {NULL, NULL, NULL, 0, 0}
+ {NULL, NULL, {0}, 0, 0, 0}
};
struct s_mtypes {
*/
struct RES_ITEM; /* Declare forward referenced structure */
+struct RES; /* Declare forware referenced structure */
typedef void (MSG_RES_HANDLER)(LEX *lc, RES_ITEM *item, int index, int pass);
/* This is the structure that defines
struct RES_ITEM {
const char *name; /* Resource name i.e. Director, ... */
MSG_RES_HANDLER *handler; /* Routine storing the resource item */
- char **value; /* Where to store the item */
+ union {
+ char **value; /* Where to store the item */
+ char **charvalue;
+ uint32_t ui32value;
+ int32_t i32value;
+ uint64_t ui64value;
+ int64_t i64value;
+ bool boolvalue;
+ utime_t utimevalue;
+ RES *resvalue;
+ RES **presvalue;
+ };
int code; /* item code/additional info */
int flags; /* flags: default, required, ... */
int default_value; /* default value */
};
/* For storing name_addr items in res_items table */
-#define ITEM(x) ((char **)&res_all.x)
+#define ITEM(x) {(char **)&res_all.x}
#define MAX_RES_ITEMS 70 /* maximum resource items per RES */
#ifndef __RUNSCRIPT_H_
#define __RUNSCRIPT_H_ 1
-#if defined(FILE_DAEMON) || defined(DIRECTOR_DAEMON)
-# define USE_RUNSCRIPT
-#endif
-
-#ifdef USE_RUNSCRIPT
-
/* Usage:
*
* #define USE_RUNSCRIPT
* RUNSCRIPT->when can take following value :
*/
enum {
- SCRIPT_Never = 0,
- SCRIPT_After = 1, /* AfterJob */
- SCRIPT_Before = 2, /* BeforeJob */
- SCRIPT_Any = 3 /* Before and After */
+ SCRIPT_Never = 1,
+ SCRIPT_After = 2, /* AfterJob */
+ SCRIPT_Before = 3, /* BeforeJob */
+ SCRIPT_Any = 4 /* Before and After */
};
/*
*/
class RUNSCRIPT {
public:
- POOLMEM *command; /* command string */
- POOLMEM *target; /* host target */
- char level; /* Base|Full|Incr...|All (NYI) */
- bool on_success; /* executre command on job success (After) */
+ POOLMEM *command; /* command string */
+ POOLMEM *target; /* host target */
+ char level; /* Base|Full|Incr...|All (NYI) */
+ bool on_success; /* executre command on job success (After) */
bool on_failure; /* executre command on job failure (After) */
bool abort_on_error; /* abort job on error (Before) */
int when; /* SCRIPT_Before|Script_After BEFORE/AFTER JOB*/
void set_command(const POOLMEM *cmd);
void set_target(const POOLMEM *client_name);
void reset_default(bool free_string = false);
- bool is_local(); /* true if running on local host */
+ bool is_local(); /* true if running on local host */
void debug();
};
/* foreach_alist free RUNSCRIPT */
void free_runscripts(alist *runscripts); /* you have to free alist */
-#endif /* USE_RUNSCRIPT */
-
#endif /* __RUNSCRIPT_H_ */
*
*/
/*
- Copyright (C) 2002-2005 Kern Sibbald
+ Copyright (C) 2002-2006 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
#include "bacula.h"
#include "cats/cats.h"
+#include "lib/runscript.h"
#include "dird/dird_conf.h"
/* Dummy functions */
*/
#undef VERSION
-#define VERSION "1.39.12"
-#define BDATE "01 June 2006"
-#define LSMDATE "01Jun06"
+#define VERSION "1.39.14"
+#define BDATE "22 June 2006"
+#define LSMDATE "22Jun06"
/* Debug flags */
#undef DEBUG