]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/dird/admin.c
Kludge joblist to include all jobs
[bacula/bacula] / bacula / src / dird / admin.c
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2003-2007 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from
7    many others, a complete list can be found in the file AUTHORS.
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version two of the GNU General Public
10    License as published by the Free Software Foundation plus additions
11    that are listed in the file LICENSE.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23    Bacula® is a registered trademark of John Walker.
24    The licensor of Bacula is the Free Software Foundation Europe
25    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26    Switzerland, email:ftf@fsfeurope.org.
27 */
28 /*
29  *
30  *   Bacula Director -- admin.c -- responsible for doing admin jobs
31  *
32  *     Kern Sibbald, May MMIII
33  *
34  *  Basic tasks done here:
35  *     Display the job report.
36  *
37  *   Version $Id$
38  */
39
40 #include "bacula.h"
41 #include "dird.h"
42 #include "ua.h"
43
44
45 bool do_admin_init(JCR *jcr)
46 {
47    free_rstorage(jcr);
48    return true;
49 }
50
51 /*
52  *  Returns:  false on failure
53  *            true  on success
54  */
55 bool do_admin(JCR *jcr)
56 {
57
58    jcr->jr.JobId = jcr->JobId;
59
60    jcr->fname = (char *)get_pool_memory(PM_FNAME);
61
62    /* Print Job Start message */
63    Jmsg(jcr, M_INFO, 0, _("Start Admin JobId %d, Job=%s\n"),
64         jcr->JobId, jcr->Job);
65
66    set_jcr_job_status(jcr, JS_Running);
67    admin_cleanup(jcr, JS_Terminated);
68    return true;
69 }
70
71
72 /*
73  * Release resources allocated during backup.
74  */
75 void admin_cleanup(JCR *jcr, int TermCode)
76 {
77    char sdt[50], edt[50];
78    char term_code[100];
79    const char *term_msg;
80    int msg_type;
81    MEDIA_DBR mr;
82
83    Dmsg0(100, "Enter backup_cleanup()\n");
84    memset(&mr, 0, sizeof(mr));
85
86    update_job_end(jcr, TermCode);
87
88    if (!db_get_job_record(jcr, jcr->db, &jcr->jr)) {
89       Jmsg(jcr, M_WARNING, 0, _("Error getting Job record for Job report: ERR=%s"),
90          db_strerror(jcr->db));
91       set_jcr_job_status(jcr, JS_ErrorTerminated);
92    }
93
94    msg_type = M_INFO;                 /* by default INFO message */
95    switch (jcr->JobStatus) {
96    case JS_Terminated:
97       term_msg = _("Admin OK");
98       break;
99    case JS_FatalError:
100    case JS_ErrorTerminated:
101       term_msg = _("*** Admin Error ***");
102       msg_type = M_ERROR;          /* Generate error message */
103       break;
104    case JS_Canceled:
105       term_msg = _("Admin Canceled");
106       break;
107    default:
108       term_msg = term_code;
109       sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus);
110       break;
111    }
112    bstrftime(sdt, sizeof(sdt), jcr->jr.StartTime);
113    bstrftime(edt, sizeof(edt), jcr->jr.EndTime);
114
115    Jmsg(jcr, msg_type, 0, _("Bacula " VERSION " (" LSMDATE "): %s\n"
116 "  JobId:                  %d\n"
117 "  Job:                    %s\n"
118 "  Start time:             %s\n"
119 "  End time:               %s\n"
120 "  Termination:            %s\n\n"),
121         edt,
122         jcr->jr.JobId,
123         jcr->jr.Job,
124         sdt,
125         edt,
126         term_msg);
127
128    Dmsg0(100, "Leave admin_cleanup()\n");
129 }