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-2003 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 /* Forward referenced functions */
39 static void admin_cleanup(JCR *jcr, int TermCode);
41 /* External functions */
44 * Returns: 0 on failure
47 int do_admin(JCR *jcr)
50 jcr->jr.JobId = jcr->JobId;
51 jcr->jr.StartTime = jcr->start_time;
52 if (!db_update_job_start_record(jcr, jcr->db, &jcr->jr)) {
53 Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
57 jcr->fname = (char *)get_pool_memory(PM_FNAME);
59 /* Print Job Start message */
60 Jmsg(jcr, M_INFO, 0, _("Start Admin JobId %d, Job=%s\n"),
61 jcr->JobId, jcr->Job);
63 set_jcr_job_status(jcr, JS_Running);
64 admin_cleanup(jcr, JS_Terminated);
68 admin_cleanup(jcr, JS_ErrorTerminated);
73 * Release resources allocated during backup.
75 static void admin_cleanup(JCR *jcr, int TermCode)
77 char sdt[50], edt[50];
84 Dmsg0(100, "Enter backup_cleanup()\n");
85 memset(&mr, 0, sizeof(mr));
86 set_jcr_job_status(jcr, TermCode);
88 update_job_end_record(jcr); /* update database */
90 if (!db_get_job_record(jcr, jcr->db, &jcr->jr)) {
91 Jmsg(jcr, M_WARNING, 0, _("Error getting job record for stats: %s"),
92 db_strerror(jcr->db));
93 set_jcr_job_status(jcr, JS_ErrorTerminated);
96 msg_type = M_INFO; /* by default INFO message */
97 switch (jcr->JobStatus) {
99 term_msg = _("Admin OK");
102 case JS_ErrorTerminated:
103 term_msg = _("*** Admin Error ***");
104 msg_type = M_ERROR; /* Generate error message */
107 term_msg = _("Admin Canceled");
110 term_msg = term_code;
111 sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus);
114 bstrftime(sdt, sizeof(sdt), jcr->jr.StartTime);
115 bstrftime(edt, sizeof(edt), jcr->jr.EndTime);
116 RunTime = jcr->jr.EndTime - jcr->jr.StartTime;
118 Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n\
123 Termination: %s\n\n"),
131 Dmsg0(100, "Leave admin_cleanup()\n");