-/*
- *
- * Program to scan a Bacula Volume and compare it with
- * the catalog and optionally synchronize the catalog
- * with the tape.
- *
- * Kern E. Sibbald, December 2001
- *
- *
- * Version $Id$
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2001-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2001-2007 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
This program is Free Software; you can redistribute it and/or
modify it under the terms of version two of the GNU General Public
- License as published by the Free Software Foundation plus additions
- that are listed in the file LICENSE.
+ License as published by the Free Software Foundation and included
+ in the file LICENSE.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ *
+ * Program to scan a Bacula Volume and compare it with
+ * the catalog and optionally synchronize the catalog
+ * with the tape.
+ *
+ * Kern E. Sibbald, December 2001
+ *
+ *
+ * Version $Id$
+ */
#include "bacula.h"
#include "stored.h"
my_name_is(argc, argv, "bscan");
init_msg(NULL, NULL);
+ OSDependentInit();
while ((ch = getopt(argc, argv, "b:c:d:h:mn:pP:rsSu:vV:w:?")) != -1) {
switch (ch) {
if (showProgress) {
char ed1[50];
struct stat sb;
- fstat(dev->fd, &sb);
+ fstat(dev->fd(), &sb);
currentVolumeSize = sb.st_size;
Pmsg1(000, _("First Volume Size = %sn"),
edit_uint64(currentVolumeSize, ed1));
Dmsg1(100, "Walk attached jcrs. Volume=%s\n", dev->VolCatInfo.VolCatName);
foreach_dlist(mdcr, dev->attached_dcrs) {
JCR *mjcr = mdcr->jcr;
+ Dmsg1(000, "========== JobId=%u ========\n", mjcr->JobId);
if (mjcr->JobId == 0) {
continue;
}
if (verbose) {
Pmsg1(000, _("Create JobMedia for Job %s\n"), mjcr->Job);
}
- if (dev->is_tape()) {
- mdcr->EndBlock = dcr->EndBlock;
- mdcr->EndFile = dcr->EndFile;
-// } else {
-// mdcr->EndBlock = (uint32_t)dcr->file_addr;
-// mdcr->EndFile = (uint32_t)(dcr->file_addr >> 32);
- }
+ mdcr->StartBlock = dcr->StartBlock;
+ mdcr->StartFile = dcr->StartFile;
+ mdcr->EndBlock = dcr->EndBlock;
+ mdcr->EndFile = dcr->EndFile;
mjcr->read_dcr->VolLastIndex = dcr->VolLastIndex;
if (!create_jobmedia_record(db, mjcr)) {
Pmsg2(000, _("Could not create JobMedia record for Volume=%s Job=%s\n"),
dev->VolCatInfo.VolCatName, mjcr->Job);
}
}
+
+ update_media_record(db, &mr);
+
/* Now let common read routine get up next tape. Note,
* we call mount_next... with bscan's jcr because that is where we
* have the Volume list, but we get attached.
if (showProgress) {
char ed1[50];
struct stat sb;
- fstat(dev->fd, &sb);
+ fstat(dev->fd(), &sb);
currentVolumeSize = sb.st_size;
Pmsg1(000, _("First Volume Size = %sn"),
edit_uint64(currentVolumeSize, ed1));
read_records(bjcr->read_dcr, record_cb, bscan_mount_next_read_volume);
+ if (update_db) {
+ db_write_batch_file_records(bjcr); /* used by bulk batch file insert */
+ }
free_attr(attr);
}
mr->LabelDate = mktime(&tm);
}
lasttime = mr->LabelDate;
+ if (mr->VolJobs == 0) {
+ mr->VolJobs = 1;
+ }
+ if (mr->VolMounts == 0) {
+ mr->VolMounts = 1;
+ }
if (!update_db) {
return 1;
JOBMEDIA_DBR jmr;
DCR *dcr = mjcr->read_dcr;
- if (dev->is_tape()) {
- dcr->EndBlock = dev->EndBlock;
- dcr->EndFile = dev->EndFile;
-#ifdef needed
- } else {
- dcr->EndBlock = (uint32_t)dev->file_addr;
- dcr->EndFile = (uint32_t)(dev->file_addr >> 32);
-#endif
- }
+ dcr->EndBlock = dev->EndBlock;
+ dcr->EndFile = dev->EndFile;
memset(&jmr, 0, sizeof(jmr));
jmr.JobId = mjcr->JobId;
jobjcr->VolSessionId = rec->VolSessionId;
jobjcr->VolSessionTime = rec->VolSessionTime;
jobjcr->ClientId = jr->ClientId;
- jobjcr->read_dcr = new_dcr(jobjcr, dev);
+ jobjcr->dcr = jobjcr->read_dcr = new_dcr(jobjcr, NULL, dev);
return jobjcr;
}