X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fdird%2Fua_output.c;h=d7e93d0795062f8a5e2e5ac08d188140f41b9abe;hb=786be614c53783a10956e6ea4c9ef1f643edf07a;hp=c93ad9d2d42f36ba11d09859e1283a51fc10b42c;hpb=0497e45003fb2676d3421d878634fe3dd2b833bf;p=bacula%2Fbacula diff --git a/bacula/src/dird/ua_output.c b/bacula/src/dird/ua_output.c index c93ad9d2d4..d7e93d0795 100644 --- a/bacula/src/dird/ua_output.c +++ b/bacula/src/dird/ua_output.c @@ -1,12 +1,12 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2009 Free Software Foundation Europe e.V. + Copyright (C) 2000-2012 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. This program is Free Software; you can redistribute it and/or - modify it under the terms of version two of the GNU General Public + modify it under the terms of version three of the GNU Affero General Public License as published by the Free Software Foundation and included in the file LICENSE. @@ -15,7 +15,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Affero General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -280,7 +280,6 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist) memset(&jr, 0, sizeof(jr)); memset(&pr, 0, sizeof(pr)); - memset(&mr, 0, sizeof(mr)); Dmsg1(20, "list: %s\n", cmd); @@ -288,15 +287,16 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist) ua->error_msg(_("Hey! DB is NULL\n")); } + /* Apply any limit */ + j = find_arg_with_value(ua, NT_("limit")); + if (j >= 0) { + jr.limit = atoi(ua->argv[j]); + } + /* Scan arguments looking for things to do */ for (i=1; iargc; i++) { /* List JOBS */ if (strcasecmp(ua->argk[i], NT_("jobs")) == 0) { - /* Apply any limit */ - j = find_arg_with_value(ua, NT_("limit")); - if (j >= 0) { - jr.limit = atoi(ua->argv[j]); - } db_list_job_records(ua->jcr, ua->db, &jr, prtit, ua, llist); /* List JOBTOTALS */ @@ -326,6 +326,25 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist) jr.JobId = 0; db_list_job_records(ua->jcr, ua->db, &jr, prtit, ua, llist); + /* List Base files */ + } else if (strcasecmp(ua->argk[i], NT_("basefiles")) == 0) { + /* TODO: cleanup this block */ + for (j=i+1; jargc; j++) { + if (strcasecmp(ua->argk[j], NT_("ujobid")) == 0 && ua->argv[j]) { + bstrncpy(jr.Job, ua->argv[j], MAX_NAME_LENGTH); + jr.JobId = 0; + db_get_job_record(ua->jcr, ua->db, &jr); + jobid = jr.JobId; + } else if (strcasecmp(ua->argk[j], NT_("jobid")) == 0 && ua->argv[j]) { + jobid = str_to_int64(ua->argv[j]); + } else { + continue; + } + if (jobid > 0) { + db_list_base_files_for_job(ua->jcr, ua->db, jobid, prtit, ua); + } + } + /* List FILES */ } else if (strcasecmp(ua->argk[i], NT_("files")) == 0) { @@ -483,7 +502,7 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist) } list_nextvol(ua, n); } else if (strcasecmp(ua->argk[i], NT_("copies")) == 0) { - char *jobids=NULL; + char *jobids = NULL; uint32_t limit=0; for (j=i+1; jargc; j++) { if (strcasecmp(ua->argk[j], NT_("jobid")) == 0 && ua->argv[j]) { @@ -516,7 +535,6 @@ static bool list_nextvol(UAContext *ua, int ndays) MEDIA_DBR mr; POOL_DBR pr; - memset(&mr, 0, sizeof(mr)); int i = find_arg_with_value(ua, "job"); if (i <= 0) { if ((job = select_job_resource(ua)) == NULL) { @@ -549,7 +567,7 @@ static bool list_nextvol(UAContext *ua, int ndays) } mr.PoolId = jcr->jr.PoolId; get_job_storage(&store, job, run); - mr.StorageId = store.store->StorageId; + set_storageid_in_mr(store.store, &mr); /* no need to set ScratchPoolId, since we use fnv_no_create_vol */ if (!find_next_volume_for_append(jcr, &mr, 1, fnv_no_create_vol, fnv_prune)) { ua->error_msg(_("Could not find next Volume for Job %s (Pool=%s, Level=%s).\n"), @@ -563,8 +581,10 @@ static bool list_nextvol(UAContext *ua, int ndays) } get_out: - db_close_database(jcr, jcr->db); - jcr->db = NULL; + if (jcr->db) { + db_close_database(jcr, jcr->db); + jcr->db = NULL; + } free_jcr(jcr); if (!found) { ua->error_msg(_("Could not find next Volume for Job %s.\n"), @@ -687,11 +707,12 @@ bool complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool) } Dmsg0(100, "complete_jcr open db\n"); - jcr->db = jcr->db=db_init(jcr, jcr->catalog->db_driver, jcr->catalog->db_name, - jcr->catalog->db_user, - jcr->catalog->db_password, jcr->catalog->db_address, - jcr->catalog->db_port, jcr->catalog->db_socket, - jcr->catalog->mult_db_connections); + jcr->db = db_init_database(jcr, jcr->catalog->db_driver, jcr->catalog->db_name, + jcr->catalog->db_user, + jcr->catalog->db_password, jcr->catalog->db_address, + jcr->catalog->db_port, jcr->catalog->db_socket, + jcr->catalog->mult_db_connections, + jcr->catalog->disable_batch_insert); if (!jcr->db || !db_open_database(jcr, jcr->db)) { Jmsg(jcr, M_FATAL, 0, _("Could not open database \"%s\".\n"), jcr->catalog->db_name);