X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fstored%2Fbscan.c;h=fde0ba1ff06a960b1e9203d3e768e0a55c11207a;hb=b58f32ee0c8cce5b5f7af1416966b8bd2b3ccb6d;hp=2bdeac3f0480228d5734b3b6cfbdeca7ffddb641;hpb=35fd0fb12ed5ffbcebe953f7641da65850a5f7f1;p=bacula%2Fbacula diff --git a/bacula/src/stored/bscan.c b/bacula/src/stored/bscan.c index 2bdeac3f04..fde0ba1ff0 100644 --- a/bacula/src/stored/bscan.c +++ b/bacula/src/stored/bscan.c @@ -82,10 +82,12 @@ static ATTR *attr; static time_t lasttime = 0; +static const char *db_driver = "NULL"; static const char *db_name = "bacula"; static const char *db_user = "bacula"; static const char *db_password = ""; static const char *db_host = NULL; +static int db_port = 0; static const char *wd = NULL; static bool update_db = false; static bool update_vol_info = false; @@ -119,10 +121,12 @@ PROG_COPYRIGHT " -d set debug level to \n" " -dt print timestamp in debug output\n" " -m update media info in database\n" +" -D specify the driver database name (default NULL)\n" " -n specify the database name (default bacula)\n" " -u specify database user name (default bacula)\n" " -P specify database password (default none)\n" " -h specify database host (default NULL)\n" +" -t specify database port (default 0)\n" " -p proceed inspite of I/O errors\n" " -r list records\n" " -s synchronize or store in database\n" @@ -150,7 +154,7 @@ int main (int argc, char *argv[]) OSDependentInit(); - while ((ch = getopt(argc, argv, "b:c:d:h:mn:pP:rsSu:vV:w:?")) != -1) { + while ((ch = getopt(argc, argv, "b:c:dD:h:p:mn:pP:rsSt:u:vV:w:?")) != -1) { switch (ch) { case 'S' : showProgress = true; @@ -166,6 +170,10 @@ int main (int argc, char *argv[]) configfile = bstrdup(optarg); break; + case 'D': + db_driver = optarg; + break; + case 'd': /* debug level */ if (*optarg == 't') { dbg_timestamp = true; @@ -180,6 +188,10 @@ int main (int argc, char *argv[]) case 'h': db_host = optarg; break; + + case 't': + db_port = atoi(optarg); + break; case 'm': update_vol_info = true; @@ -282,8 +294,8 @@ int main (int argc, char *argv[]) edit_uint64(currentVolumeSize, ed1)); } - if ((db=db_init_database(NULL, db_name, db_user, db_password, - db_host, 0, NULL, 0)) == NULL) { + if ((db=db_init(NULL, db_driver, db_name, db_user, db_password, + db_host, db_port, NULL, 0)) == NULL) { Emsg0(M_ERROR_TERM, 0, _("Could not init Bacula database\n")); } if (!db_open_database(NULL, db)) { @@ -523,20 +535,6 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) update_db = save_update_db; jr.PoolId = pr.PoolId; -#ifdef xxx - /* Set start positions into JCR */ - if (dev->is_tape()) { - /* - * Note, we have already advanced past current block, - * so the correct number is block_num - 1 - */ - dcr->StartBlock = dev->block_num - 1; - dcr->StartFile = dev->file; - } else { - dcr->StartBlock = (uint32_t)dev->file_addr; - dcr->StartFile = (uint32_t)(dev->file_addr >> 32); - } -#endif mjcr->start_time = jr.StartTime; mjcr->JobLevel = jr.JobLevel; @@ -621,7 +619,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) jr.VolSessionTime = mjcr->VolSessionTime; jr.JobTDate = (utime_t)mjcr->start_time; jr.ClientId = mjcr->ClientId; - if (!db_update_job_end_record(bjcr, db, &jr)) { + if (!db_update_job_end_record(bjcr, db, &jr, false)) { Pmsg1(0, _("Could not update job record. ERR=%s\n"), db_strerror(db)); } mjcr->read_dcr = NULL; @@ -847,7 +845,11 @@ static int create_file_attributes_record(B_DB *db, JCR *mjcr, ar.ClientId = mjcr->ClientId; ar.JobId = mjcr->JobId; ar.Stream = rec->Stream; - ar.FileIndex = rec->FileIndex; + if (type == FT_DELETED) { + ar.FileIndex = 0; + } else { + ar.FileIndex = rec->FileIndex; + } ar.attr = ap; if (dcr->VolFirstIndex == 0) { dcr->VolFirstIndex = rec->FileIndex; @@ -1120,7 +1122,7 @@ static int update_job_record(B_DB *db, JOB_DBR *jr, SESSION_LABEL *elabel, return 1; } - if (!db_update_job_end_record(bjcr, db, jr)) { + if (!db_update_job_end_record(bjcr, db, jr, false)) { Pmsg2(0, _("Could not update JobId=%u record. ERR=%s\n"), jr->JobId, db_strerror(db)); free_jcr(mjcr); return 0;