From: Kern Sibbald Date: Wed, 18 Feb 2009 20:11:55 +0000 (+0000) Subject: Apply Eric's next-beta.patch that enables 64 bit FileIds and X-Git-Tag: Release-3.0.0~212 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ca619c2715fa90cb2ac2db4dab0cc68f9bd6175c;p=bacula%2Fbacula Apply Eric's next-beta.patch that enables 64 bit FileIds and adds new columns to the catalog. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8478 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/ReleaseNotes b/bacula/ReleaseNotes index 21b381cdbd..0bff19ea3d 100644 --- a/bacula/ReleaseNotes +++ b/bacula/ReleaseNotes @@ -6,8 +6,7 @@ This Director and Storage daemon must be upgraded at the same time, but they should be compatible with all 2.4.x File daemons, unless you use some of the new features that affect the FD. In other words, you should -not have to upgrade all your File daemons when you upgrade. There is -no database upgrade needed from version 2.4.x. However, the next +not have to upgrade all your File daemons when you upgrade. However, the next BETA release will require a database upgrade. ================== Warning !!!!!! ========================== diff --git a/bacula/src/bc_types.h b/bacula/src/bc_types.h index 76ecd86d58..4a7c30de53 100644 --- a/bacula/src/bc_types.h +++ b/bacula/src/bc_types.h @@ -57,7 +57,7 @@ * In principle, the only field that really should need to be * 64 bits is the FileId_t */ -typedef uint32_t FileId_t; +typedef uint64_t FileId_t; typedef uint32_t DBId_t; /* general DB id type */ typedef uint32_t JobId_t; diff --git a/bacula/src/cats/cats.h b/bacula/src/cats/cats.h index baf8517b58..9431685fe1 100644 --- a/bacula/src/cats/cats.h +++ b/bacula/src/cats/cats.h @@ -88,7 +88,7 @@ typedef int (DB_RESULT_HANDLER)(void *, int, char **); #if defined(BUILDING_CATS) #ifdef HAVE_SQLITE -#define BDB_VERSION 10 +#define BDB_VERSION 11 #include @@ -208,7 +208,7 @@ extern const char* my_sqlite_batch_fill_path_query; #ifdef HAVE_SQLITE3 -#define BDB_VERSION 10 +#define BDB_VERSION 11 #include @@ -334,7 +334,7 @@ extern const char* my_sqlite_batch_fill_path_query; #ifdef HAVE_MYSQL -#define BDB_VERSION 10 +#define BDB_VERSION 11 #include @@ -417,7 +417,7 @@ extern void my_mysql_free_result(B_DB *mdb); #ifdef HAVE_POSTGRESQL -#define BDB_VERSION 10 +#define BDB_VERSION 11 #include @@ -531,7 +531,7 @@ extern const char* my_pg_batch_fill_path_query; #ifdef HAVE_DBI -#define BDB_VERSION 10 +#define BDB_VERSION 11 #include @@ -790,6 +790,7 @@ struct JOB_DBR { uint32_t JobErrors; uint32_t JobMissingFiles; uint64_t JobBytes; + uint64_t ReadBytes; int PurgedFiles; int HasBase; diff --git a/bacula/src/cats/drop_mysql_tables.in b/bacula/src/cats/drop_mysql_tables.in index d9918940cb..6c2ef32828 100644 --- a/bacula/src/cats/drop_mysql_tables.in +++ b/bacula/src/cats/drop_mysql_tables.in @@ -16,7 +16,7 @@ DROP TABLE IF EXISTS MediaType; DROP TABLE IF EXISTS File; DROP TABLE IF EXISTS Client; DROP TABLE IF EXISTS Job; -DROP TABLE IF EXISTS JobHistory; +DROP TABLE IF EXISTS JobHisto; DROP TABLE IF EXISTS Media; DROP TABLE IF EXISTS JobMedia; DROP TABLE IF EXISTS Pool; diff --git a/bacula/src/cats/drop_postgresql_tables.in b/bacula/src/cats/drop_postgresql_tables.in index bcbd1fdd18..71c45b571c 100644 --- a/bacula/src/cats/drop_postgresql_tables.in +++ b/bacula/src/cats/drop_postgresql_tables.in @@ -11,7 +11,7 @@ drop table basefiles; drop table jobmedia; drop table file; drop table job; -drop table jobhistory; +drop table jobhisto; drop table media; drop table client; drop table pool; diff --git a/bacula/src/cats/grant_postgresql_privileges.in b/bacula/src/cats/grant_postgresql_privileges.in index 5532dbe9a2..d426874e97 100644 --- a/bacula/src/cats/grant_postgresql_privileges.in +++ b/bacula/src/cats/grant_postgresql_privileges.in @@ -32,7 +32,7 @@ grant all on status to ${db_user}; grant all on location to ${db_user}; grant all on locationlog to ${db_user}; grant all on log to ${db_user}; -grant all on jobhistory to ${db_user}; +grant all on jobhisto to ${db_user}; -- for sequences on those tables diff --git a/bacula/src/cats/make_mysql_tables.in b/bacula/src/cats/make_mysql_tables.in index 7fdea045c6..56f49f8d16 100644 --- a/bacula/src/cats/make_mysql_tables.in +++ b/bacula/src/cats/make_mysql_tables.in @@ -29,7 +29,7 @@ CREATE TABLE Path ( CREATE TABLE File ( - FileId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + FileId BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, FileIndex INTEGER UNSIGNED DEFAULT 0, JobId INTEGER UNSIGNED NOT NULL REFERENCES Job, PathId INTEGER UNSIGNED NOT NULL REFERENCES Path, @@ -104,6 +104,7 @@ CREATE TABLE Job ( VolSessionTime INTEGER UNSIGNED DEFAULT 0, JobFiles INTEGER UNSIGNED DEFAULT 0, JobBytes BIGINT UNSIGNED DEFAULT 0, + ReadBytes BIGINT UNSIGNED DEFAULT 0, JobErrors INTEGER UNSIGNED DEFAULT 0, JobMissingFiles INTEGER UNSIGNED DEFAULT 0, PoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool, @@ -116,7 +117,33 @@ CREATE TABLE Job ( ); -- Create a table like Job for long term statistics -CREATE TABLE JobHistory (LIKE Job); +CREATE TABLE JobHisto ( + JobId INTEGER UNSIGNED NOT NULL, + Job TINYBLOB NOT NULL, + Name TINYBLOB NOT NULL, + Type BINARY(1) NOT NULL, + Level BINARY(1) NOT NULL, + ClientId INTEGER DEFAULT 0, + JobStatus BINARY(1) NOT NULL, + SchedTime DATETIME DEFAULT 0, + 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, + ReadBytes BIGINT UNSIGNED DEFAULT 0, + JobErrors INTEGER UNSIGNED DEFAULT 0, + JobMissingFiles INTEGER UNSIGNED DEFAULT 0, + PoolId INTEGER UNSIGNED DEFAULT 0, + FileSetId INTEGER UNSIGNED DEFAULT 0, + PriorJobId INTEGER UNSIGNED DEFAULT 0, + PurgedFiles TINYINT DEFAULT 0, + HasBase TINYINT DEFAULT 0, + INDEX (StartTime) + ); CREATE TABLE Location ( LocationId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, @@ -190,6 +217,7 @@ CREATE TABLE Media ( 'Read-Only', 'Disabled', 'Error', 'Busy', 'Used', 'Cleaning') NOT NULL, Enabled TINYINT DEFAULT 1, Recycle TINYINT DEFAULT 0, + ActionOnPurge TINYINT DEFAULT 0, VolRetention BIGINT UNSIGNED DEFAULT 0, VolUseDuration BIGINT UNSIGNED DEFAULT 0, MaxVolJobs INTEGER UNSIGNED DEFAULT 0, @@ -229,6 +257,7 @@ CREATE TABLE Pool ( MaxVolBytes BIGINT UNSIGNED DEFAULT 0, AutoPrune TINYINT DEFAULT 0, Recycle TINYINT DEFAULT 0, + ActionOnPurge TINYINT DEFAULT 0, PoolType ENUM('Backup', 'Copy', 'Cloned', 'Archive', 'Migration', 'Scratch') NOT NULL, LabelType TINYINT DEFAULT 0, LabelFormat TINYBLOB, @@ -269,7 +298,7 @@ CREATE TABLE BaseFiles ( BaseId INTEGER UNSIGNED AUTO_INCREMENT, BaseJobId INTEGER UNSIGNED NOT NULL REFERENCES Job, JobId INTEGER UNSIGNED NOT NULL REFERENCES Job, - FileId INTEGER UNSIGNED NOT NULL REFERENCES File, + FileId BIGINT UNSIGNED NOT NULL REFERENCES File, FileIndex INTEGER UNSIGNED, PRIMARY KEY(BaseId) ); @@ -333,7 +362,7 @@ CREATE TABLE Version ( ); -- Initialize Version -INSERT INTO Version (VersionId) VALUES (10); +INSERT INTO Version (VersionId) VALUES (11); END-OF-DATA then diff --git a/bacula/src/cats/make_postgresql_tables.in b/bacula/src/cats/make_postgresql_tables.in index 051a17588c..bd136c6a0b 100644 --- a/bacula/src/cats/make_postgresql_tables.in +++ b/bacula/src/cats/make_postgresql_tables.in @@ -15,7 +15,7 @@ CREATE TABLE filename ); ALTER TABLE filename ALTER COLUMN name SET STATISTICS 1000; -CREATE INDEX filename_name_idx on filename (name); +CREATE UNIQUE INDEX filename_name_idx on filename (name); CREATE TABLE path ( @@ -25,11 +25,11 @@ CREATE TABLE path ); ALTER TABLE path ALTER COLUMN path SET STATISTICS 1000; -CREATE INDEX path_name_idx on path (path); +CREATE UNIQUE INDEX path_name_idx on path (path); CREATE TABLE file ( - fileid serial not null, + fileid bigserial not null, fileindex integer not null default 0, jobid integer not null, pathid integer not null, @@ -74,6 +74,7 @@ CREATE TABLE job volsessiontime integer default 0, jobfiles integer default 0, jobbytes bigint default 0, + readbytes bigint default 0, joberrors integer default 0, jobmissingfiles integer default 0, poolid integer default 0, @@ -87,7 +88,9 @@ CREATE TABLE job CREATE INDEX job_name_idx on job (name); -- Create a table like Job for long term statistics -CREATE TABLE JobHistory (LIKE Job); +CREATE TABLE JobHisto (LIKE Job); +CREATE INDEX jobhisto_idx ON jobhisto ( starttime ); + CREATE TABLE Location ( LocationId serial not null, @@ -154,6 +157,7 @@ CREATE TABLE media 'Error','Busy','Used','Cleaning','Scratch')), enabled smallint default 1, recycle smallint default 0, + ActionOnPurge smallint default 0, volretention bigint default 0, voluseduration bigint default 0, maxvoljobs integer default 0, @@ -229,6 +233,7 @@ CREATE TABLE pool maxvolbytes bigint default 0, autoprune smallint default 0, recycle smallint default 0, + ActionOnPurge smallint default 0, pooltype text check (pooltype in ('Backup','Copy','Cloned','Archive','Migration','Scratch')), labeltype integer default 0, @@ -300,7 +305,7 @@ CREATE TABLE basefiles ( baseid serial not null, jobid integer not null, - fileid integer not null, + fileid bigint not null, fileindex integer , basejobid integer , primary key (baseid) @@ -377,7 +382,7 @@ INSERT INTO Status (JobStatus,JobStatusLong) VALUES INSERT INTO Status (JobStatus,JobStatusLong) VALUES ('i', 'Doing batch insert file records'); -INSERT INTO Version (VersionId) VALUES (10); +INSERT INTO Version (VersionId) VALUES (11); -- Make sure we have appropriate permissions diff --git a/bacula/src/cats/make_sqlite3_tables.in b/bacula/src/cats/make_sqlite3_tables.in index d997317102..8f1ce00833 100644 --- a/bacula/src/cats/make_sqlite3_tables.in +++ b/bacula/src/cats/make_sqlite3_tables.in @@ -64,6 +64,7 @@ CREATE TABLE Job ( VolSessionTime INTEGER UNSIGNED DEFAULT 0, JobFiles INTEGER UNSIGNED DEFAULT 0, JobBytes BIGINT UNSIGNED DEFAULT 0, + ReadBytes BIGINT UNSIGNED DEFAULT 0, JobErrors INTEGER UNSIGNED DEFAULT 0, JobMissingFiles INTEGER UNSIGNED DEFAULT 0, PoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0, @@ -76,13 +77,13 @@ CREATE TABLE Job ( CREATE INDEX inx6 ON Job (Name); -- Create a table like Job for long term statistics -CREATE TABLE JobHistory ( +CREATE TABLE JobHisto ( JobId INTEGER, Job VARCHAR(128) NOT NULL, Name VARCHAR(128) NOT NULL, Type CHAR(1) NOT NULL, Level CHAR(1) NOT NULL, - ClientId INTEGER REFERENCES Client DEFAULT 0, + ClientId INTEGER DEFAULT 0, JobStatus CHAR(1) NOT NULL, SchedTime DATETIME NOT NULL, StartTime DATETIME DEFAULT 0, @@ -93,16 +94,16 @@ CREATE TABLE JobHistory ( VolSessionTime INTEGER UNSIGNED DEFAULT 0, JobFiles INTEGER UNSIGNED DEFAULT 0, JobBytes BIGINT UNSIGNED DEFAULT 0, + ReadBytes 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, + PoolId INTEGER UNSIGNED DEFAULT 0, + FileSetId INTEGER UNSIGNED DEFAULT 0, + PriorJobId INTEGER UNSIGNED DEFAULT 0, PurgedFiles TINYINT DEFAULT 0, - HasBase TINYINT DEFAULT 0, - PRIMARY KEY(JobId) + HasBase TINYINT DEFAULT 0 ); -CREATE INDEX inx61 ON JobHistory (Name); +CREATE INDEX inx61 ON JobHisto (StartTime); CREATE TABLE Location ( LocationId INTEGER, @@ -183,6 +184,7 @@ CREATE TABLE Media ( VolStatus VARCHAR(20) NOT NULL, Enabled TINYINT DEFAULT 1, Recycle TINYINT DEFAULT 0, + ActionOnPurge TINYINT DEFAULT 0, VolRetention BIGINT UNSIGNED DEFAULT 0, VolUseDuration BIGINT UNSIGNED DEFAULT 0, MaxVolJobs INTEGER UNSIGNED DEFAULT 0, @@ -256,6 +258,7 @@ CREATE TABLE Pool ( MaxVolBytes BIGINT UNSIGNED DEFAULT 0, AutoPrune TINYINT DEFAULT 0, Recycle TINYINT DEFAULT 0, + ActionOnPurge TINYINT DEFAULT 0, PoolType VARCHAR(20) NOT NULL, LabelType TINYINT DEFAULT 0, LabelFormat VARCHAR(128) NOT NULL, @@ -383,7 +386,7 @@ INSERT INTO Status (JobStatus,JobStatusLong) VALUES -- Initialize Version -INSERT INTO Version (VersionId) VALUES (10); +INSERT INTO Version (VersionId) VALUES (11); PRAGMA default_cache_size = 100000; diff --git a/bacula/src/cats/make_sqlite_tables.in b/bacula/src/cats/make_sqlite_tables.in index b98d39770d..9bd0a481e8 100644 --- a/bacula/src/cats/make_sqlite_tables.in +++ b/bacula/src/cats/make_sqlite_tables.in @@ -64,6 +64,7 @@ CREATE TABLE Job ( VolSessionTime INTEGER UNSIGNED DEFAULT 0, JobFiles INTEGER UNSIGNED DEFAULT 0, JobBytes BIGINT UNSIGNED DEFAULT 0, + ReadBytes BIGINT UNSIGNED DEFAULT 0, JobErrors INTEGER UNSIGNED DEFAULT 0, JobMissingFiles INTEGER UNSIGNED DEFAULT 0, PoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0, @@ -76,13 +77,13 @@ CREATE TABLE Job ( CREATE INDEX inx6 ON Job (Name); -- Create a table like Job for long term statistics -CREATE TABLE JobHistory ( +CREATE TABLE JobHisto ( JobId INTEGER, Job VARCHAR(128) NOT NULL, Name VARCHAR(128) NOT NULL, Type CHAR(1) NOT NULL, Level CHAR(1) NOT NULL, - ClientId INTEGER REFERENCES Client DEFAULT 0, + ClientId INTEGER DEFAULT 0, JobStatus CHAR(1) NOT NULL, SchedTime DATETIME NOT NULL, StartTime DATETIME DEFAULT 0, @@ -93,16 +94,16 @@ CREATE TABLE JobHistory ( VolSessionTime INTEGER UNSIGNED DEFAULT 0, JobFiles INTEGER UNSIGNED DEFAULT 0, JobBytes BIGINT UNSIGNED DEFAULT 0, + ReadBytes 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, + PoolId INTEGER UNSIGNED DEFAULT 0, + FileSetId INTEGER UNSIGNED DEFAULT 0, + PriorJobId INTEGER UNSIGNED DEFAULT 0, PurgedFiles TINYINT DEFAULT 0, - HasBase TINYINT DEFAULT 0, - PRIMARY KEY(JobId) + HasBase TINYINT DEFAULT 0 ); -CREATE INDEX inx61 ON JobHistory (Name); +CREATE INDEX inx61 ON JobHisto (StartTime); CREATE TABLE Location ( LocationId INTEGER, @@ -183,6 +184,7 @@ CREATE TABLE Media ( VolStatus VARCHAR(20) NOT NULL, Enabled TINYINT DEFAULT 1, Recycle TINYINT DEFAULT 0, + ActionOnPurge TINYINT DEFAULT 0, VolRetention BIGINT UNSIGNED DEFAULT 0, VolUseDuration BIGINT UNSIGNED DEFAULT 0, MaxVolJobs INTEGER UNSIGNED DEFAULT 0, @@ -256,6 +258,7 @@ CREATE TABLE Pool ( MaxVolBytes BIGINT UNSIGNED DEFAULT 0, AutoPrune TINYINT DEFAULT 0, Recycle TINYINT DEFAULT 0, + ActionOnPurge TINYINT DEFAULT 0, PoolType VARCHAR(20) NOT NULL, LabelType TINYINT DEFAULT 0, LabelFormat VARCHAR(128) NOT NULL, @@ -383,7 +386,7 @@ INSERT INTO Status (JobStatus,JobStatusLong) VALUES -- Initialize Version -INSERT INTO Version (VersionId) VALUES (10); +INSERT INTO Version (VersionId) VALUES (11); PRAGMA default_synchronous = OFF; diff --git a/bacula/src/cats/sql_cmds.c b/bacula/src/cats/sql_cmds.c index 87c16b5044..a96b789a04 100644 --- a/bacula/src/cats/sql_cmds.c +++ b/bacula/src/cats/sql_cmds.c @@ -44,6 +44,26 @@ #include "bacula.h" #include "cats.h" + +/* For sql_update.c db_update_stats */ +const char *fill_jobhisto = + "INSERT INTO JobHisto (" + "JobId, Job, Name, Type, Level, ClientId, JobStatus, " + "SchedTime, StartTime, EndTime, RealEndTime, JobTDate, " + "VolSessionId, VolSessionTime, JobFiles, JobBytes, ReadBytes, " + "JobErrors, JobMissingFiles, PoolId, FileSetId, PriorJobId, " + "PurgedFiles, HasBase ) " + "SELECT " + "JobId, Job, Name, Type, Level, ClientId, JobStatus, " + "SchedTime, StartTime, EndTime, RealEndTime, JobTDate, " + "VolSessionId, VolSessionTime, JobFiles, JobBytes, ReadBytes, " + "JobErrors, JobMissingFiles, PoolId, FileSetId, PriorJobId, " + "PurgedFiles, HasBase " + "FROM Job " + "WHERE JobStatus IN ('T', 'f', 'A', 'E') " + "AND JobId NOT IN (SELECT JobId FROM JobHisto) " + "AND JobTDate < %s "; + /* For ua_update.c */ const char *list_pool = "SELECT * FROM Pool WHERE PoolId=%s"; diff --git a/bacula/src/cats/sql_cmds.h b/bacula/src/cats/sql_cmds.h index 9dbc16e40b..438f7591b0 100644 --- a/bacula/src/cats/sql_cmds.h +++ b/bacula/src/cats/sql_cmds.h @@ -26,7 +26,7 @@ Switzerland, email:ftf@fsfeurope.org. */ - +extern const char CATS_IMP_EXP *fill_jobhisto; extern const char CATS_IMP_EXP *client_backups; extern const char CATS_IMP_EXP *list_pool; extern const char CATS_IMP_EXP *drop_deltabs[]; diff --git a/bacula/src/cats/sql_get.c b/bacula/src/cats/sql_get.c index dd6a29acfc..f658e7432a 100644 --- a/bacula/src/cats/sql_get.c +++ b/bacula/src/cats/sql_get.c @@ -297,13 +297,13 @@ bool db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) Mmsg(mdb->cmd, "SELECT VolSessionId,VolSessionTime," "PoolId,StartTime,EndTime,JobFiles,JobBytes,JobTDate,Job,JobStatus," "Type,Level,ClientId,Name,PriorJobId,RealEndTime,JobId,FileSetId," -"SchedTime,RealEndTime " +"SchedTime,RealEndTime,ReadBytes " "FROM Job WHERE Job='%s'", jr->Job); } else { Mmsg(mdb->cmd, "SELECT VolSessionId,VolSessionTime," "PoolId,StartTime,EndTime,JobFiles,JobBytes,JobTDate,Job,JobStatus," "Type,Level,ClientId,Name,PriorJobId,RealEndTime,JobId,FileSetId," -"SchedTime,RealEndTime " +"SchedTime,RealEndTime,ReadBytes " "FROM Job WHERE JobId=%s", edit_int64(jr->JobId, ed1)); } @@ -341,6 +341,7 @@ bool db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) jr->FileSetId = str_to_int64(row[17]); bstrncpy(jr->cSchedTime, row[3]!=NULL?row[18]:"", sizeof(jr->cSchedTime)); bstrncpy(jr->cRealEndTime, row[3]!=NULL?row[19]:"", sizeof(jr->cRealEndTime)); + jr->ReadBytes = str_to_int64(row[20]); jr->StartTime = str_to_utime(jr->cStartTime); jr->SchedTime = str_to_utime(jr->cSchedTime); jr->EndTime = str_to_utime(jr->cEndTime); diff --git a/bacula/src/cats/sql_update.c b/bacula/src/cats/sql_update.c index 8c713aa70f..92ecffdfc5 100644 --- a/bacula/src/cats/sql_update.c +++ b/bacula/src/cats/sql_update.c @@ -136,13 +136,7 @@ db_update_stats(JCR *jcr, B_DB *mdb, utime_t age) utime_t now = (utime_t)time(NULL); edit_uint64(now - age, ed1); - Mmsg(mdb->cmd, - "INSERT INTO JobHistory " - "SELECT * " - "FROM Job " - "WHERE JobStatus IN ('T', 'f', 'A', 'E') " - "AND JobId NOT IN (SELECT JobId FROM JobHistory) " - "AND JobTDate < %s ", ed1); + Mmsg(mdb->cmd, fill_jobhisto, ed1); QUERY_DB(jcr, mdb, mdb->cmd); /* TODO: get a message ? */ return sql_affected_rows(mdb); } @@ -161,7 +155,7 @@ db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) time_t ttime; struct tm tm; int stat; - char ed1[30], ed2[30], ed3[50]; + char ed1[30], ed2[30], ed3[50], ed4[50]; btime_t JobTDate; char PriorJobId[50]; @@ -187,10 +181,11 @@ db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) db_lock(mdb); Mmsg(mdb->cmd, "UPDATE Job SET JobStatus='%c',EndTime='%s'," -"ClientId=%u,JobBytes=%s,JobFiles=%u,JobErrors=%u,VolSessionId=%u," +"ClientId=%u,JobBytes=%s,ReadBytes=%s,JobFiles=%u,JobErrors=%u,VolSessionId=%u," "VolSessionTime=%u,PoolId=%u,FileSetId=%u,JobTDate=%s," "RealEndTime='%s',PriorJobId=%s WHERE JobId=%s", (char)(jr->JobStatus), dt, jr->ClientId, edit_uint64(jr->JobBytes, ed1), + edit_uint64(jr->ReadBytes, ed4), jr->JobFiles, jr->JobErrors, jr->VolSessionId, jr->VolSessionTime, jr->PoolId, jr->FileSetId, edit_uint64(JobTDate, ed2), rdt, diff --git a/bacula/src/cats/update_mysql_tables.in b/bacula/src/cats/update_mysql_tables.in index a66dc9c1fa..e78a13592c 100644 --- a/bacula/src/cats/update_mysql_tables.in +++ b/bacula/src/cats/update_mysql_tables.in @@ -12,16 +12,50 @@ db_name=@db_name@ if $bindir/mysql $* -f <jr.JobStatus = jcr->JobStatus; jcr->jr.JobFiles = jcr->JobFiles; jcr->jr.JobBytes = jcr->JobBytes; + jcr->jr.ReadBytes = jcr->ReadBytes; jcr->jr.VolSessionId = jcr->VolSessionId; jcr->jr.VolSessionTime = jcr->VolSessionTime; jcr->jr.JobErrors = jcr->Errors; diff --git a/bacula/src/dird/ua_prune.c b/bacula/src/dird/ua_prune.c index 257e45428e..9dc98f760d 100644 --- a/bacula/src/dird/ua_prune.c +++ b/bacula/src/dird/ua_prune.c @@ -194,12 +194,12 @@ int prune_stats(UAContext *ua, utime_t retention) utime_t now = (utime_t)time(NULL); db_lock(ua->db); - Mmsg(query, "DELETE FROM JobHistory WHERE JobTDate < %s", + Mmsg(query, "DELETE FROM JobHisto WHERE JobTDate < %s", edit_int64(now - retention, ed1)); db_sql_query(ua->db, query.c_str(), NULL, NULL); db_unlock(ua->db); - ua->info_msg(_("Pruned Jobs from JobHistory catalog.\n")); + ua->info_msg(_("Pruned Jobs from JobHisto catalog.\n")); return true; } diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index 45aa8b931a..387cc3dc97 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -26,6 +26,8 @@ mixed priorities General: 18Feb09 +kes Apply Eric's next-beta.patch that enables 64 bit FileIds and + adds new columns to the catalog. kes Ensure that libtool directory always cleaned + reduce unnecessary output during make clean. 15Feb09