2 * Bacula File Daemon Job processing
4 * Kern Sibbald, October MM
10 Copyright (C) 2000-2005 Kern Sibbald
12 This program is free software; you can redistribute it and/or
13 modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation; either version 2 of
15 the License, or (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 General Public License for more details.
22 You should have received a copy of the GNU General Public
23 License along with this program; if not, write to the Free
24 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
32 extern char my_name[];
33 extern CLIENT *me; /* our client resource */
35 /* Imported functions */
36 extern int status_cmd(JCR *jcr);
37 extern int qstatus_cmd(JCR *jcr);
39 /* Forward referenced functions */
40 static int backup_cmd(JCR *jcr);
41 static int bootstrap_cmd(JCR *jcr);
42 static int cancel_cmd(JCR *jcr);
43 static int setdebug_cmd(JCR *jcr);
44 static int estimate_cmd(JCR *jcr);
45 static int hello_cmd(JCR *jcr);
46 static int job_cmd(JCR *jcr);
47 static int fileset_cmd(JCR *jcr);
48 static int level_cmd(JCR *jcr);
49 static int verify_cmd(JCR *jcr);
50 static int restore_cmd(JCR *jcr);
51 static int storage_cmd(JCR *jcr);
52 static int session_cmd(JCR *jcr);
53 static int response(JCR *jcr, BSOCK *sd, char *resp, const char *cmd);
54 static void filed_free_jcr(JCR *jcr);
55 static int open_sd_read_session(JCR *jcr);
56 static int send_bootstrap_file(JCR *jcr);
57 static int runbefore_cmd(JCR *jcr);
58 static int runafter_cmd(JCR *jcr);
59 static bool run_cmd(JCR *jcr, char *cmd, const char *name);
60 static void set_options(findFOPTS *fo, const char *opts);
63 /* Exported functions */
68 int monitoraccess; /* specify if monitors have access to this function */
72 * The following are the recognized commands from the Director.
74 static struct s_cmds cmds[] = {
75 {"backup", backup_cmd, 0},
76 {"cancel", cancel_cmd, 0},
77 {"setdebug=", setdebug_cmd, 0},
78 {"estimate", estimate_cmd, 0},
79 {"Hello", hello_cmd, 1},
80 {"fileset", fileset_cmd, 0},
81 {"JobId=", job_cmd, 0},
82 {"level = ", level_cmd, 0},
83 {"restore", restore_cmd, 0},
84 {"session", session_cmd, 0},
85 {"status", status_cmd, 1},
86 {".status", qstatus_cmd, 1},
87 {"storage ", storage_cmd, 0},
88 {"verify", verify_cmd, 0},
89 {"bootstrap", bootstrap_cmd, 0},
90 {"RunBeforeJob", runbefore_cmd, 0},
91 {"RunAfterJob", runafter_cmd, 0},
92 {NULL, NULL} /* list terminator */
95 /* Commands received from director that need scanning */
96 static char jobcmd[] = "JobId=%d Job=%127s SDid=%d SDtime=%d Authorization=%100s";
97 static char storaddr[] = "storage address=%s port=%d ssl=%d\n";
98 static char sessioncmd[] = "session %127s %ld %ld %ld %ld %ld %ld\n";
99 static char restorecmd[] = "restore replace=%c prelinks=%d where=%s\n";
100 static char restorecmd1[] = "restore replace=%c prelinks=%d where=\n";
101 static char verifycmd[] = "verify level=%30s\n";
102 static char estimatecmd[] = "estimate listing=%d\n";
103 static char runbefore[] = "RunBeforeJob %s\n";
104 static char runafter[] = "RunAfterJob %s\n";
106 /* Responses sent to Director */
107 static char errmsg[] = "2999 Invalid command\n";
108 static char no_auth[] = "2998 No Authorization\n";
109 static char illegal_cmd[] = "2997 Illegal command for a Director with Monitor directive enabled\n";
110 static char OKinc[] = "2000 OK include\n";
111 static char OKest[] = "2000 OK estimate files=%u bytes=%s\n";
112 static char OKlevel[] = "2000 OK level\n";
113 static char OKbackup[] = "2000 OK backup\n";
114 static char OKbootstrap[] = "2000 OK bootstrap\n";
115 static char OKverify[] = "2000 OK verify\n";
116 static char OKrestore[] = "2000 OK restore\n";
117 static char OKsession[] = "2000 OK session\n";
118 static char OKstore[] = "2000 OK storage\n";
119 static char OKjob[] = "2000 OK Job %s,%s,%s";
120 static char OKsetdebug[] = "2000 OK setdebug=%d\n";
121 static char BADjob[] = "2901 Bad Job\n";
122 static char EndJob[] = "2800 End Job TermCode=%d JobFiles=%u ReadBytes=%s JobBytes=%s Errors=%u\n";
123 static char OKRunBefore[] = "2000 OK RunBefore\n";
124 static char OKRunAfter[] = "2000 OK RunAfter\n";
126 /* Responses received from Storage Daemon */
127 static char OK_end[] = "3000 OK end\n";
128 static char OK_close[] = "3000 OK close Status = %d\n";
129 static char OK_open[] = "3000 OK open ticket = %d\n";
130 static char OK_data[] = "3000 OK data\n";
131 static char OK_append[] = "3000 OK append data\n";
132 static char OKSDbootstrap[] = "3000 OK bootstrap\n";
135 /* Commands sent to Storage Daemon */
136 static char append_open[] = "append open session\n";
137 static char append_data[] = "append data %d\n";
138 static char append_end[] = "append end session %d\n";
139 static char append_close[] = "append close session %d\n";
140 static char read_open[] = "read open session = %s %ld %ld %ld %ld %ld %ld\n";
141 static char read_data[] = "read data %d\n";
142 static char read_close[] = "read close session %d\n";
145 * Accept requests from a Director
147 * NOTE! We are running as a separate thread
149 * Send output one line
150 * at a time followed by a zero length transmission.
152 * Return when the connection is terminated or there
155 * Basic task here is:
156 * Authenticate Director (during Hello command).
157 * Accept commands one at a time from the Director
161 void *handle_client_request(void *dirp)
166 BSOCK *dir = (BSOCK *)dirp;
168 jcr = new_jcr(sizeof(JCR), filed_free_jcr); /* create JCR */
169 jcr->dir_bsock = dir;
170 jcr->ff = init_find_files();
171 jcr->start_time = time(NULL);
172 jcr->last_fname = get_pool_memory(PM_FNAME);
173 jcr->last_fname[0] = 0;
174 jcr->client_name = get_memory(strlen(my_name) + 1);
175 pm_strcpy(jcr->client_name, my_name);
177 enable_backup_privileges(NULL, 1 /* ignore_errors */);
179 /**********FIXME******* add command handler error code */
181 for (quit=false; !quit;) {
184 if (bnet_recv(dir) < 0) {
185 break; /* connection terminated */
187 dir->msg[dir->msglen] = 0;
188 Dmsg1(100, "<dird: %s", dir->msg);
190 for (i=0; cmds[i].cmd; i++) {
191 if (strncmp(cmds[i].cmd, dir->msg, strlen(cmds[i].cmd)) == 0) {
192 found = true; /* indicate command found */
193 if (!jcr->authenticated && cmds[i].func != hello_cmd) {
194 bnet_fsend(dir, no_auth);
195 bnet_sig(dir, BNET_EOD);
198 if ((jcr->authenticated) && (!cmds[i].monitoraccess) && (jcr->director->monitor)) {
199 Dmsg1(100, "Command %s illegal.\n", cmds[i].cmd);
200 bnet_fsend(dir, illegal_cmd);
201 bnet_sig(dir, BNET_EOD);
204 Dmsg1(100, "Executing %s command.\n", cmds[i].cmd);
205 if (!cmds[i].func(jcr)) { /* do command */
206 quit = true; /* error or fully terminated, get out */
207 Dmsg0(20, "Quit command loop due to command error or Job done.\n");
212 if (!found) { /* command not found */
213 bnet_fsend(dir, errmsg);
219 /* Inform Storage daemon that we are done */
220 if (jcr->store_bsock) {
221 bnet_sig(jcr->store_bsock, BNET_TERMINATE);
224 if (jcr->RunAfterJob && !job_canceled(jcr)) {
225 run_cmd(jcr, jcr->RunAfterJob, "ClientRunAfterJob");
227 dequeue_messages(jcr); /* send any queued messages */
229 /* Inform Director that we are done */
230 bnet_sig(dir, BNET_TERMINATE);
232 /* Clean up fileset */
233 FF_PKT *ff = (FF_PKT *)jcr->ff;
234 findFILESET *fileset = ff->fileset;
237 /* Delete FileSet Include lists */
238 for (i=0; i<fileset->include_list.size(); i++) {
239 findINCEXE *incexe = (findINCEXE *)fileset->include_list.get(i);
240 for (j=0; j<incexe->opts_list.size(); j++) {
241 findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j);
242 for (k=0; k<fo->regex.size(); k++) {
243 regfree((regex_t *)fo->regex.get(k));
246 fo->regexdir.destroy();
247 fo->regexfile.destroy();
249 fo->wilddir.destroy();
250 fo->wildfile.destroy();
252 fo->fstype.destroy();
260 incexe->opts_list.destroy();
261 incexe->name_list.destroy();
263 fileset->include_list.destroy();
265 /* Delete FileSet Exclude lists */
266 for (i=0; i<fileset->exclude_list.size(); i++) {
267 findINCEXE *incexe = (findINCEXE *)fileset->exclude_list.get(i);
268 for (j=0; j<incexe->opts_list.size(); j++) {
269 findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j);
271 fo->regexdir.destroy();
272 fo->regexfile.destroy();
274 fo->wilddir.destroy();
275 fo->wildfile.destroy();
277 fo->fstype.destroy();
279 incexe->opts_list.destroy();
280 incexe->name_list.destroy();
282 fileset->exclude_list.destroy();
285 Dmsg0(100, "Calling term_find_files\n");
286 term_find_files((FF_PKT *)jcr->ff);
287 Dmsg0(100, "Done with term_find_files\n");
288 free_jcr(jcr); /* destroy JCR record */
289 Dmsg0(100, "Done with free_jcr\n");
294 * Hello from Director he must identify himself and provide his
297 static int hello_cmd(JCR *jcr)
299 Dmsg0(120, "Calling Authenticate\n");
300 if (!authenticate_director(jcr)) {
303 Dmsg0(120, "OK Authenticate\n");
304 jcr->authenticated = true;
311 static int cancel_cmd(JCR *jcr)
313 BSOCK *dir = jcr->dir_bsock;
314 char Job[MAX_NAME_LENGTH];
317 if (sscanf(dir->msg, "cancel Job=%127s", Job) == 1) {
318 if (!(cjcr=get_jcr_by_full_name(Job))) {
319 bnet_fsend(dir, "2901 Job %s not found.\n", Job);
321 if (cjcr->store_bsock) {
323 cjcr->store_bsock->timed_out = 1;
324 cjcr->store_bsock->terminated = 1;
326 * #if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32)
328 #if !defined(HAVE_CYGWIN)
329 pthread_kill(cjcr->my_thread_id, TIMEOUT_SIGNAL);
333 set_jcr_job_status(cjcr, JS_Canceled);
335 bnet_fsend(dir, _("2001 Job %s marked to be canceled.\n"), Job);
338 bnet_fsend(dir, _("2902 Error scanning cancel command.\n"));
340 bnet_sig(dir, BNET_EOD);
346 * Set debug level as requested by the Director
349 static int setdebug_cmd(JCR *jcr)
351 BSOCK *dir = jcr->dir_bsock;
352 int level, trace_flag;
354 Dmsg1(110, "setdebug_cmd: %s", dir->msg);
355 if (sscanf(dir->msg, "setdebug=%d trace=%d", &level, &trace_flag) != 2 || level < 0) {
356 pm_strcpy(jcr->errmsg, dir->msg);
357 bnet_fsend(dir, "2991 Bad setdebug command: %s\n", jcr->errmsg);
361 set_trace(trace_flag);
362 return bnet_fsend(dir, OKsetdebug, level);
366 static int estimate_cmd(JCR *jcr)
368 BSOCK *dir = jcr->dir_bsock;
371 if (sscanf(dir->msg, estimatecmd, &jcr->listing) != 1) {
372 pm_strcpy(jcr->errmsg, dir->msg);
373 Jmsg(jcr, M_FATAL, 0, _("Bad estimate command: %s"), jcr->errmsg);
374 bnet_fsend(dir, "2992 Bad estimate command.\n");
378 bnet_fsend(dir, OKest, jcr->num_files_examined,
379 edit_uint64_with_commas(jcr->JobBytes, ed2));
380 bnet_sig(dir, BNET_EOD);
385 * Get JobId and Storage Daemon Authorization key from Director
387 static int job_cmd(JCR *jcr)
389 BSOCK *dir = jcr->dir_bsock;
390 POOLMEM *sd_auth_key;
392 sd_auth_key = get_memory(dir->msglen);
393 if (sscanf(dir->msg, jobcmd, &jcr->JobId, jcr->Job,
394 &jcr->VolSessionId, &jcr->VolSessionTime,
396 pm_strcpy(jcr->errmsg, dir->msg);
397 Jmsg(jcr, M_FATAL, 0, _("Bad Job Command: %s"), jcr->errmsg);
398 bnet_fsend(dir, BADjob);
399 free_pool_memory(sd_auth_key);
402 jcr->sd_auth_key = bstrdup(sd_auth_key);
403 free_pool_memory(sd_auth_key);
404 Dmsg2(120, "JobId=%d Auth=%s\n", jcr->JobId, jcr->sd_auth_key);
405 return bnet_fsend(dir, OKjob, HOST_OS, DISTNAME, DISTVER);
408 static int runbefore_cmd(JCR *jcr)
411 BSOCK *dir = jcr->dir_bsock;
412 POOLMEM *cmd = get_memory(dir->msglen+1);
414 Dmsg1(100, "runbefore_cmd: %s", dir->msg);
415 if (sscanf(dir->msg, runbefore, cmd) != 1) {
416 pm_strcpy(jcr->errmsg, dir->msg);
417 Jmsg1(jcr, M_FATAL, 0, _("Bad RunBeforeJob command: %s\n"), jcr->errmsg);
418 bnet_fsend(dir, "2905 Bad RunBeforeJob command.\n");
424 /* Run the command now */
425 ok = run_cmd(jcr, cmd, "ClientRunBeforeJob");
428 bnet_fsend(dir, OKRunBefore);
431 bnet_fsend(dir, "2905 Bad RunBeforeJob command.\n");
436 static int runafter_cmd(JCR *jcr)
438 BSOCK *dir = jcr->dir_bsock;
439 POOLMEM *msg = get_memory(dir->msglen+1);
441 Dmsg1(100, "runafter_cmd: %s", dir->msg);
442 if (sscanf(dir->msg, runafter, msg) != 1) {
443 pm_strcpy(jcr->errmsg, dir->msg);
444 Jmsg1(jcr, M_FATAL, 0, _("Bad RunAfter command: %s\n"), jcr->errmsg);
445 bnet_fsend(dir, "2905 Bad RunAfterJob command.\n");
450 if (jcr->RunAfterJob) {
451 free_pool_memory(jcr->RunAfterJob);
453 jcr->RunAfterJob = get_pool_memory(PM_FNAME);
454 pm_strcpy(jcr->RunAfterJob, msg);
455 free_pool_memory(msg);
456 return bnet_fsend(dir, OKRunAfter);
459 static bool run_cmd(JCR *jcr, char *cmd, const char *name)
461 POOLMEM *ecmd = get_pool_memory(PM_FNAME);
464 char line[MAXSTRING];
466 ecmd = edit_job_codes(jcr, ecmd, cmd, "");
467 bpipe = open_bpipe(ecmd, 0, "r");
468 free_pool_memory(ecmd);
471 Jmsg(jcr, M_FATAL, 0, _("%s could not execute. ERR=%s\n"), name,
475 while (fgets(line, sizeof(line), bpipe->rfd)) {
476 int len = strlen(line);
477 if (len > 0 && line[len-1] == '\n') {
480 Jmsg(jcr, M_INFO, 0, _("%s: %s\n"), name, line);
482 status = close_bpipe(bpipe);
485 Jmsg(jcr, M_FATAL, 0, _("%s returned non-zero status=%d. ERR=%s\n"), name,
486 status, be.strerror(status));
492 static bool init_fileset(JCR *jcr)
495 findFILESET *fileset;
500 ff = (FF_PKT *)jcr->ff;
504 fileset = (findFILESET *)malloc(sizeof(findFILESET));
505 memset(fileset, 0, sizeof(findFILESET));
506 ff->fileset = fileset;
507 fileset->state = state_none;
508 fileset->include_list.init(1, true);
509 fileset->exclude_list.init(1, true);
513 static findFOPTS *start_options(FF_PKT *ff)
515 int state = ff->fileset->state;
516 findINCEXE *incexe = ff->fileset->incexe;
518 if (state != state_options) {
519 ff->fileset->state = state_options;
520 findFOPTS *fo = (findFOPTS *)malloc(sizeof(findFOPTS));
521 memset(fo, 0, sizeof(findFOPTS));
522 fo->regex.init(1, true);
523 fo->regexdir.init(1, true);
524 fo->regexfile.init(1, true);
525 fo->wild.init(1, true);
526 fo->wilddir.init(1, true);
527 fo->wildfile.init(1, true);
528 fo->base.init(1, true);
529 fo->fstype.init(1, true);
530 incexe->current_opts = fo;
531 incexe->opts_list.append(fo);
533 return incexe->current_opts;
538 * Add fname to include/exclude fileset list. First check for
539 * | and < and if necessary perform command.
541 static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *fileset)
553 p++; /* skip over | */
554 fn = get_pool_memory(PM_FNAME);
555 fn = edit_job_codes(jcr, fn, p, "");
556 bpipe = open_bpipe(fn, 0, "r");
557 free_pool_memory(fn);
559 Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"),
563 while (fgets(buf, sizeof(buf), bpipe->rfd)) {
564 strip_trailing_junk(buf);
565 fileset->incexe->name_list.append(bstrdup(buf));
567 if ((stat=close_bpipe(bpipe)) != 0) {
568 Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. RtnStat=%d ERR=%s\n"),
569 p, stat, strerror(errno));
574 Dmsg0(100, "Doing < include on client.\n");
575 p++; /* skip over < */
576 if ((ffd = fopen(p, "r")) == NULL) {
578 Jmsg(jcr, M_FATAL, 0, _("Cannot open FileSet input file: %s. ERR=%s\n"),
582 while (fgets(buf, sizeof(buf), ffd)) {
583 strip_trailing_junk(buf);
584 Dmsg1(100, "%s\n", buf);
585 fileset->incexe->name_list.append(bstrdup(buf));
590 fileset->incexe->name_list.append(bstrdup(fname));
596 static void add_fileset(JCR *jcr, const char *item)
598 FF_PKT *ff = (FF_PKT *)jcr->ff;
599 findFILESET *fileset = ff->fileset;
600 int state = fileset->state;
601 findFOPTS *current_opts;
603 /* Get code, optional subcode, and position item past the dividing space */
604 Dmsg1(100, "%s\n", item);
609 int subcode = ' '; /* A space is always a valid subcode */
610 if (item[0] != '\0' && item[0] != ' ') {
618 /* Skip all lines we receive after an error */
619 if (state == state_error) {
624 * The switch tests the code for validity.
625 * The subcode is always good if it is a space, otherwise we must confirm.
626 * We set state to state_error first assuming the subcode is invalid,
627 * requiring state to be set in cases below that handle subcodes.
629 if (subcode != ' ') {
635 fileset->incexe = (findINCEXE *)malloc(sizeof(findINCEXE));
636 memset(fileset->incexe, 0, sizeof(findINCEXE));
637 fileset->incexe->opts_list.init(1, true);
638 fileset->incexe->name_list.init(1, true);
639 fileset->include_list.append(fileset->incexe);
643 fileset->incexe = (findINCEXE *)malloc(sizeof(findINCEXE));
644 memset(fileset->incexe, 0, sizeof(findINCEXE));
645 fileset->incexe->opts_list.init(1, true);
646 fileset->incexe->name_list.init(1, true);
647 fileset->exclude_list.append(fileset->incexe);
653 /* File item to either include/include list */
654 state = state_include;
655 add_file_to_fileset(jcr, item, fileset);
658 current_opts = start_options(ff);
662 preg = (regex_t *)malloc(sizeof(regex_t));
663 if (current_opts->flags & FO_IGNORECASE) {
664 rc = regcomp(preg, item, REG_EXTENDED|REG_ICASE);
666 rc = regcomp(preg, item, REG_EXTENDED);
669 regerror(rc, preg, prbuf, sizeof(prbuf));
672 Jmsg(jcr, M_FATAL, 0, "REGEX %s compile error. ERR=%s\n", item, prbuf);
676 state = state_options;
677 if (subcode == ' ') {
678 current_opts->regex.append(preg);
679 } else if (subcode == 'D') {
680 current_opts->regexdir.append(preg);
681 } else if (subcode == 'F') {
682 current_opts->regexfile.append(preg);
688 current_opts = start_options(ff);
689 current_opts->base.append(bstrdup(item));
690 state = state_options;
693 current_opts = start_options(ff);
694 current_opts->fstype.append(bstrdup(item));
695 state = state_options;
698 current_opts = start_options(ff);
699 state = state_options;
700 if (subcode == ' ') {
701 current_opts->wild.append(bstrdup(item));
702 } else if (subcode == 'D') {
703 current_opts->wilddir.append(bstrdup(item));
704 } else if (subcode == 'F') {
705 current_opts->wildfile.append(bstrdup(item));
711 current_opts = start_options(ff);
712 set_options(current_opts, item);
713 state = state_options;
716 current_opts = start_options(ff);
717 current_opts->reader = bstrdup(item);
718 state = state_options;
721 current_opts = start_options(ff);
722 current_opts->writer = bstrdup(item);
723 state = state_options;
726 Jmsg(jcr, M_FATAL, 0, "Invalid FileSet command: %s\n", item);
730 ff->fileset->state = state;
733 static bool term_fileset(JCR *jcr)
735 FF_PKT *ff = (FF_PKT *)jcr->ff;
736 findFILESET *fileset = ff->fileset;
739 for (i=0; i<fileset->include_list.size(); i++) {
740 findINCEXE *incexe = (findINCEXE *)fileset->include_list.get(i);
742 for (j=0; j<incexe->opts_list.size(); j++) {
743 findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j);
744 for (k=0; k<fo->regex.size(); k++) {
745 Dmsg1(400, "R %s\n", (char *)fo->regex.get(k));
747 for (k=0; k<fo->regexdir.size(); k++) {
748 Dmsg1(400, "RD %s\n", (char *)fo->regexdir.get(k));
750 for (k=0; k<fo->regexfile.size(); k++) {
751 Dmsg1(400, "RF %s\n", (char *)fo->regexfile.get(k));
753 for (k=0; k<fo->wild.size(); k++) {
754 Dmsg1(400, "W %s\n", (char *)fo->wild.get(k));
756 for (k=0; k<fo->wilddir.size(); k++) {
757 Dmsg1(400, "WD %s\n", (char *)fo->wilddir.get(k));
759 for (k=0; k<fo->wildfile.size(); k++) {
760 Dmsg1(400, "WF %s\n", (char *)fo->wildfile.get(k));
762 for (k=0; k<fo->base.size(); k++) {
763 Dmsg1(400, "B %s\n", (char *)fo->base.get(k));
765 for (k=0; k<fo->fstype.size(); k++) {
766 Dmsg1(400, "X %s\n", (char *)fo->fstype.get(k));
769 Dmsg1(400, "D %s\n", fo->reader);
772 Dmsg1(400, "T %s\n", fo->writer);
775 for (j=0; j<incexe->name_list.size(); j++) {
776 Dmsg1(400, "F %s\n", (char *)incexe->name_list.get(j));
779 for (i=0; i<fileset->exclude_list.size(); i++) {
780 findINCEXE *incexe = (findINCEXE *)fileset->exclude_list.get(i);
782 for (j=0; j<incexe->opts_list.size(); j++) {
783 findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j);
784 for (k=0; k<fo->regex.size(); k++) {
785 Dmsg1(400, "R %s\n", (char *)fo->regex.get(k));
787 for (k=0; k<fo->regexdir.size(); k++) {
788 Dmsg1(400, "RD %s\n", (char *)fo->regexdir.get(k));
790 for (k=0; k<fo->regexfile.size(); k++) {
791 Dmsg1(400, "RF %s\n", (char *)fo->regexfile.get(k));
793 for (k=0; k<fo->wild.size(); k++) {
794 Dmsg1(400, "W %s\n", (char *)fo->wild.get(k));
796 for (k=0; k<fo->wilddir.size(); k++) {
797 Dmsg1(400, "WD %s\n", (char *)fo->wilddir.get(k));
799 for (k=0; k<fo->wildfile.size(); k++) {
800 Dmsg1(400, "WF %s\n", (char *)fo->wildfile.get(k));
802 for (k=0; k<fo->base.size(); k++) {
803 Dmsg1(400, "B %s\n", (char *)fo->base.get(k));
805 for (k=0; k<fo->fstype.size(); k++) {
806 Dmsg1(400, "X %s\n", (char *)fo->fstype.get(k));
809 for (j=0; j<incexe->name_list.size(); j++) {
810 Dmsg1(400, "F %s\n", (char *)incexe->name_list.get(j));
813 return ff->fileset->state != state_error;
818 * As an optimization, we should do this during
819 * "compile" time in filed/job.c, and keep only a bit mask
820 * and the Verify options.
822 static void set_options(findFOPTS *fo, const char *opts)
827 for (p=opts; *p; p++) {
829 case 'a': /* alway replace */
830 case '0': /* no option */
833 fo->flags |= FO_EXCLUDE;
836 fo->flags |= FO_MULTIFS;
838 case 'h': /* no recursion */
839 fo->flags |= FO_NO_RECURSION;
841 case 'H': /* no hard link handling */
842 fo->flags |= FO_NO_HARDLINK;
845 fo->flags |= FO_IGNORECASE;
851 fo->flags |= FO_NOREPLACE;
853 case 'p': /* use portable data format */
854 fo->flags |= FO_PORTABLE;
856 case 'R': /* Resource forks and Finder Info */
857 fo->flags |= FO_HFSPLUS;
858 case 'r': /* read fifo */
859 fo->flags |= FO_READFIFO;
862 fo->flags |= FO_SHA1;
865 fo->flags |= FO_SPARSE;
868 fo->flags |= FO_MTIMEONLY;
871 fo->flags |= FO_KEEPATIME;
876 case 'V': /* verify options */
877 /* Copy Verify Options */
878 for (j=0; *p && *p != ':'; p++) {
879 fo->VerifyOpts[j] = *p;
880 if (j < (int)sizeof(fo->VerifyOpts) - 1) {
884 fo->VerifyOpts[j] = 0;
887 fo->flags |= FO_IF_NEWER;
889 case 'Z': /* gzip compression */
890 fo->flags |= FO_GZIP;
891 fo->GZIP_level = *++p - '0';
892 Dmsg1(200, "Compression level=%d\n", fo->GZIP_level);
895 Emsg1(M_ERROR, 0, "Unknown include/exclude option: %c\n", *p);
903 * Director is passing his Fileset
905 static int fileset_cmd(JCR *jcr)
907 BSOCK *dir = jcr->dir_bsock;
909 if (!init_fileset(jcr)) {
912 while (bnet_recv(dir) >= 0) {
913 strip_trailing_junk(dir->msg);
914 Dmsg1(400, "Fileset: %s\n", dir->msg);
915 add_fileset(jcr, dir->msg);
917 if (!term_fileset(jcr)) {
920 return bnet_fsend(dir, OKinc);
924 static int bootstrap_cmd(JCR *jcr)
926 BSOCK *dir = jcr->dir_bsock;
927 POOLMEM *fname = get_pool_memory(PM_FNAME);
930 if (jcr->RestoreBootstrap) {
931 unlink(jcr->RestoreBootstrap);
932 free_pool_memory(jcr->RestoreBootstrap);
934 Mmsg(fname, "%s/%s.%s.bootstrap", me->working_directory, me->hdr.name,
936 Dmsg1(400, "bootstrap=%s\n", fname);
937 jcr->RestoreBootstrap = fname;
938 bs = fopen(fname, "a+"); /* create file */
942 * Suck up what he is sending to us so that he will then
943 * read our error message.
945 while (bnet_recv(dir) >= 0)
948 Jmsg(jcr, M_FATAL, 0, _("Could not create bootstrap file %s: ERR=%s\n"),
949 jcr->RestoreBootstrap, be.strerror());
950 free_pool_memory(jcr->RestoreBootstrap);
951 jcr->RestoreBootstrap = NULL;
952 set_jcr_job_status(jcr, JS_ErrorTerminated);
956 while (bnet_recv(dir) >= 0) {
957 Dmsg1(200, "filed<dird: bootstrap file %s\n", dir->msg);
962 return bnet_fsend(dir, OKbootstrap);
967 * Get backup level from Director
970 static int level_cmd(JCR *jcr)
972 BSOCK *dir = jcr->dir_bsock;
973 POOLMEM *level, *buf = NULL;
976 level = get_memory(dir->msglen+1);
977 Dmsg1(110, "level_cmd: %s", dir->msg);
978 if (sscanf(dir->msg, "level = %s ", level) != 1) {
981 /* Base backup requested? */
982 if (strcmp(level, "base") == 0) {
983 jcr->JobLevel = L_BASE;
984 /* Full backup requested? */
985 } else if (strcmp(level, "full") == 0) {
986 jcr->JobLevel = L_FULL;
987 } else if (strcmp(level, "differential") == 0) {
988 jcr->JobLevel = L_DIFFERENTIAL;
991 } else if (strcmp(level, "incremental") == 0) {
992 jcr->JobLevel = L_INCREMENTAL;
996 * We get his UTC since time, then sync the clocks and correct it
997 * to agree with our clock.
999 } else if (strcmp(level, "since_utime") == 0) {
1000 buf = get_memory(dir->msglen+1);
1001 utime_t since_time, adj;
1002 btime_t his_time, bt_start, rt=0, bt_adj=0;
1003 if (jcr->JobLevel == L_NONE) {
1004 jcr->JobLevel = L_SINCE; /* if no other job level set, do it now */
1006 if (sscanf(dir->msg, "level = since_utime %s mtime_only=%d",
1007 buf, &mtime_only) != 2) {
1010 since_time = str_to_uint64(buf); /* this is the since time */
1011 char ed1[50], ed2[50];
1013 * Sync clocks by polling him for the time. We take
1014 * 10 samples of his time throwing out the first two.
1016 for (int i=0; i<10; i++) {
1017 bt_start = get_current_btime();
1018 bnet_sig(dir, BNET_BTIME); /* poll for time */
1019 if (bnet_recv(dir) <= 0) { /* get response */
1022 if (sscanf(dir->msg, "btime %s", buf) != 1) {
1025 if (i < 2) { /* toss first two results */
1028 his_time = str_to_uint64(buf);
1029 rt = get_current_btime() - bt_start; /* compute round trip time */
1030 bt_adj -= his_time - bt_start - rt/2;
1031 Dmsg2(200, "rt=%s adj=%s\n", edit_uint64(rt, ed1), edit_uint64(bt_adj, ed2));
1034 bt_adj = bt_adj / 8; /* compute average time */
1035 Dmsg2(100, "rt=%s adj=%s\n", edit_uint64(rt, ed1), edit_uint64(bt_adj, ed2));
1036 adj = btime_to_utime(bt_adj);
1037 since_time += adj; /* adjust for clock difference */
1039 Jmsg(jcr, M_INFO, 0, _("DIR and FD clocks differ by %d seconds, FD automatically adjusting.\n"), adj);
1041 bnet_sig(dir, BNET_EOD);
1043 Dmsg2(100, "adj = %d since_time=%d\n", (int)adj, (int)since_time);
1044 jcr->incremental = 1; /* set incremental or decremental backup */
1045 jcr->mtime = (time_t)since_time; /* set since time */
1047 Jmsg1(jcr, M_FATAL, 0, "Unknown backup level: %s\n", level);
1055 return bnet_fsend(dir, OKlevel);
1058 pm_strcpy(jcr->errmsg, dir->msg);
1059 Jmsg1(jcr, M_FATAL, 0, _("Bad level command: %s\n"), jcr->errmsg);
1068 * Get session parameters from Director -- this is for a Restore command
1070 static int session_cmd(JCR *jcr)
1072 BSOCK *dir = jcr->dir_bsock;
1074 Dmsg1(100, "SessionCmd: %s", dir->msg);
1075 if (sscanf(dir->msg, sessioncmd, jcr->VolumeName,
1076 &jcr->VolSessionId, &jcr->VolSessionTime,
1077 &jcr->StartFile, &jcr->EndFile,
1078 &jcr->StartBlock, &jcr->EndBlock) != 7) {
1079 pm_strcpy(jcr->errmsg, dir->msg);
1080 Jmsg(jcr, M_FATAL, 0, "Bad session command: %s", jcr->errmsg);
1084 return bnet_fsend(dir, OKsession);
1088 * Get address of storage daemon from Director
1091 static int storage_cmd(JCR *jcr)
1093 int stored_port; /* storage daemon port */
1094 int enable_ssl; /* enable ssl to sd */
1095 BSOCK *dir = jcr->dir_bsock;
1096 BSOCK *sd; /* storage daemon bsock */
1098 Dmsg1(100, "StorageCmd: %s", dir->msg);
1099 if (sscanf(dir->msg, storaddr, &jcr->stored_addr, &stored_port, &enable_ssl) != 3) {
1100 pm_strcpy(jcr->errmsg, dir->msg);
1101 Jmsg(jcr, M_FATAL, 0, _("Bad storage command: %s"), jcr->errmsg);
1104 Dmsg3(110, "Open storage: %s:%d ssl=%d\n", jcr->stored_addr, stored_port, enable_ssl);
1105 /* Open command communications with Storage daemon */
1106 /* Try to connect for 1 hour at 10 second intervals */
1107 sd = bnet_connect(jcr, 10, (int)me->SDConnectTimeout, _("Storage daemon"),
1108 jcr->stored_addr, NULL, stored_port, 1);
1110 Jmsg(jcr, M_FATAL, 0, _("Failed to connect to Storage daemon: %s:%d\n"),
1111 jcr->stored_addr, stored_port);
1112 Dmsg2(100, "Failed to connect to Storage daemon: %s:%d\n",
1113 jcr->stored_addr, stored_port);
1116 Dmsg0(110, "Connection OK to SD.\n");
1118 jcr->store_bsock = sd;
1120 bnet_fsend(sd, "Hello Start Job %s\n", jcr->Job);
1121 if (!authenticate_storagedaemon(jcr)) {
1122 Jmsg(jcr, M_FATAL, 0, _("Failed to authenticate Storage daemon.\n"));
1125 Dmsg0(110, "Authenticated with SD.\n");
1127 /* Send OK to Director */
1128 return bnet_fsend(dir, OKstore);
1133 * Do a backup. For now, we handle only Full and Incremental.
1135 static int backup_cmd(JCR *jcr)
1137 BSOCK *dir = jcr->dir_bsock;
1138 BSOCK *sd = jcr->store_bsock;
1141 char ed1[50], ed2[50];
1143 set_jcr_job_status(jcr, JS_Blocked);
1144 jcr->JobType = JT_BACKUP;
1145 Dmsg1(100, "begin backup ff=%p\n", (FF_PKT *)jcr->ff);
1148 Jmsg(jcr, M_FATAL, 0, _("Cannot contact Storage daemon\n"));
1152 bnet_fsend(dir, OKbackup);
1153 Dmsg1(110, "bfiled>dird: %s", dir->msg);
1156 * Send Append Open Session to Storage daemon
1158 bnet_fsend(sd, append_open);
1159 Dmsg1(110, ">stored: %s", sd->msg);
1161 * Expect to receive back the Ticket number
1163 if (bget_msg(sd) >= 0) {
1164 Dmsg1(110, "<stored: %s", sd->msg);
1165 if (sscanf(sd->msg, OK_open, &jcr->Ticket) != 1) {
1166 Jmsg(jcr, M_FATAL, 0, _("Bad response to append open: %s\n"), sd->msg);
1169 Dmsg1(110, "Got Ticket=%d\n", jcr->Ticket);
1171 Jmsg(jcr, M_FATAL, 0, _("Bad response from stored to open command\n"));
1176 * Send Append data command to Storage daemon
1178 bnet_fsend(sd, append_data, jcr->Ticket);
1179 Dmsg1(110, ">stored: %s", sd->msg);
1182 * Expect to get OK data
1184 Dmsg1(110, "<stored: %s", sd->msg);
1185 if (!response(jcr, sd, OK_data, "Append Data")) {
1190 * Send Files to Storage daemon
1192 Dmsg1(110, "begin blast ff=%p\n", (FF_PKT *)jcr->ff);
1193 if (!blast_data_to_storage_daemon(jcr, NULL)) {
1194 set_jcr_job_status(jcr, JS_ErrorTerminated);
1195 bnet_suppress_error_messages(sd, 1);
1196 Dmsg0(110, "Error in blast_data.\n");
1198 set_jcr_job_status(jcr, JS_Terminated);
1199 if (jcr->JobStatus != JS_Terminated) {
1200 bnet_suppress_error_messages(sd, 1);
1201 goto cleanup; /* bail out now */
1204 * Expect to get response to append_data from Storage daemon
1206 if (!response(jcr, sd, OK_append, "Append Data")) {
1207 set_jcr_job_status(jcr, JS_ErrorTerminated);
1212 * Send Append End Data to Storage daemon
1214 bnet_fsend(sd, append_end, jcr->Ticket);
1216 if (!response(jcr, sd, OK_end, "Append End")) {
1217 set_jcr_job_status(jcr, JS_ErrorTerminated);
1222 * Send Append Close to Storage daemon
1224 bnet_fsend(sd, append_close, jcr->Ticket);
1225 while (bget_msg(sd) >= 0) { /* stop on signal or error */
1226 if (sscanf(sd->msg, OK_close, &SDJobStatus) == 1) {
1228 Dmsg2(200, "SDJobStatus = %d %c\n", SDJobStatus, (char)SDJobStatus);
1232 Jmsg(jcr, M_FATAL, 0, _("Append Close with SD failed.\n"));
1235 if (SDJobStatus != JS_Terminated) {
1236 Jmsg(jcr, M_FATAL, 0, _("Bad status %d returned from Storage Daemon.\n"),
1242 bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles,
1243 edit_uint64(jcr->ReadBytes, ed1),
1244 edit_uint64(jcr->JobBytes, ed2), jcr->Errors);
1245 Dmsg1(110, "End FD msg: %s\n", dir->msg);
1247 return 0; /* return and stop command loop */
1251 * Do a Verify for Director
1254 static int verify_cmd(JCR *jcr)
1256 BSOCK *dir = jcr->dir_bsock;
1257 BSOCK *sd = jcr->store_bsock;
1258 char level[100], ed1[50], ed2[50];
1260 jcr->JobType = JT_VERIFY;
1261 if (sscanf(dir->msg, verifycmd, level) != 1) {
1262 bnet_fsend(dir, "2994 Bad verify command: %s\n", dir->msg);
1265 if (strcasecmp(level, "init") == 0) {
1266 jcr->JobLevel = L_VERIFY_INIT;
1267 } else if (strcasecmp(level, "catalog") == 0){
1268 jcr->JobLevel = L_VERIFY_CATALOG;
1269 } else if (strcasecmp(level, "volume") == 0){
1270 jcr->JobLevel = L_VERIFY_VOLUME_TO_CATALOG;
1271 } else if (strcasecmp(level, "data") == 0){
1272 jcr->JobLevel = L_VERIFY_DATA;
1273 } else if (strcasecmp(level, "disk_to_catalog") == 0) {
1274 jcr->JobLevel = L_VERIFY_DISK_TO_CATALOG;
1276 bnet_fsend(dir, "2994 Bad verify level: %s\n", dir->msg);
1280 bnet_fsend(dir, OKverify);
1281 Dmsg1(110, "bfiled>dird: %s", dir->msg);
1283 switch (jcr->JobLevel) {
1285 case L_VERIFY_CATALOG:
1288 case L_VERIFY_VOLUME_TO_CATALOG:
1289 if (!open_sd_read_session(jcr)) {
1292 start_dir_heartbeat(jcr);
1293 do_verify_volume(jcr);
1294 stop_dir_heartbeat(jcr);
1296 * Send Close session command to Storage daemon
1298 bnet_fsend(sd, read_close, jcr->Ticket);
1299 Dmsg1(130, "bfiled>stored: %s", sd->msg);
1301 /* ****FIXME**** check response */
1302 bget_msg(sd); /* get OK */
1304 /* Inform Storage daemon that we are done */
1305 bnet_sig(sd, BNET_TERMINATE);
1308 case L_VERIFY_DISK_TO_CATALOG:
1312 bnet_fsend(dir, "2994 Bad verify level: %s\n", dir->msg);
1316 bnet_sig(dir, BNET_EOD);
1318 /* Send termination status back to Dir */
1319 bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles,
1320 edit_uint64(jcr->ReadBytes, ed1),
1321 edit_uint64(jcr->JobBytes, ed2), jcr->Errors);
1323 /* Inform Director that we are done */
1324 bnet_sig(dir, BNET_TERMINATE);
1325 return 0; /* return and terminate command loop */
1329 * Do a Restore for Director
1332 static int restore_cmd(JCR *jcr)
1334 BSOCK *dir = jcr->dir_bsock;
1335 BSOCK *sd = jcr->store_bsock;
1339 char ed1[50], ed2[50];
1342 * Scan WHERE (base directory for restore) from command
1344 Dmsg0(150, "restore command\n");
1345 /* Pickup where string */
1346 where = get_memory(dir->msglen+1);
1349 if (sscanf(dir->msg, restorecmd, &replace, &prefix_links, where) != 3) {
1350 if (sscanf(dir->msg, restorecmd1, &replace, &prefix_links) != 2) {
1351 pm_strcpy(jcr->errmsg, dir->msg);
1352 Jmsg(jcr, M_FATAL, 0, _("Bad replace command. CMD=%s\n"), jcr->errmsg);
1357 /* Turn / into nothing */
1358 if (where[0] == '/' && where[1] == 0) {
1362 Dmsg2(150, "Got replace %c, where=%s\n", replace, where);
1363 unbash_spaces(where);
1364 jcr->where = bstrdup(where);
1365 free_pool_memory(where);
1366 jcr->replace = replace;
1367 jcr->prefix_links = prefix_links;
1369 bnet_fsend(dir, OKrestore);
1370 Dmsg1(110, "bfiled>dird: %s", dir->msg);
1372 jcr->JobType = JT_RESTORE;
1374 set_jcr_job_status(jcr, JS_Blocked);
1375 if (!open_sd_read_session(jcr)) {
1376 set_jcr_job_status(jcr, JS_ErrorTerminated);
1380 set_jcr_job_status(jcr, JS_Running);
1383 * Do restore of files and data
1385 start_dir_heartbeat(jcr);
1387 stop_dir_heartbeat(jcr);
1389 set_jcr_job_status(jcr, JS_Terminated);
1390 if (jcr->JobStatus != JS_Terminated) {
1391 bnet_suppress_error_messages(sd, 1);
1395 * Send Close session command to Storage daemon
1397 bnet_fsend(sd, read_close, jcr->Ticket);
1398 Dmsg1(130, "bfiled>stored: %s", sd->msg);
1400 bget_msg(sd); /* get OK */
1402 /* Inform Storage daemon that we are done */
1403 bnet_sig(sd, BNET_TERMINATE);
1408 set_jcr_job_status(jcr, JS_ErrorTerminated);
1410 /* Send termination status back to Dir */
1411 bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles,
1412 edit_uint64(jcr->ReadBytes, ed1),
1413 edit_uint64(jcr->JobBytes, ed2), jcr->Errors);
1415 /* Inform Director that we are done */
1416 bnet_sig(dir, BNET_TERMINATE);
1418 Dmsg0(130, "Done in job.c\n");
1419 return 0; /* return and terminate command loop */
1422 static int open_sd_read_session(JCR *jcr)
1424 BSOCK *sd = jcr->store_bsock;
1427 Jmsg(jcr, M_FATAL, 0, _("Improper calling sequence.\n"));
1430 Dmsg4(120, "VolSessId=%ld VolsessT=%ld SF=%ld EF=%ld\n",
1431 jcr->VolSessionId, jcr->VolSessionTime, jcr->StartFile, jcr->EndFile);
1432 Dmsg2(120, "JobId=%d vol=%s\n", jcr->JobId, "DummyVolume");
1434 * Open Read Session with Storage daemon
1436 bnet_fsend(sd, read_open, jcr->VolumeName,
1437 jcr->VolSessionId, jcr->VolSessionTime, jcr->StartFile, jcr->EndFile,
1438 jcr->StartBlock, jcr->EndBlock);
1439 Dmsg1(110, ">stored: %s", sd->msg);
1444 if (bget_msg(sd) >= 0) {
1445 Dmsg1(110, "bfiled<stored: %s", sd->msg);
1446 if (sscanf(sd->msg, OK_open, &jcr->Ticket) != 1) {
1447 Jmsg(jcr, M_FATAL, 0, _("Bad response to SD read open: %s\n"), sd->msg);
1450 Dmsg1(110, "bfiled: got Ticket=%d\n", jcr->Ticket);
1452 Jmsg(jcr, M_FATAL, 0, _("Bad response from stored to read open command\n"));
1456 if (!send_bootstrap_file(jcr)) {
1461 * Start read of data with Storage daemon
1463 bnet_fsend(sd, read_data, jcr->Ticket);
1464 Dmsg1(110, ">stored: %s", sd->msg);
1469 if (!response(jcr, sd, OK_data, "Read Data")) {
1476 * Destroy the Job Control Record and associated
1477 * resources (sockets).
1479 static void filed_free_jcr(JCR *jcr)
1481 if (jcr->store_bsock) {
1482 bnet_close(jcr->store_bsock);
1484 if (jcr->RestoreBootstrap) {
1485 unlink(jcr->RestoreBootstrap);
1486 free_pool_memory(jcr->RestoreBootstrap);
1487 jcr->RestoreBootstrap = NULL;
1489 if (jcr->last_fname) {
1490 free_pool_memory(jcr->last_fname);
1492 if (jcr->RunAfterJob) {
1493 free_pool_memory(jcr->RunAfterJob);
1501 * Get response from Storage daemon to a command we
1502 * sent. Check that the response is OK.
1504 * Returns: 0 on failure
1507 int response(JCR *jcr, BSOCK *sd, char *resp, const char *cmd)
1512 if (bget_msg(sd) > 0) {
1513 Dmsg0(110, sd->msg);
1514 if (strcmp(sd->msg, resp) == 0) {
1518 if (job_canceled(jcr)) {
1519 return 0; /* if canceled avoid useless error messages */
1521 if (is_bnet_error(sd)) {
1522 Jmsg2(jcr, M_FATAL, 0, _("Comm error with SD. bad response to %s. ERR=%s\n"),
1523 cmd, bnet_strerror(sd));
1525 Jmsg3(jcr, M_FATAL, 0, _("Bad response to %s command. Wanted %s, got %s\n"),
1526 cmd, resp, sd->msg);
1531 static int send_bootstrap_file(JCR *jcr)
1535 BSOCK *sd = jcr->store_bsock;
1536 const char *bootstrap = "bootstrap\n";
1539 Dmsg1(400, "send_bootstrap_file: %s\n", jcr->RestoreBootstrap);
1540 if (!jcr->RestoreBootstrap) {
1543 bs = fopen(jcr->RestoreBootstrap, "r");
1546 Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"),
1547 jcr->RestoreBootstrap, be.strerror());
1548 set_jcr_job_status(jcr, JS_ErrorTerminated);
1551 sd->msglen = pm_strcpy(sd->msg, bootstrap);
1553 while (fgets(buf, sizeof(buf), bs)) {
1554 sd->msglen = Mmsg(sd->msg, "%s", buf);
1557 bnet_sig(sd, BNET_EOD);
1559 if (!response(jcr, sd, OKSDbootstrap, "Bootstrap")) {
1560 set_jcr_job_status(jcr, JS_ErrorTerminated);
1566 if (jcr->RestoreBootstrap) {
1567 unlink(jcr->RestoreBootstrap);
1568 free_pool_memory(jcr->RestoreBootstrap);
1569 jcr->RestoreBootstrap = NULL;