From 77b9ce43521d34bb9438b5e94b944b4067ce025e Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 15 Aug 2005 08:48:01 +0000 Subject: [PATCH] - Fix how FileSet is saved in job record to correct continual Full save. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2315 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kes-1.37 | 2 + bacula/src/cats/protos.h | 2 +- bacula/src/cats/sql_find.c | 132 ++++++++++++------------- bacula/src/dird/backup.c | 5 +- bacula/src/dird/fd_cmds.c | 2 +- bacula/src/dird/job.c | 20 ++-- bacula/src/dird/mac.c | 196 ++++++++++++++++++------------------- bacula/src/dird/protos.h | 2 +- bacula/src/dird/ua_cmds.c | 3 +- 9 files changed, 175 insertions(+), 189 deletions(-) diff --git a/bacula/kes-1.37 b/bacula/kes-1.37 index 5691cf76d7..995ac9f0b5 100644 --- a/bacula/kes-1.37 +++ b/bacula/kes-1.37 @@ -5,6 +5,8 @@ General: Changes to 1.37.36: 15Aug05 +- Fix how FileSet is saved in job record to correct continual + Full save. - Make datadir print on config.out listing. - Move get FileSet record up in backup init to eliminate continual Full save seen by Peter Sjoberg. diff --git a/bacula/src/cats/protos.h b/bacula/src/cats/protos.h index bc301d22ef..ede3b2b711 100644 --- a/bacula/src/cats/protos.h +++ b/bacula/src/cats/protos.h @@ -64,7 +64,7 @@ int db_delete_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pool_dbr); int db_delete_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr); /* find.c */ -int db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime); +bool db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime); int db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr); int db_find_next_volume(JCR *jcr, B_DB *mdb, int index, bool InChanger, MEDIA_DBR *mr); bool db_find_failed_job_since(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM *stime, int &JobLevel); diff --git a/bacula/src/cats/sql_find.c b/bacula/src/cats/sql_find.c index 354038280f..33ae9b0ac3 100644 --- a/bacula/src/cats/sql_find.c +++ b/bacula/src/cats/sql_find.c @@ -2,39 +2,34 @@ * Bacula Catalog Database Find record interface routines * * Note, generally, these routines are more complicated - * that a simple search by name or id. Such simple - * request are in get.c + * that a simple search by name or id. Such simple + * request are in get.c * * Kern Sibbald, December 2000 * * Version $Id$ */ - /* Copyright (C) 2000-2005 Kern Sibbald This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. + modify it under the terms of the GNU General Public License + version 2 as amended with additional clauses defined in the + file LICENSE in the main source directory. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + the file LICENSE for additional details. */ + /* The following is necessary so that we do not include * the dummy external definition of DB. */ -#define __SQL_C /* indicate that this is sql.c */ +#define __SQL_C /* indicate that this is sql.c */ #include "bacula.h" #include "cats.h" @@ -59,9 +54,9 @@ extern int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_ * StartTime is returned in stime * * Returns: 0 on failure - * 1 on success, jr is unchanged, but stime is set + * 1 on success, jr is unchanged, but stime is set */ -int +bool db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime) { SQL_ROW row; @@ -73,69 +68,64 @@ db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime) /* If no Id given, we must find corresponding job */ if (jr->JobId == 0) { /* Differential is since last Full backup */ - Mmsg(mdb->cmd, + Mmsg(mdb->cmd, "SELECT StartTime FROM Job WHERE JobStatus='T' AND Type='%c' AND " "Level='%c' AND Name='%s' AND ClientId=%s AND FileSetId=%s " "ORDER BY StartTime DESC LIMIT 1", - jr->JobType, L_FULL, jr->Name, - edit_int64(jr->ClientId, ed1), edit_int64(jr->FileSetId, ed2)); + jr->JobType, L_FULL, jr->Name, + edit_int64(jr->ClientId, ed1), edit_int64(jr->FileSetId, ed2)); if (jr->JobLevel == L_DIFFERENTIAL) { - /* SQL cmd for Differential backup already edited above */ + /* SQL cmd for Differential backup already edited above */ /* Incremental is since last Full, Incremental, or Differential */ } else if (jr->JobLevel == L_INCREMENTAL) { - /* - * For an Incremental job, we must first ensure - * that a Full backup was done (cmd edited above) - * then we do a second look to find the most recent - * backup - */ - if (!QUERY_DB(jcr, mdb, mdb->cmd)) { + /* + * For an Incremental job, we must first ensure + * that a Full backup was done (cmd edited above) + * then we do a second look to find the most recent + * backup + */ + if (!QUERY_DB(jcr, mdb, mdb->cmd)) { Mmsg2(&mdb->errmsg, _("Query error for start time request: ERR=%s\nCMD=%s\n"), - sql_strerror(mdb), mdb->cmd); - db_unlock(mdb); - return 0; - } - if ((row = sql_fetch_row(mdb)) == NULL) { - sql_free_result(mdb); + sql_strerror(mdb), mdb->cmd); + goto bail_out; + } + if ((row = sql_fetch_row(mdb)) == NULL) { + sql_free_result(mdb); Mmsg(mdb->errmsg, _("No prior Full backup Job record found.\n")); - db_unlock(mdb); - return 0; - } - sql_free_result(mdb); - /* Now edit SQL command for Incremental Job */ - Mmsg(mdb->cmd, + goto bail_out; + } + sql_free_result(mdb); + /* Now edit SQL command for Incremental Job */ + Mmsg(mdb->cmd, "SELECT StartTime FROM Job WHERE JobStatus='T' AND Type='%c' AND " "Level IN ('%c','%c','%c') AND Name='%s' AND ClientId=%s " "AND FileSetId=%s ORDER BY StartTime DESC LIMIT 1", - jr->JobType, L_INCREMENTAL, L_DIFFERENTIAL, L_FULL, jr->Name, - edit_int64(jr->ClientId, ed1), edit_int64(jr->FileSetId, ed2)); + jr->JobType, L_INCREMENTAL, L_DIFFERENTIAL, L_FULL, jr->Name, + edit_int64(jr->ClientId, ed1), edit_int64(jr->FileSetId, ed2)); } else { Mmsg1(&mdb->errmsg, _("Unknown level=%d\n"), jr->JobLevel); - db_unlock(mdb); - return 0; + goto bail_out; } } else { Dmsg1(100, "Submitting: %s\n", mdb->cmd); Mmsg(mdb->cmd, "SELECT StartTime FROM Job WHERE Job.JobId=%s", - edit_int64(jr->JobId, ed1)); + edit_int64(jr->JobId, ed1)); } if (!QUERY_DB(jcr, mdb, mdb->cmd)) { pm_strcpy(stime, ""); /* set EOS */ Mmsg2(&mdb->errmsg, _("Query error for start time request: ERR=%s\nCMD=%s\n"), - sql_strerror(mdb), mdb->cmd); - db_unlock(mdb); - return 0; + sql_strerror(mdb), mdb->cmd); + goto bail_out; } if ((row = sql_fetch_row(mdb)) == NULL) { Mmsg2(&mdb->errmsg, _("No Job record found: ERR=%s\nCMD=%s\n"), - sql_strerror(mdb), mdb->cmd); + sql_strerror(mdb), mdb->cmd); sql_free_result(mdb); - db_unlock(mdb); - return 0; + goto bail_out; } Dmsg1(100, "Got start time: %s\n", row[0]); pm_strcpy(stime, row[0]); @@ -143,7 +133,11 @@ db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime) sql_free_result(mdb); db_unlock(mdb); - return 1; + return true; + +bail_out: + db_unlock(mdb); + return false; } /* @@ -151,8 +145,8 @@ db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime) * it must be either Full or Diff. * * Returns: false on failure - * true on success, jr is unchanged and stime unchanged - * level returned in JobLevel + * true on success, jr is unchanged and stime unchanged + * level returned in JobLevel */ bool db_find_failed_job_since(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM *stime, int &JobLevel) @@ -167,9 +161,9 @@ db_find_failed_job_since(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM *stime, int & "Level IN ('%c','%c') AND Name='%s' AND ClientId=%s " "AND FileSetId=%s AND StartTime>'%s' " "ORDER BY StartTime DESC LIMIT 1", - jr->JobType, L_FULL, L_DIFFERENTIAL, jr->Name, - edit_int64(jr->ClientId, ed1), edit_int64(jr->FileSetId, ed2), - stime); + jr->JobType, L_FULL, L_DIFFERENTIAL, jr->Name, + edit_int64(jr->ClientId, ed1), edit_int64(jr->FileSetId, ed2), + stime); if (!QUERY_DB(jcr, mdb, mdb->cmd)) { db_unlock(mdb); @@ -195,7 +189,7 @@ db_find_failed_job_since(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM *stime, int & * For VERIFY_VOLUME_TO_CATALOG, we want the JobId of the last Job. * * Returns: 1 on success - * 0 on failure + * 0 on failure */ int db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr) @@ -210,19 +204,19 @@ db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr) "SELECT JobId FROM Job WHERE Type='V' AND Level='%c' AND " " JobStatus='T' AND Name='%s' AND " "ClientId=%s ORDER BY StartTime DESC LIMIT 1", - L_VERIFY_INIT, jr->Name, - edit_int64(jr->ClientId, ed1)); + L_VERIFY_INIT, jr->Name, + edit_int64(jr->ClientId, ed1)); } else if (jr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG || - jr->JobLevel == L_VERIFY_DISK_TO_CATALOG) { + jr->JobLevel == L_VERIFY_DISK_TO_CATALOG) { if (Name) { - Mmsg(mdb->cmd, + Mmsg(mdb->cmd, "SELECT JobId FROM Job WHERE Type='B' AND JobStatus='T' AND " "Name='%s' ORDER BY StartTime DESC LIMIT 1", Name); } else { - Mmsg(mdb->cmd, + Mmsg(mdb->cmd, "SELECT JobId FROM Job WHERE Type='B' AND JobStatus='T' AND " "ClientId=%s ORDER BY StartTime DESC LIMIT 1", - edit_int64(jr->ClientId, ed1)); + edit_int64(jr->ClientId, ed1)); } } else { Mmsg1(&mdb->errmsg, _("Unknown Job level=%c\n"), jr->JobLevel); @@ -261,7 +255,7 @@ db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr) * Find a Volume for a given PoolId, MediaType, and Status. * * Returns: 0 on failure - * numrows on success + * numrows on success */ int db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr) @@ -272,7 +266,7 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr char ed1[50]; db_lock(mdb); - if (item == -1) { /* find oldest volume */ + if (item == -1) { /* find oldest volume */ /* Find oldest volume */ Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks," "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes," @@ -282,7 +276,7 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr "FROM Media WHERE PoolId=%s AND MediaType='%s' AND VolStatus IN ('Full'," "'Recycle','Purged','Used','Append') " "ORDER BY LastWritten LIMIT 1", - edit_int64(mr->PoolId, ed1), mr->MediaType); + edit_int64(mr->PoolId, ed1), mr->MediaType); item = 1; } else { /* Find next available volume */ @@ -305,8 +299,8 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr "FROM Media WHERE PoolId=%s AND MediaType='%s' AND VolStatus='%s' " "%s " "%s LIMIT %d", - edit_int64(mr->PoolId, ed1), mr->MediaType, - mr->VolStatus, changer, order, item); + edit_int64(mr->PoolId, ed1), mr->MediaType, + mr->VolStatus, changer, order, item); } if (!QUERY_DB(jcr, mdb, mdb->cmd)) { db_unlock(mdb); @@ -316,7 +310,7 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr numrows = sql_num_rows(mdb); if (item > numrows) { Mmsg2(&mdb->errmsg, _("Request for Volume item %d greater than max %d\n"), - item, numrows); + item, numrows); db_unlock(mdb); return 0; } diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index af58f298a4..0d2b181355 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -48,14 +48,11 @@ static char EndJob[] = "2800 End Job TermCode=%d JobFiles=%u " */ bool do_backup_init(JCR *jcr) { - FILESET_DBR fsr; POOL_DBR pr; - memset(&fsr, 0, sizeof(fsr); - if (!get_or_create_fileset_record(jcr, &fsr)) { + if (!get_or_create_fileset_record(jcr)) { return false; } - bstrncpy(jcr->FSCreateTime, fsr.cCreateTime, sizeof(jcr->FSCreateTime)); /* * Get definitive Job level and since time diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c index c0f2cddc79..d3c02e1c32 100644 --- a/bacula/src/dird/fd_cmds.c +++ b/bacula/src/dird/fd_cmds.c @@ -140,7 +140,7 @@ void get_level_since_time(JCR *jcr, char *since, int since_len) since[0] = 0; if (jcr->cloned) { - if ( jcr->stime && jcr->stime[0]) { + if (jcr->stime && jcr->stime[0]) { bstrncpy(since, _(", since="), since_len); bstrncat(since, jcr->stime, since_len); } diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index faef49445a..ecb0d7bf34 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -634,32 +634,34 @@ bool get_or_create_client_record(JCR *jcr) return true; } -bool get_or_create_fileset_record(JCR *jcr, FILESET_DBR *fsr) +bool get_or_create_fileset_record(JCR *jcr) { + FILESET_DBR fsr; /* * Get or Create FileSet record */ - memset(fsr, 0, sizeof(FILESET_DBR)); - bstrncpy(fsr->FileSet, jcr->fileset->hdr.name, sizeof(fsr->FileSet)); + memset(&fsr, 0, sizeof(FILESET_DBR)); + bstrncpy(fsr.FileSet, jcr->fileset->hdr.name, sizeof(fsr.FileSet)); if (jcr->fileset->have_MD5) { struct MD5Context md5c; unsigned char signature[16]; memcpy(&md5c, &jcr->fileset->md5c, sizeof(md5c)); MD5Final(signature, &md5c); - bin_to_base64(fsr->MD5, (char *)signature, 16); /* encode 16 bytes */ - bstrncpy(jcr->fileset->MD5, fsr->MD5, sizeof(jcr->fileset->MD5)); + bin_to_base64(fsr.MD5, (char *)signature, 16); /* encode 16 bytes */ + bstrncpy(jcr->fileset->MD5, fsr.MD5, sizeof(jcr->fileset->MD5)); } else { Jmsg(jcr, M_WARNING, 0, _("FileSet MD5 signature not found.\n")); } if (!jcr->fileset->ignore_fs_changes || - !db_get_fileset_record(jcr, jcr->db, fsr)) { - if (!db_create_fileset_record(jcr, jcr->db, fsr)) { + !db_get_fileset_record(jcr, jcr->db, &fsr)) { + if (!db_create_fileset_record(jcr, jcr->db, &fsr)) { Jmsg(jcr, M_ERROR, 0, _("Could not create FileSet \"%s\" record. ERR=%s\n"), - fsr->FileSet, db_strerror(jcr->db)); + fsr.FileSet, db_strerror(jcr->db)); return false; } } - jcr->jr.FileSetId = fsr->FileSetId; + jcr->jr.FileSetId = fsr.FileSetId; + bstrncpy(jcr->FSCreateTime, fsr.cCreateTime, sizeof(jcr->FSCreateTime)); Dmsg2(119, "Created FileSet %s record %u\n", jcr->fileset->hdr.name, jcr->jr.FileSetId); return true; diff --git a/bacula/src/dird/mac.c b/bacula/src/dird/mac.c index 3356fb8a1e..bd6c1d2dc5 100644 --- a/bacula/src/dird/mac.c +++ b/bacula/src/dird/mac.c @@ -9,29 +9,23 @@ * Open DB and create records for this job. * Open Message Channel with Storage daemon to tell him a job will be starting. * Open connection with File daemon and pass him commands - * to do the backup. + * to do the backup. * When the File daemon finishes the job, update the DB. * * Version $Id$ */ - /* Copyright (C) 2004-2005 Kern Sibbald This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. + modify it under the terms of the GNU General Public License + version 2 as amended with additional clauses defined in the + file LICENSE in the main source directory. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + the file LICENSE for additional details. */ @@ -45,16 +39,14 @@ */ bool do_mac_init(JCR *jcr) { - FILESET_DBR fsr; POOL_DBR pr; JOB_DBR jr; JobId_t input_jobid; char *Name; - if (!get_or_create_fileset_record(jcr, &fsr)) { + if (!get_or_create_fileset_record(jcr)) { return false; } - bstrncpy(jcr->FSCreateTime, fsr.cCreateTime, sizeof(jcr->FSCreateTime)); /* * Find JobId of last job that ran. @@ -77,17 +69,17 @@ bool do_mac_init(JCR *jcr) switch (jcr->JobLevel) { case L_FULL: if (jcr->full_pool) { - jcr->pool = jcr->full_pool; + jcr->pool = jcr->full_pool; } break; case L_INCREMENTAL: if (jcr->inc_pool) { - jcr->pool = jcr->inc_pool; + jcr->pool = jcr->inc_pool; } break; case L_DIFFERENTIAL: if (jcr->dif_pool) { - jcr->pool = jcr->dif_pool; + jcr->pool = jcr->dif_pool; } break; } @@ -98,13 +90,13 @@ bool do_mac_init(JCR *jcr) /* Try to create the pool */ if (create_pool(jcr, jcr->db, jcr->pool, POOL_OP_CREATE) < 0) { Jmsg(jcr, M_FATAL, 0, _("Pool %s not in database. %s"), pr.Name, - db_strerror(jcr->db)); - return false; + db_strerror(jcr->db)); + return false; } else { Jmsg(jcr, M_INFO, 0, _("Pool %s created in database.\n"), pr.Name); } } - jcr->PoolId = pr.PoolId; /****FIXME**** this can go away */ + jcr->PoolId = pr.PoolId; /****FIXME**** this can go away */ jcr->jr.PoolId = pr.PoolId; jcr->needs_sd = true; return true; @@ -114,7 +106,7 @@ bool do_mac_init(JCR *jcr) * Do a Migration, Archive, or Copy of a previous job * * Returns: false on failure - * true on success + * true on success */ bool do_mac(JCR *jcr) { @@ -139,7 +131,7 @@ bool do_mac(JCR *jcr) /* Print Job Start message */ Jmsg(jcr, M_INFO, 0, _("Start %s JobId %u, Job=%s\n"), - Type, jcr->JobId, jcr->Job); + Type, jcr->JobId, jcr->Job); set_jcr_job_status(jcr, JS_Running); Dmsg2(100, "JobId=%d JobLevel=%c\n", jcr->jr.JobId, jcr->jr.JobLevel); @@ -226,22 +218,22 @@ void mac_cleanup(JCR *jcr, int TermCode) } Dmsg2(100, "Enter mac_cleanup %d %c\n", TermCode, TermCode); - dequeue_messages(jcr); /* display any queued messages */ + dequeue_messages(jcr); /* display any queued messages */ memset(&mr, 0, sizeof(mr)); set_jcr_job_status(jcr, TermCode); - update_job_end_record(jcr); /* update database */ + update_job_end_record(jcr); /* update database */ if (!db_get_job_record(jcr, jcr->db, &jcr->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting job record for stats: %s"), - db_strerror(jcr->db)); + db_strerror(jcr->db)); set_jcr_job_status(jcr, JS_ErrorTerminated); } bstrncpy(mr.VolumeName, jcr->VolumeName, sizeof(mr.VolumeName)); if (!db_get_media_record(jcr, jcr->db, &mr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Media record for Volume \"%s\": ERR=%s"), - mr.VolumeName, db_strerror(jcr->db)); + mr.VolumeName, db_strerror(jcr->db)); set_jcr_job_status(jcr, JS_ErrorTerminated); } @@ -256,87 +248,87 @@ void mac_cleanup(JCR *jcr, int TermCode) int VolCount; if (*fname == '|') { - fname++; - got_pipe = 1; + fname++; + got_pipe = 1; bpipe = open_bpipe(fname, 0, "w"); - fd = bpipe ? bpipe->wfd : NULL; + fd = bpipe ? bpipe->wfd : NULL; } else { - /* ***FIXME*** handle BASE */ + /* ***FIXME*** handle BASE */ fd = fopen(fname, jcr->JobLevel==L_FULL?"w+":"a+"); } if (fd) { - VolCount = db_get_job_volume_parameters(jcr, jcr->db, jcr->JobId, - &VolParams); - if (VolCount == 0) { + VolCount = db_get_job_volume_parameters(jcr, jcr->db, jcr->JobId, + &VolParams); + if (VolCount == 0) { Jmsg(jcr, M_ERROR, 0, _("Could not get Job Volume Parameters to " "update Bootstrap file. ERR=%s\n"), db_strerror(jcr->db)); - if (jcr->SDJobFiles != 0) { - set_jcr_job_status(jcr, JS_ErrorTerminated); - } + if (jcr->SDJobFiles != 0) { + set_jcr_job_status(jcr, JS_ErrorTerminated); + } - } - for (int i=0; i < VolCount; i++) { - /* Write the record */ + } + for (int i=0; i < VolCount; i++) { + /* Write the record */ fprintf(fd, "Volume=\"%s\"\n", VolParams[i].VolumeName); fprintf(fd, "MediaType=\"%s\"\n", VolParams[i].MediaType); fprintf(fd, "VolSessionId=%u\n", jcr->VolSessionId); fprintf(fd, "VolSessionTime=%u\n", jcr->VolSessionTime); fprintf(fd, "VolFile=%u-%u\n", VolParams[i].StartFile, - VolParams[i].EndFile); + VolParams[i].EndFile); fprintf(fd, "VolBlock=%u-%u\n", VolParams[i].StartBlock, - VolParams[i].EndBlock); + VolParams[i].EndBlock); fprintf(fd, "FileIndex=%d-%d\n", VolParams[i].FirstIndex, - VolParams[i].LastIndex); - } - if (VolParams) { - free(VolParams); - } - if (got_pipe) { - close_bpipe(bpipe); - } else { - fclose(fd); - } + VolParams[i].LastIndex); + } + if (VolParams) { + free(VolParams); + } + if (got_pipe) { + close_bpipe(bpipe); + } else { + fclose(fd); + } } else { - berrno be; + berrno be; Jmsg(jcr, M_ERROR, 0, _("Could not open WriteBootstrap file:\n" "%s: ERR=%s\n"), fname, be.strerror()); - set_jcr_job_status(jcr, JS_ErrorTerminated); + set_jcr_job_status(jcr, JS_ErrorTerminated); } } - msg_type = M_INFO; /* by default INFO message */ + msg_type = M_INFO; /* by default INFO message */ switch (jcr->JobStatus) { case JS_Terminated: - if (jcr->Errors || jcr->SDErrors) { + if (jcr->Errors || jcr->SDErrors) { term_msg = _("Backup OK -- with warnings"); - } else { + } else { term_msg = _("Backup OK"); - } - break; + } + break; case JS_FatalError: case JS_ErrorTerminated: term_msg = _("*** Backup Error ***"); - msg_type = M_ERROR; /* Generate error message */ - if (jcr->store_bsock) { - bnet_sig(jcr->store_bsock, BNET_TERMINATE); - if (jcr->SD_msg_chan) { - pthread_cancel(jcr->SD_msg_chan); - } - } - break; + msg_type = M_ERROR; /* Generate error message */ + if (jcr->store_bsock) { + bnet_sig(jcr->store_bsock, BNET_TERMINATE); + if (jcr->SD_msg_chan) { + pthread_cancel(jcr->SD_msg_chan); + } + } + break; case JS_Canceled: term_msg = _("Backup Canceled"); - if (jcr->store_bsock) { - bnet_sig(jcr->store_bsock, BNET_TERMINATE); - if (jcr->SD_msg_chan) { - pthread_cancel(jcr->SD_msg_chan); - } - } - break; + if (jcr->store_bsock) { + bnet_sig(jcr->store_bsock, BNET_TERMINATE); + if (jcr->SD_msg_chan) { + pthread_cancel(jcr->SD_msg_chan); + } + } + break; default: - term_msg = term_code; + term_msg = term_code; sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus); - break; + break; } bstrftimes(sdt, sizeof(sdt), jcr->jr.StartTime); bstrftimes(edt, sizeof(edt), jcr->jr.EndTime); @@ -356,7 +348,7 @@ void mac_cleanup(JCR *jcr, int TermCode) if (jcr->JobStatus == JS_Terminated && jcr->jr.JobBytes) { Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db)); } - jcr->VolumeName[0] = 0; /* none */ + jcr->VolumeName[0] = 0; /* none */ } if (jcr->ReadBytes == 0) { @@ -372,7 +364,7 @@ void mac_cleanup(JCR *jcr, int TermCode) jobstatus_to_ascii(jcr->FDJobStatus, fd_term_msg, sizeof(fd_term_msg)); jobstatus_to_ascii(jcr->SDJobStatus, sd_term_msg, sizeof(sd_term_msg)); -// bmicrosleep(15, 0); /* for debugging SIGHUP */ +// bmicrosleep(15, 0); /* for debugging SIGHUP */ Jmsg(jcr, msg_type, 0, _("Bacula %s (%s): %s\n" " JobId: %d\n" @@ -400,30 +392,30 @@ void mac_cleanup(JCR *jcr, int TermCode) " Termination: %s\n\n"), VERSION, LSMDATE, - edt, - jcr->jr.JobId, - jcr->jr.Job, - level_to_str(jcr->JobLevel), jcr->since, - jcr->client->hdr.name, - jcr->fileset->hdr.name, jcr->FSCreateTime, - jcr->pool->hdr.name, - sdt, - edt, - edit_uint64_with_commas(jcr->jr.JobFiles, ec1), - edit_uint64_with_commas(jcr->SDJobFiles, ec4), - edit_uint64_with_commas(jcr->jr.JobBytes, ec2), - edit_uint64_with_commas(jcr->SDJobBytes, ec5), - (float)kbps, - compress, - jcr->VolumeName, - jcr->VolSessionId, - jcr->VolSessionTime, - edit_uint64_with_commas(mr.VolBytes, ec3), - jcr->Errors, - jcr->SDErrors, - fd_term_msg, - sd_term_msg, - term_msg); + edt, + jcr->jr.JobId, + jcr->jr.Job, + level_to_str(jcr->JobLevel), jcr->since, + jcr->client->hdr.name, + jcr->fileset->hdr.name, jcr->FSCreateTime, + jcr->pool->hdr.name, + sdt, + edt, + edit_uint64_with_commas(jcr->jr.JobFiles, ec1), + edit_uint64_with_commas(jcr->SDJobFiles, ec4), + edit_uint64_with_commas(jcr->jr.JobBytes, ec2), + edit_uint64_with_commas(jcr->SDJobBytes, ec5), + (float)kbps, + compress, + jcr->VolumeName, + jcr->VolSessionId, + jcr->VolSessionTime, + edit_uint64_with_commas(mr.VolBytes, ec3), + jcr->Errors, + jcr->SDErrors, + fd_term_msg, + sd_term_msg, + term_msg); Dmsg0(100, "Leave mac_cleanup()\n"); } diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index b96d60ba53..a7da723d91 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -92,7 +92,7 @@ extern void set_jcr_defaults(JCR *jcr, JOB *job); extern void create_unique_job_name(JCR *jcr, const char *base_name); extern void update_job_end_record(JCR *jcr); extern bool get_or_create_client_record(JCR *jcr); -extern bool get_or_create_fileset_record(JCR *jcr, FILESET_DBR *fsr); +extern bool get_or_create_fileset_record(JCR *jcr); extern JobId_t run_job(JCR *jcr); extern bool cancel_job(UAContext *ua, JCR *jcr); extern void init_jcr_job_record(JCR *jcr); diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 692a7b69ed..47508a6e92 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -902,7 +902,6 @@ static int estimate_cmd(UAContext *ua, const char *cmd) JOB *job = NULL; CLIENT *client = NULL; FILESET *fileset = NULL; - FILESET_DBR fsr; int listing = 0; char since[MAXSTRING]; JCR *jcr = ua->jcr; @@ -973,7 +972,7 @@ static int estimate_cmd(UAContext *ua, const char *cmd) if (!get_or_create_client_record(jcr)) { return 1; } - if (!get_or_create_fileset_record(jcr, &fsr)) { + if (!get_or_create_fileset_record(jcr)) { return 1; } -- 2.39.5