From: Kern Sibbald Date: Fri, 9 Apr 2010 19:38:59 +0000 (+0200) Subject: Create and put data into RestoreObject table X-Git-Tag: Release-7.0.0~1961 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=34fa5a0e5ecb8bbfe7f1ddde176f03859909b055;p=bacula%2Fbacula Create and put data into RestoreObject table --- diff --git a/bacula/src/cats/make_mysql_tables.in b/bacula/src/cats/make_mysql_tables.in index ef2efffa41..206c52f07f 100644 --- a/bacula/src/cats/make_mysql_tables.in +++ b/bacula/src/cats/make_mysql_tables.in @@ -46,7 +46,7 @@ CREATE TABLE File ( ); CREATE TABLE RestoreObject ( - RestoreObjectId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT; + RestoreObjectId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, Fname BLOB NOT NULL, Path BLOB NOT NULL, RestoreObject BLOB NOT NULL, diff --git a/bacula/src/cats/make_postgresql_tables.in b/bacula/src/cats/make_postgresql_tables.in index a713c06a4d..34d5d61254 100644 --- a/bacula/src/cats/make_postgresql_tables.in +++ b/bacula/src/cats/make_postgresql_tables.in @@ -30,7 +30,7 @@ CREATE UNIQUE INDEX path_name_idx on path (path); CREATE TABLE file ( - fileid bigserial not null, + fileid bigserial not null, fileindex integer not null default 0, jobid integer not null, pathid integer not null, @@ -60,35 +60,50 @@ CREATE INDEX file_jobid_idx on file(jobid); -- CREATE INDEX file_pathid_idx on file(pathid); -- CREATE INDEX file_filenameid_idx on file(filenameid); +CREATE TABLE RestoreObject ( + RestoreObjectId SERIAL NOT NULL, + Fname TEXT NOT NULL, + Path TEXT NOT NULL, + RestoreObject TEXT NOT NULL, + PluginName TEXT NOT NULL, + ObjectIndex INTEGER DEFAULT 0, + ObjectType INTEGER DEFAULT 0, + FileIndex INTEGER UNSIGNED DEFAULT 0, + JobId INTEGER UNSIGNED, + PRIMARY KEY(RestoreObjectId), + ); +CREATE INDEX restore_jobid_idx on file(JobId); + + CREATE TABLE Job ( - JobId serial not null, - Job text not null, - Name text not null, - Type char(1) not null, - Level char(1) not null, - ClientId integer default 0, - JobStatus char(1) not null, - SchedTime timestamp without time zone, - StartTime timestamp without time zone, - EndTime timestamp without time zone, + JobId serial not null, + Job text not null, + Name text not null, + Type char(1) not null, + Level char(1) not null, + ClientId integer default 0, + JobStatus char(1) not null, + SchedTime timestamp without time zone, + StartTime timestamp without time zone, + EndTime timestamp without time zone, RealEndTime timestamp without time zone, - JobTDate bigint default 0, - VolSessionId integer default 0, - 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, - FilesetId integer default 0, - PriorJobid integer default 0, - PurgedFiles smallint default 0, - HasBase smallint default 0, - HasCache smallint default 0, - Reviewed smallint default 0, - Comment text, + JobTDate bigint default 0, + VolSessionId integer default 0, + 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, + FilesetId integer default 0, + PriorJobid integer default 0, + PurgedFiles smallint default 0, + HasBase smallint default 0, + HasCache smallint default 0, + Reviewed smallint default 0, + Comment text, primary key (jobid) ); @@ -163,7 +178,7 @@ CREATE TABLE media 'Error','Busy','Used','Cleaning','Scratch')), enabled smallint default 1, recycle smallint default 0, - ActionOnPurge smallint default 0, + ActionOnPurge smallint default 0, volretention bigint default 0, voluseduration bigint default 0, maxvoljobs integer default 0, @@ -239,7 +254,7 @@ CREATE TABLE pool maxvolbytes bigint default 0, autoprune smallint default 0, recycle smallint default 0, - ActionOnPurge smallint default 0, + ActionOnPurge smallint default 0, pooltype text check (pooltype in ('Backup','Copy','Cloned','Archive','Migration','Scratch')), labeltype integer default 0, @@ -344,7 +359,7 @@ CREATE TABLE PathHierarchy ); CREATE INDEX pathhierarchy_ppathid - ON PathHierarchy (PPathId); + ON PathHierarchy (PPathId); CREATE TABLE PathVisibility ( @@ -355,7 +370,7 @@ CREATE TABLE PathVisibility CONSTRAINT pathvisibility_pkey PRIMARY KEY (JobId, PathId) ); CREATE INDEX pathvisibility_jobid - ON PathVisibility (JobId); + ON PathVisibility (JobId); CREATE TABLE version ( diff --git a/bacula/src/cats/make_sqlite3_tables.in b/bacula/src/cats/make_sqlite3_tables.in index b33a24da8e..40a17e9c4f 100644 --- a/bacula/src/cats/make_sqlite3_tables.in +++ b/bacula/src/cats/make_sqlite3_tables.in @@ -39,7 +39,6 @@ CREATE TABLE File ( MD5 VARCHAR(255) NOT NULL, PRIMARY KEY(FileId) ); - CREATE INDEX inx3 ON File (JobId); CREATE INDEX file_jpf_idx ON File (JobId, PathId, FilenameId); -- @@ -49,6 +48,23 @@ CREATE INDEX file_jpf_idx ON File (JobId, PathId, FilenameId); -- CREATE INDEX inx4 ON File (PathId); -- CREATE INDEX inx5 ON File (FileNameId); + +CREATE TABLE RestoreObject ( + RestoreObjectId INTEGER, + Fname TEXT DEFAULT '', + Path TEXT DEFAULT '', + RestoreObject TEXT DEFAULT '', + PluginName TEXT DEFAULT '', + ObjectIndex INTEGER DEFAULT 0, + ObjectType INTEGER DEFAULT 0, + FileIndex INTEGER UNSIGNED DEFAULT 0, + JobId INTEGER UNSIGNED REFERENCES Job NOT NULL, + PRIMARY KEY(RestoreObjectId), + INDEX (JobId) + ); +CREATE INDEX restore_jobid_idx ON RestoreObject (JobId); + + CREATE TABLE Job ( JobId INTEGER, Job VARCHAR(128) NOT NULL, @@ -191,7 +207,7 @@ CREATE TABLE Media ( VolStatus VARCHAR(20) NOT NULL, Enabled TINYINT DEFAULT 1, Recycle TINYINT DEFAULT 0, - ActionOnPurge TINYINT DEFAULT 0, + ActionOnPurge TINYINT DEFAULT 0, VolRetention BIGINT UNSIGNED DEFAULT 0, VolUseDuration BIGINT UNSIGNED DEFAULT 0, MaxVolJobs INTEGER UNSIGNED DEFAULT 0, @@ -265,7 +281,7 @@ CREATE TABLE Pool ( MaxVolBytes BIGINT UNSIGNED DEFAULT 0, AutoPrune TINYINT DEFAULT 0, Recycle TINYINT DEFAULT 0, - ActionOnPurge TINYINT DEFAULT 0, + ActionOnPurge TINYINT DEFAULT 0, PoolType VARCHAR(20) NOT NULL, LabelType TINYINT DEFAULT 0, LabelFormat VARCHAR(128) NOT NULL, @@ -351,7 +367,7 @@ CREATE TABLE PathHierarchy ); CREATE INDEX pathhierarchy_ppathid - ON PathHierarchy (PPathId); + ON PathHierarchy (PPathId); CREATE TABLE PathVisibility ( @@ -363,7 +379,7 @@ CREATE TABLE PathVisibility ); CREATE INDEX pathvisibility_jobid - ON PathVisibility (JobId); + ON PathVisibility (JobId); CREATE TABLE Status ( JobStatus CHAR(1) NOT NULL, diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index 877726670d..3a1d02faf8 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -1274,7 +1274,7 @@ bool db_create_restore_object_record(JCR *jcr, B_DB *mdb, ROBJECT_DBR *ro) Dmsg1(dbglevel, "Fname=%s\n", ro->fname); Dmsg0(dbglevel, "put_object_into_catalog\n"); - split_path_and_file(jcr, mdb, ro->fname); + split_path_and_file(jcr, mdb, ro->full_fname); mdb->esc_name = check_pool_memory_size(mdb->esc_name, mdb->fnl*2+1); db_escape_string(jcr, mdb, mdb->esc_name, mdb->fname, mdb->fnl); @@ -1286,10 +1286,10 @@ bool db_create_restore_object_record(JCR *jcr, B_DB *mdb, ROBJECT_DBR *ro) db_escape_string(jcr, mdb, esc_obj, ro->object, ro->object_len); Mmsg(mdb->cmd, - "INSERT INTO RestoreObject (Fname,Path,PluginName,RestoreObject" + "INSERT INTO RestoreObject (Fname,Path,PluginName,RestoreObject," "ObjectIndex,ObjectType,FileIndex,JobId) VALUES" "('%s','%s','%s','%s',%d,%d,%d,%u)", - ro->fname, ro->path, ro->plugin_name, esc_obj, ro->object_len, + mdb->esc_name, mdb->esc_path, mdb->esc_path, esc_obj, ro->object_len, ro->ObjectIndex, FT_RESTORE_FIRST, ro->FileIndex, ro->JobId); ro->RestoreObjectId = sql_insert_id(mdb, mdb->cmd, NT_("RestoreObject")); diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index 7d9c2f452d..1f765da18b 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -373,11 +373,11 @@ static void update_attribute(JCR *jcr, char *msg, int32_t msglen) uint32_t VolSessionId, VolSessionTime; int32_t Stream; uint32_t FileIndex; - uint32_t data_len; char *p; int len; char *fname, *attr; ATTR_DBR *ar = NULL; + uint32_t reclen; /* Start transaction allocates jcr->attr and jcr->ar if needed */ db_start_transaction(jcr, jcr->db); /* start transaction if not already open */ @@ -400,7 +400,7 @@ static void update_attribute(JCR *jcr, char *msg, int32_t msglen) unser_uint32(VolSessionTime); /* VolSessionTime */ unser_int32(FileIndex); /* FileIndex */ unser_int32(Stream); /* Stream */ - unser_uint32(data_len); /* Record length */ + unser_uint32(reclen); /* Record length */ p += unser_length(p); /* Raw record follows */ /* @@ -409,8 +409,8 @@ static void update_attribute(JCR *jcr, char *msg, int32_t msglen) */ Dmsg1(400, "UpdCat msg=%s\n", msg); - Dmsg5(400, "UpdCat VolSessId=%d VolSessT=%d FI=%d Strm=%d data_len=%d\n", - VolSessionId, VolSessionTime, FileIndex, Stream, data_len); + Dmsg5(400, "UpdCat VolSessId=%d VolSessT=%d FI=%d Strm=%d reclen=%d\n", + VolSessionId, VolSessionTime, FileIndex, Stream, reclen); if (Stream == STREAM_UNIX_ATTRIBUTES || Stream == STREAM_UNIX_ATTRIBUTES_EX) { if (jcr->cached_attribute) { @@ -455,6 +455,7 @@ static void update_attribute(JCR *jcr, char *msg, int32_t msglen) ROBJECT_DBR ro; POOLMEM *attrEx = get_pool_memory(PM_MESSAGE); char *p; + memset(&ro, 0, sizeof(ro)); ro.full_fname = fname; ro.Stream = Stream; ro.FileType = ar->FileType; @@ -466,13 +467,16 @@ static void update_attribute(JCR *jcr, char *msg, int32_t msglen) while (*p++ != 0) /* skip link */ { } /* We have an object, so do a binary copy */ - ro.object_len = msglen + ar->attr - p; + ro.object_len = msglen + jcr->attr - p; attrEx = check_pool_memory_size(attrEx, ro.object_len + 1); memcpy(attrEx, p, ro.object_len); ro.object = attrEx; /* Add a EOS for those who attempt to print the object */ p = attrEx + ro.object_len; *p = 0; + Dmsg7(000, "fname=%s stream=%d FT=%d FI=%d JobId=%d, obj_len=%d\nobj=\"%s\"\n", + ro.full_fname, ro.Stream, ro.FileType, ro.FileIndex, ro.JobId, + ro.object_len, attrEx); /* Send it */ if (!db_create_restore_object_record(jcr, jcr->db, &ro)) { Jmsg1(jcr, M_FATAL, 0, _("Restore object create error. %s"), db_strerror(jcr->db)); diff --git a/bacula/src/filed/fd_plugins.c b/bacula/src/filed/fd_plugins.c index 3141fc6afd..c5f303e6ea 100644 --- a/bacula/src/filed/fd_plugins.c +++ b/bacula/src/filed/fd_plugins.c @@ -350,7 +350,7 @@ bool send_plugin_name(JCR *jcr, BSOCK *sd, bool start) sd->bstrerror()); return false; } - Dmsg1(50, "send: %s\n", sd->msg); + Dmsg1(50, "send plugin name hdr: %s\n", sd->msg); if (start) { /* Send data -- not much */ @@ -364,7 +364,7 @@ bool send_plugin_name(JCR *jcr, BSOCK *sd, bool start) sd->bstrerror()); return false; } - Dmsg1(dbglvl, "send: %s\n", sd->msg); + Dmsg1(dbglvl, "send plugin start/end: %s\n", sd->msg); sd->signal(BNET_EOD); /* indicate end of plugin name data */ return true; } diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 20f8fb0313..19676e93f1 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -1639,7 +1639,6 @@ static int backup_cmd(JCR *jcr) if (!blast_data_to_storage_daemon(jcr, NULL)) { set_jcr_job_status(jcr, JS_ErrorTerminated); bnet_suppress_error_messages(sd, 1); - bget_msg(sd); /* Read final response from append_data */ Dmsg0(110, "Error in blast_data.\n"); } else { set_jcr_job_status(jcr, JS_Terminated); diff --git a/bacula/src/lib/bsock.c b/bacula/src/lib/bsock.c index a2e3bb275c..ade5eb678c 100644 --- a/bacula/src/lib/bsock.c +++ b/bacula/src/lib/bsock.c @@ -335,6 +335,12 @@ bool BSOCK::send() bool ok = true; if (errors || is_terminated() || msglen > 1000000) { + if (!m_suppress_error_msgs) { + Qmsg6(m_jcr, M_ERROR, 0, + _("Socket has errors=%d; is_terminated=%d; or has insane msglen=%d on call to %s:%s:%d\n"), + errors, is_terminated(), msglen, m_who, + m_host, m_port); + } return false; } if (m_use_locking) P(m_mutex); diff --git a/bacula/src/plugins/fd/test-plugin-fd.c b/bacula/src/plugins/fd/test-plugin-fd.c index 358352641b..a09ae9e50f 100644 --- a/bacula/src/plugins/fd/test-plugin-fd.c +++ b/bacula/src/plugins/fd/test-plugin-fd.c @@ -280,17 +280,17 @@ static bRC startBackupFile(bpContext *ctx, struct save_pkt *sp) } time_t now = time(NULL); sp->fname = p_ctx->fname; + sp->object = (char *)"This is test data for the restore object."; + sp->object_len = strlen(sp->object); + sp->index = 2; sp->type = FT_RESTORE_FIRST; sp->statp.st_mode = 0700 | S_IFREG; sp->statp.st_ctime = now; sp->statp.st_mtime = now; sp->statp.st_atime = now; - sp->statp.st_size = -1; + sp->statp.st_size = sp->object_len; sp->statp.st_blksize = 4096; sp->statp.st_blocks = 1; - sp->object = (char *)"This is test data for the restore object."; - sp->object_len = strlen(sp->object); - sp->index = 2; p_ctx->backup = true; printf("test-plugin-fd: startBackupFile\n"); return bRC_OK; @@ -314,8 +314,14 @@ static bRC endBackupFile(bpContext *ctx) */ static bRC pluginIO(bpContext *ctx, struct io_pkt *io) { - printf("test-plugin-fd: pluginIO\n"); - return bRC_Error; + struct plugin_ctx *p_ctx = (struct plugin_ctx *)ctx->pContext; + if (!p_ctx) { + return bRC_Error; + } + + io->status = 0; + io->io_errno = 0; + return bRC_OK; } /* diff --git a/regress/tests/test-plugin-test b/regress/tests/test-plugin-test index 509a6173db..1d07c718b9 100755 --- a/regress/tests/test-plugin-test +++ b/regress/tests/test-plugin-test @@ -29,7 +29,8 @@ messages label storage=File1 volume=TestVolume001 setdebug level=150 client=$CLIENT estimate job=$JobName level=Full -setdebug level=50 client=$CLIENT +@#setdebug level=150 client=$CLIENT +@#setdebug level=150 storage=File1 run job=$JobName storage=File1 yes wait status client=$CLIENT