3 * Bacula Director -- admin.c -- responsible for doing admin jobs
5 * Kern Sibbald, May MMIII
7 * Basic tasks done here:
8 * Display the job report.
14 Copyright (C) 2000-2004 Kern Sibbald and John Walker
16 This program is free software; you can redistribute it and/or
17 modify it under the terms of the GNU General Public License as
18 published by the Free Software Foundation; either version 2 of
19 the License, or (at your option) any later version.
21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 General Public License for more details.
26 You should have received a copy of the GNU General Public
27 License along with this program; if not, write to the Free
28 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
38 bool do_admin_init(JCR *jcr)
44 * Returns: false on failure
47 bool do_admin(JCR *jcr)
50 jcr->jr.JobId = jcr->JobId;
52 jcr->fname = (char *)get_pool_memory(PM_FNAME);
54 /* Print Job Start message */
55 Jmsg(jcr, M_INFO, 0, _("Start Admin JobId %d, Job=%s\n"),
56 jcr->JobId, jcr->Job);
58 set_jcr_job_status(jcr, JS_Running);
59 admin_cleanup(jcr, JS_Terminated);
65 * Release resources allocated during backup.
67 void admin_cleanup(JCR *jcr, int TermCode)
69 char sdt[50], edt[50];
75 Dmsg0(100, "Enter backup_cleanup()\n");
76 memset(&mr, 0, sizeof(mr));
77 set_jcr_job_status(jcr, TermCode);
79 update_job_end_record(jcr); /* update database */
81 if (!db_get_job_record(jcr, jcr->db, &jcr->jr)) {
82 Jmsg(jcr, M_WARNING, 0, _("Error getting job record for stats: %s"),
83 db_strerror(jcr->db));
84 set_jcr_job_status(jcr, JS_ErrorTerminated);
87 msg_type = M_INFO; /* by default INFO message */
88 switch (jcr->JobStatus) {
90 term_msg = _("Admin OK");
93 case JS_ErrorTerminated:
94 term_msg = _("*** Admin Error ***");
95 msg_type = M_ERROR; /* Generate error message */
98 term_msg = _("Admin Canceled");
101 term_msg = term_code;
102 sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus);
105 bstrftime(sdt, sizeof(sdt), jcr->jr.StartTime);
106 bstrftime(edt, sizeof(edt), jcr->jr.EndTime);
108 Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n"
113 " Termination: %s\n\n"),
121 Dmsg0(100, "Leave admin_cleanup()\n");