From fddf5cf144446d52e872b4880989d4a09559b034 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 14 Jul 2008 15:47:39 +0000 Subject: [PATCH] kes Remove old code from label.c kes Split display_display_info() out of write_bsr_file() kes do_vbackup_init() working -- i.e. bootstrap file built. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7381 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/bsr.c | 48 +++++++++++++++++++----------------- bacula/src/dird/protos.h | 8 ++++++ bacula/src/dird/ua_restore.c | 2 ++ bacula/src/dird/vbackup.c | 28 ++++++++++++++++----- bacula/src/stored/label.c | 21 ---------------- bacula/technotes-2.5 | 3 +++ 6 files changed, 60 insertions(+), 50 deletions(-) diff --git a/bacula/src/dird/bsr.c b/bacula/src/dird/bsr.c index a89451f12d..2e9d73df81 100644 --- a/bacula/src/dird/bsr.c +++ b/bacula/src/dird/bsr.c @@ -1,18 +1,7 @@ -/* - * - * Bacula Director -- Bootstrap Record routines. - * - * BSR (bootstrap record) handling routines split from - * ua_restore.c July MMIII - * - * Kern Sibbald, July MMII - * - * Version $Id$ - */ /* Bacula® - The Network Backup Solution - Copyright (C) 2002-2006 Free Software Foundation Europe e.V. + Copyright (C) 2002-2008 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. @@ -36,14 +25,23 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * + * Bacula Director -- Bootstrap Record routines. + * + * BSR (bootstrap record) handling routines split from + * ua_restore.c July MMIII + * + * Kern Sibbald, July MMII + * + * Version $Id$ + */ #include "bacula.h" #include "dird.h" /* Forward referenced functions */ static uint32_t write_bsr(UAContext *ua, RESTORE_CTX &rx, FILE *fd); -void print_bsr(UAContext *ua, RBSR *bsr); - /* * Create new FileIndex entry for BSR @@ -233,12 +231,8 @@ uint32_t write_bsr_file(UAContext *ua, RESTORE_CTX &rx) { FILE *fd; POOL_MEM fname(PM_MESSAGE); - POOL_MEM volmsg(PM_MESSAGE); uint32_t count = 0;; bool err; - char *p; - JobId_t JobId; - char Device[MAX_NAME_LENGTH]; make_unique_restore_filename(ua, fname); fd = fopen(fname.c_str(), "w+b"); @@ -253,7 +247,7 @@ uint32_t write_bsr_file(UAContext *ua, RESTORE_CTX &rx) err = ferror(fd); fclose(fd); if (count == 0) { - ua->info_msg(_("No files found to restore/migrate. No bootstrap file written.\n")); + ua->info_msg(_("No files found to read. No bootstrap file written.\n")); goto bail_out; } if (err) { @@ -262,9 +256,19 @@ uint32_t write_bsr_file(UAContext *ua, RESTORE_CTX &rx) goto bail_out; } - ua->send_msg(_("Bootstrap records written to %s\n"), fname.c_str()); +bail_out: + return count; +} + +void display_bsr_info(UAContext *ua, RESTORE_CTX &rx) +{ + char *p; + POOL_MEM volmsg(PM_MESSAGE); + JobId_t JobId; + char Device[MAX_NAME_LENGTH]; + /* Tell the user what he will need to mount */ ua->send_msg("\n"); ua->send_msg(_("The job will require the following\n" @@ -314,13 +318,11 @@ uint32_t write_bsr_file(UAContext *ua, RESTORE_CTX &rx) } if (ua->num_prompts == 0) { ua->send_msg(_("No Volumes found to restore.\n")); - count = 0; } ua->num_prompts = 0; ua->send_msg("\n"); -bail_out: - return count; + return; } /* diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index 08530ecc88..dd4c4919f8 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -58,15 +58,23 @@ extern bool do_backup(JCR *jcr); extern void backup_cleanup(JCR *jcr, int TermCode); extern void update_bootstrap_file(JCR *jcr); +/* vbackup.c */ +extern bool do_vbackup_init(JCR *jcr); +extern bool do_vbackup(JCR *jcr); +extern void vbackup_cleanup(JCR *jcr, int TermCode); + + /* bsr.c */ RBSR *new_bsr(); void free_bsr(RBSR *bsr); bool complete_bsr(UAContext *ua, RBSR *bsr); uint32_t write_bsr_file(UAContext *ua, RESTORE_CTX &rx); +void display_bsr_info(UAContext *ua, RESTORE_CTX &rx); void add_findex(RBSR *bsr, uint32_t JobId, int32_t findex); void add_findex_all(RBSR *bsr, uint32_t JobId); RBSR_FINDEX *new_findex(); void make_unique_restore_filename(UAContext *ua, POOLMEM **fname); +void print_bsr(UAContext *ua, RBSR *bsr); /* catreq.c */ diff --git a/bacula/src/dird/ua_restore.c b/bacula/src/dird/ua_restore.c index cf71a85503..b7b80569b8 100644 --- a/bacula/src/dird/ua_restore.c +++ b/bacula/src/dird/ua_restore.c @@ -194,6 +194,8 @@ int restore_cmd(UAContext *ua, const char *cmd) ua->warning_msg(_("No files selected to be restored.\n")); goto bail_out; } + display_bsr_info(ua, rx); /* display vols needed, etc */ + /* If no count of files, use bsr generated value (often wrong) */ if (rx.selected_files == 0) { rx.selected_files = selected_files; diff --git a/bacula/src/dird/vbackup.c b/bacula/src/dird/vbackup.c index 724c4b6368..4368042547 100644 --- a/bacula/src/dird/vbackup.c +++ b/bacula/src/dird/vbackup.c @@ -61,6 +61,12 @@ void vbackup_cleanup(JCR *jcr, int TermCode); */ bool do_vbackup_init(JCR *jcr) { + /* ***FIXME*** remove when implemented in job.c */ + if (!jcr->rpool_source) { + jcr->rpool_source = get_pool_memory(PM_MESSAGE); + pm_strcpy(jcr->rpool_source, _("unknown source")); + } + if (!get_or_create_fileset_record(jcr)) { Dmsg1(dbglevel, "JobId=%d no FileSet\n", (int)jcr->JobId); return false; @@ -86,13 +92,13 @@ bool do_vbackup_init(JCR *jcr) POOLMEM *jobids = get_pool_memory(PM_FNAME); db_accurate_get_jobids(jcr, jcr->db, &jcr->jr, jobids); + Dmsg1(000, "Accurate jobids=%s\n", jobids); if (*jobids == 0) { free_pool_memory(jobids); Jmsg(jcr, M_FATAL, 0, _("Cannot find previous JobIds.\n")); return false; } - if (!create_bootstrap_file(jcr, jobids)) { Jmsg(jcr, M_FATAL, 0, _("Could not get or create the FileSet record.\n")); free_pool_memory(jobids); @@ -487,15 +493,18 @@ static bool create_bootstrap_file(JCR *jcr, POOLMEM *jobids) memset(&rx, 0, sizeof(rx)); rx.bsr = new_bsr(); ua = new_ua_context(jcr); + rx.JobIds = jobids; #define new_get_file_list #ifdef new_get_file_list - if (!db_get_file_list(jcr, ua->db, jobids, insert_bootstrap_handler, (void *)&rx.bsr)) { + if (!db_get_file_list(jcr, ua->db, jobids, insert_bootstrap_handler, (void *)rx.bsr)) { Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(ua->db)); } #else - JobId_t JobId; - for (p=rx->JobIds; get_next_jobid_from_list(&p, &JobId) > 0; ) { + char *p; + JobId_t JobId, last_JobId = 0; + rx.query = get_pool_memory(PM_MESSAGE); + for (p=rx.JobIds; get_next_jobid_from_list(&p, &JobId) > 0; ) { char ed1[50]; if (JobId == last_JobId) { @@ -505,15 +514,22 @@ static bool create_bootstrap_file(JCR *jcr, POOLMEM *jobids) /* * Find files for this JobId and insert them in the tree */ - Mmsg(rx->query, uar_sel_files, edit_int64(JobId, ed1)); - if (!db_sql_query(ua->db, rx->query, insert_tree_handler, (void *)&rx.bsr)) { + Mmsg(rx.query, uar_sel_files, edit_int64(JobId, ed1)); + Dmsg1(000, "uar_sel_files=%s\n", rx.query); + if (!db_sql_query(ua->db, rx.query, insert_bootstrap_handler, (void *)rx.bsr)) { Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(ua->db)); } + free_pool_memory(rx.query); + rx.query = NULL; } #endif complete_bsr(ua, rx.bsr); + Dmsg0(000, "Print bsr\n"); + print_bsr(ua, rx.bsr); + jcr->ExpectedFiles = write_bsr_file(ua, rx); + Dmsg1(000, "Found %d files to consolidate.\n", jcr->ExpectedFiles); if (jcr->ExpectedFiles == 0) { free_ua_context(ua); free_bsr(rx.bsr); diff --git a/bacula/src/stored/label.c b/bacula/src/stored/label.c index da2926148e..43b2cf2cfe 100644 --- a/bacula/src/stored/label.c +++ b/bacula/src/stored/label.c @@ -85,27 +85,6 @@ int read_dev_volume_label(DCR *dcr) return VOL_IO_ERROR; } } -#ifdef xxx - if (dev->is_labeled()) { /* did we already read label? */ - /* Compare Volume Names allow special wild card */ - if (VolName && *VolName && *VolName != '*' && strcmp(dev->VolHdr.VolumeName, VolName) != 0) { - Mmsg(jcr->errmsg, _("Wrong Volume mounted on device %s: Wanted %s have %s\n"), - dev->print_name(), VolName, dev->VolHdr.VolumeName); - /* - * Cancel Job if too many label errors - * => we are in a loop - */ - if (!dev->poll && jcr->label_errors++ > 100) { - Jmsg(jcr, M_FATAL, 0, _("Too many tries: %s"), jcr->errmsg); - } - Dmsg0(150, "return VOL_NAME_ERROR\n"); - stat = VOL_NAME_ERROR; - goto bail_out; - } - Dmsg0(130, "Leave read_volume_label() VOL_OK\n"); - return VOL_OK; /* label already read */ - } -#endif dev->clear_labeled(); dev->clear_append(); diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index 4900a02477..21158967a4 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -31,6 +31,9 @@ vtape driver General: 14Jul08 +kes Remove old code from label.c +kes Split display_display_info() out of write_bsr_file() +kes do_vbackup_init() working -- i.e. bootstrap file built. kes Change Bacula trademark owner from John Walker to Kern Sibbald kes First non-working cut of vbackup kes Correct FD heartbeat code to use volatile variable accessed by -- 2.39.5