* Note in this routine, we do not use Jmsg because it may be
* called to get attributes of a non-existent file, which is
* "normal" if a new file is found during Verify.
+ *
+ * The following is a bit of a kludge: because we always backup a
+ * directory entry, we can end up with two copies of the directory
+ * in the backup. One is when we encounter the directory and find
+ * we cannot recurse into it, and the other is when we find an
+ * explicit mention of the directory. This can also happen if the
+ * use includes the directory twice. In this case, Verify
+ * VolumeToCatalog fails because we have two copies in the catalog,
+ * and only the first one is marked (twice). So, when calling from Verify,
+ * jr is not NULL and we know jr->FileIndex is the fileindex
+ * of the version of the directory/file we actually want and do
+ * a more explicit SQL search.
*/
static
int db_get_file_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr, FILE_DBR *fdbr)
Mmsg(mdb->cmd,
"SELECT FileId, LStat, MD5 FROM File,Job WHERE "
"File.JobId=Job.JobId AND File.PathId=%s AND "
-"File.FilenameId=%s AND Job.Type='B' AND Job.JobStatus='T' AND "
+"File.FilenameId=%s AND Job.Type='B' AND Job.JobStatus IN ('T','W') AND "
"ClientId=%s ORDER BY StartTime DESC LIMIT 1",
edit_int64(fdbr->PathId, ed1),
edit_int64(fdbr->FilenameId, ed2),
edit_int64(jr->ClientId,ed3));
+ } else if (jr != NULL) {
+ /* Called from Verify so jr->FileIndex is valid */
+ Mmsg(mdb->cmd,
+"SELECT FileId, LStat, MD5 FROM File WHERE File.JobId=%s AND File.PathId=%s AND "
+"File.FilenameId=%s AND FileIndex=%u",
+ edit_int64(fdbr->JobId, ed1),
+ edit_int64(fdbr->PathId, ed2),
+ edit_int64(fdbr->FilenameId,ed3),
+ jr->FileIndex);
} else {
Mmsg(mdb->cmd,
"SELECT FileId, LStat, MD5 FROM File WHERE File.JobId=%s AND File.PathId=%s AND "
edit_int64(fdbr->PathId, ed2),
edit_int64(fdbr->FilenameId,ed3));
}
- Dmsg3(050, "Get_file_record JobId=%u FilenameId=%u PathId=%u\n",
+ Dmsg3(450, "Get_file_record JobId=%u FilenameId=%u PathId=%u\n",
fdbr->JobId, fdbr->FilenameId, fdbr->PathId);
Dmsg1(100, "Query=%s\n", mdb->cmd);
if (mdb->num_rows > 1) {
Mmsg1(mdb->errmsg, _("get_file_record want 1 got rows=%d\n"),
mdb->num_rows);
+ Dmsg1(000, "=== Problem! %s", mdb->errmsg);
}
if (mdb->num_rows >= 1) {
if ((row = sql_fetch_row(mdb)) == NULL) {
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));
}
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);
Mmsg(mdb->cmd,
"SELECT VolumeName,MediaType,FirstIndex,LastIndex,StartFile,"
"JobMedia.EndFile,StartBlock,JobMedia.EndBlock,Copy,"
-"Slot,StorageId"
+"Slot,StorageId,InChanger"
" FROM JobMedia,Media WHERE JobMedia.JobId=%s"
" AND JobMedia.MediaId=Media.MediaId ORDER BY VolIndex,JobMediaId",
edit_int64(JobId, ed1));
break;
} else {
DBId_t StorageId;
+ uint32_t StartBlock, EndBlock, StartFile, EndFile;
bstrncpy(Vols[i].VolumeName, row[0], MAX_NAME_LENGTH);
bstrncpy(Vols[i].MediaType, row[1], MAX_NAME_LENGTH);
Vols[i].FirstIndex = str_to_uint64(row[2]);
Vols[i].LastIndex = str_to_uint64(row[3]);
- Vols[i].StartFile = str_to_uint64(row[4]);
- Vols[i].EndFile = str_to_uint64(row[5]);
- Vols[i].StartBlock = str_to_uint64(row[6]);
- Vols[i].EndBlock = str_to_uint64(row[7]);
+ StartFile = str_to_uint64(row[4]);
+ EndFile = str_to_uint64(row[5]);
+ StartBlock = str_to_uint64(row[6]);
+ EndBlock = str_to_uint64(row[7]);
+ Vols[i].StartAddr = (((uint64_t)StartFile)<<32) | StartBlock;
+ Vols[i].EndAddr = (((uint64_t)EndFile)<<32) | EndBlock;
// Vols[i].Copy = str_to_uint64(row[8]);
Vols[i].Slot = str_to_uint64(row[9]);
StorageId = str_to_uint64(row[10]);
+ Vols[i].InChanger = str_to_uint64(row[11]);
Vols[i].Storage[0] = 0;
SId[i] = StorageId;
}
Mmsg(mdb->cmd,
"SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog,AcceptAnyVolume,"
"AutoPrune,Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,"
-"MaxVolBytes,PoolType,LabelType,LabelFormat,RecyclePoolId FROM Pool WHERE Pool.PoolId=%s",
+"MaxVolBytes,PoolType,LabelType,LabelFormat,RecyclePoolId,ScratchPoolId FROM Pool WHERE Pool.PoolId=%s",
edit_int64(pdbr->PoolId, ed1));
} else { /* find by name */
Mmsg(mdb->cmd,
"SELECT PoolId,Name,NumVols,MaxVols,UseOnce,UseCatalog,AcceptAnyVolume,"
"AutoPrune,Recycle,VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,"
-"MaxVolBytes,PoolType,LabelType,LabelFormat,RecyclePoolId FROM Pool WHERE Pool.Name='%s'",
+"MaxVolBytes,PoolType,LabelType,LabelFormat,RecyclePoolId,ScratchPoolId FROM Pool WHERE Pool.Name='%s'",
pdbr->Name);
}
-
if (QUERY_DB(jcr, mdb, mdb->cmd)) {
mdb->num_rows = sql_num_rows(mdb);
if (mdb->num_rows > 1) {
pdbr->LabelType = str_to_int64(row[15]);
bstrncpy(pdbr->LabelFormat, row[16]!=NULL?row[16]:"", sizeof(pdbr->LabelFormat));
pdbr->RecyclePoolId = str_to_int64(row[17]);
+ pdbr->ScratchPoolId = str_to_int64(row[18]);
ok = true;
}
}
#else
/*
* I am not sure that this works the same as the code in ua_restore.c
- * but it is very similar.
+ * but it is very similar. The accurate-test fails in a restore. Bad file count.
*/
Mmsg(buf, uar_sel_files, jobids);
#endif
"SELECT JobId, StartTime, EndTime, JobTDate, PurgedFiles "
"FROM Job JOIN FileSet USING (FileSetId) "
"WHERE ClientId = %s "
- "AND Level='F' AND JobStatus='T' AND Type='B' "
+ "AND Level='F' AND JobStatus IN ('T','W') AND Type='B' "
"AND StartTime<'%s' "
"AND FileSet.FileSet=(SELECT FileSet FROM FileSet WHERE FileSetId = %s) "
"ORDER BY Job.JobTDate DESC LIMIT 1",
"SELECT JobId, StartTime, EndTime, JobTDate, PurgedFiles "
"FROM Job JOIN FileSet USING (FileSetId) "
"WHERE ClientId = %s "
- "AND Level='D' AND JobStatus='T' AND Type='B' "
+ "AND Level='D' AND JobStatus IN ('T','W') AND Type='B' "
"AND StartTime > (SELECT EndTime FROM btemp3%s ORDER BY EndTime DESC LIMIT 1) "
"AND FileSet.FileSet= (SELECT FileSet FROM FileSet WHERE FileSetId = %s) "
"ORDER BY Job.JobTDate DESC LIMIT 1 ",
"SELECT JobId, StartTime, EndTime, JobTDate, PurgedFiles "
"FROM Job JOIN FileSet USING (FileSetId) "
"WHERE ClientId = %s "
- "AND Level='I' AND JobStatus='T' AND Type='B' "
+ "AND Level='I' AND JobStatus IN ('T','W') AND Type='B' "
"AND StartTime > (SELECT EndTime FROM btemp3%s ORDER BY EndTime DESC LIMIT 1) "
"AND FileSet.FileSet= (SELECT FileSet FROM FileSet WHERE FileSetId = %s) "
"ORDER BY Job.JobTDate DESC ",