-/*
- *
- * 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.
(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
{
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");
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) {
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"
}
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;
}
/*
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 */
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;
*/
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;
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);
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) {
/*
* 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);
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();
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