--sd.conf password does not match dir.conf storage password
=======
+- In restore job, print some summary information at end, such
+ as rate, ... job status, ...
- After unmount, if restore job started, ask to mount.
- Fix db_update_fileset in cats/sql_get.c
- Fix start/end blocks for File
* to the appropriate handler. If the message is
* in any other format, it will be returned.
*
+ * E.g. any message beginning with a digit will be returned.
+ * any message beginning with Jmsg will be processed.
+ *
*/
int32_t bget_msg(BSOCK *bs, int rtn)
{
*/
bash_spaces(jcr->job->hdr.name);
bash_spaces(jcr->client->hdr.name);
- bash_spaces(jcr->client->hdr.name);
+ bash_spaces(jcr->fileset->hdr.name);
bnet_fsend(sd, jobcmd, jcr->JobId, jcr->Job, jcr->job->hdr.name,
jcr->client->hdr.name, jcr->JobType, jcr->JobLevel,
jcr->fileset->hdr.name, !jcr->pool->catalog_files,
static char OKstore[] = "2000 OK storage\n";
static char OKsession[] = "2000 OK session\n";
static char OKbootstrap[] = "2000 OK bootstrap\n";
+static char EndJob[] = "2800 End Job TermCode=%d JobFiles=%u JobBytes=%" lld "\n";
/* Forward referenced functions */
static void restore_cleanup(JCR *jcr, int status);
char dt[MAX_TIME_LENGTH];
BSOCK *fd;
JOB_DBR rjr; /* restore job record */
+ int ok = FALSE;
if (!get_or_create_client_record(jcr)) {
/*** ****FIXME**** get job termination status */
Dmsg0(20, "wait for job termination\n");
while (bget_msg(fd, 0) > 0) {
- Dmsg1(0, "dird<filed: %s\n", fd->msg);
+ Dmsg1(100, "dird<filed: %s\n", fd->msg);
+ if (sscanf(fd->msg, EndJob, &jcr->JobStatus, &jcr->JobFiles,
+ &jcr->JobBytes) == 3) {
+ ok = TRUE;
+ }
}
- restore_cleanup(jcr, JS_Terminated);
+ restore_cleanup(jcr, ok?jcr->JobStatus:JS_ErrorTerminated);
return 1;
}
* Release resources allocated during restore.
*
*/
-static void restore_cleanup(JCR *jcr, int status)
+static void restore_cleanup(JCR *jcr, int TermCode)
{
- char dt[MAX_TIME_LENGTH];
+ char sdt[MAX_TIME_LENGTH], edt[MAX_TIME_LENGTH];
+ char ec1[30], ec2[30];
+ char term_code[100];
+ char *term_msg;
+ int msg_type;
+ double kbps;
Dmsg0(20, "In restore_cleanup\n");
- jcr->JobStatus = status;
+ jcr->JobStatus = TermCode;
update_job_end_record(jcr);
- bstrftime(dt, sizeof(dt), jcr->jr.EndTime);
- Jmsg(jcr, M_INFO, 0, _("%s End Restore Job %s.\n\n"),
- dt, jcr->Job);
+ msg_type = M_INFO; /* by default INFO message */
+ switch (TermCode) {
+ case JS_Terminated:
+ term_msg = _("Restore OK");
+ break;
+ case JS_FatalError:
+ case JS_ErrorTerminated:
+ term_msg = _("*** Restore Error ***");
+ msg_type = M_ERROR; /* Generate error message */
+ if (jcr->store_bsock) {
+ bnet_sig(jcr->store_bsock, BNET_TERMINATE);
+ pthread_cancel(jcr->SD_msg_chan);
+ }
+ break;
+ case JS_Cancelled:
+ term_msg = _("Restore Cancelled");
+ if (jcr->store_bsock) {
+ bnet_sig(jcr->store_bsock, BNET_TERMINATE);
+ pthread_cancel(jcr->SD_msg_chan);
+ }
+ break;
+ default:
+ term_msg = term_code;
+ sprintf(term_code, _("Inappropriate term code: %c\n"), TermCode);
+ break;
+ }
+ bstrftime(sdt, sizeof(sdt), jcr->jr.StartTime);
+ bstrftime(edt, sizeof(edt), jcr->jr.EndTime);
+ kbps = (double)jcr->jr.JobBytes / (1000 * (jcr->jr.EndTime - jcr->jr.StartTime));
+
+ Jmsg(jcr, msg_type, 0, _("%s\n\
+JobId: %d\n\
+Job: %s\n\
+Client: %s\n\
+Start time: %s\n\
+End time: %s\n\
+Files Restored: %s\n\
+Bytes Restored: %s\n\
+Rate: %.1f KB/s\n\
+Termination: %s\n\n"),
+ edt,
+ jcr->jr.JobId,
+ jcr->jr.Job,
+ jcr->client->hdr.name,
+ sdt,
+ edt,
+ edit_uint64_with_commas(jcr->jr.JobFiles, ec1),
+ edit_uint64_with_commas(jcr->jr.JobBytes, ec2),
+ (float)kbps,
+ term_msg);
Dmsg0(20, "Leaving restore_cleanup\n");
}
break;
}
/* ***FIXME*** allow drive:/ for Windows */
- if (ua->cmd[0] != '/') {
- bsendmsg(ua, _("Prefix must begin with a /\n"));
+ if (ua->cmd[0] != 0 && ua->cmd[0] != '/') {
+ bsendmsg(ua, _("Prefix must be null or begin with a /\n"));
} else {
if (jcr->RestoreWhere) {
free(jcr->RestoreWhere);
static char OKjob[] = "2000 OK Job\n";
static char OKsetdebug[] = "2000 OK setdebug=%d\n";
static char BADjob[] = "2901 Bad Job\n";
+static char EndJob[] = "2800 End Job TermCode=%d JobFiles=%u JobBytes=%" lld "\n";
/* Responses received from Storage Daemon */
static char OK_end[] = "3000 OK end\n";
{
BSOCK *dir = jcr->dir_bsock;
make_estimate(jcr);
- return bnet_fsend(dir, OKest, jcr->JobFiles, jcr->JobBytes);
+ return bnet_fsend(dir, OKest, jcr->num_files_examined, jcr->JobBytes);
}
/*
/* Inform Storage daemon that we are done */
bnet_sig(sd, BNET_TERMINATE);
+ bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->num_files_examined, jcr->JobBytes);
+
/* Inform Director that we are done */
bnet_sig(dir, BNET_TERMINATE);
close(ofd);
set_statp(jcr, fname, ofile, lname, type, &statp);
}
+ jcr->JobStatus = JS_Terminated;
+ goto ok_out;
bail_out:
+ jcr->JobStatus = JS_ErrorTerminated;
+ok_out:
if (jcr->compress_buf) {
free(jcr->compress_buf);
jcr->compress_buf = NULL;
} else if (dev->num_writers > 0) {
dev->num_writers--;
- Dmsg1(00, "There are %d writers in release_device\n", dev->num_writers);
+ Dmsg1(100, "There are %d writers in release_device\n", dev->num_writers);
if (dev->num_writers == 0) {
weof_dev(dev, 1);
Dmsg0(100, "dir_create_jobmedia_record. Release\n");
}
pm_strcpy(&jcr->VolumeName, VolName);
+ Dmsg1(000, "Volume=%s\n", jcr->VolumeName);
if (!acquire_device_for_read(jcr, dev, block)) {
Emsg0(M_ERROR, 0, dev->errmsg);
exit(1);
/* Responses sent to Director daemon */
static char OKjob[] = "3000 OK Job SDid=%u SDtime=%u Authorization=%s\n";
static char OK_device[] = "3000 OK use device\n";
-static char NO_device[] = "3904 Device %s not available\n";
-static char BAD_use[] = "3903 Bad use command: %s\n";
-static char BAD_job[] = "3905 Bad Job command: %s\n";
+static char NO_device[] = "3914 Device %s not available\n";
+static char BAD_use[] = "3913 Bad use command: %s\n";
+static char BAD_job[] = "3915 Bad Job command: %s\n";
}
/* Read Record */
Dmsg1(500, "Main read_record. rem=%d\n", rec->remainder);
+
if (!read_block_from_device(dev, block)) {
Dmsg1(500, "Main read record failed. rem=%d\n", rec->remainder);
if (dev->state & ST_EOT) {
- if (rec->remainder) {
- Dmsg0(500, "Not end of record.\n");
- }
if (!mount_next_read_volume(jcr, dev, block)) {
break;
}
for (rec->state=0; !is_block_empty(rec); ) {
+ if (!read_record_from_block(block, rec)) {
+ break;
+ }
+ /*
+ * At this point, we have at least a record header.
+ * Now decide if we want this record or not, but remember
+ * before accessing the record, we may need to read again to
+ * get all the data.
+ */
+
/* Some sort of label? */
if (rec->FileIndex < 0) {
char *rtype;
Dmsg1(40, "Got label = %d\n", rec->FileIndex);
if (rec->FileIndex == EOM_LABEL) { /* end of tape? */
Dmsg0(40, "Get EOM LABEL\n");
+ rec->remainder = 0;
break; /* yes, get out */
}
+ rec->remainder = 0;
continue; /* ignore other labels */
} /* end if label record */
+ /* Match BSR against current record */
if (jcr->bsr) {
- /* Match BSR against current record */
if (!match_bsr(jcr->bsr, rec, &dev->VolHdr, &sessrec)) {
Dmsg0(50, "BSR rejected record\n");
rec->remainder = 0;
continue; /* ignore */
}
}
+
if (is_partial_record(rec)) {
- break;
+ break; /* Go read full record */
}
/* Generate Header parameters and send to File daemon
/* */
#define VERSION "1.25"
#define VSTRING "1"
-#define DATE "22 August 2002"
-#define LSMDATE "22Aug02"
+#define DATE "24 August 2002"
+#define LSMDATE "24Aug02"
/* Debug flags */
#define DEBUG 1