/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2009 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.
}
+void db_list_copies_records(JCR *jcr, B_DB *mdb, uint32_t limit, char *JobIds,
+ DB_LIST_HANDLER *sendit, void *ctx, e_list_type type)
+{
+ POOL_MEM str_limit(PM_MESSAGE);
+ POOL_MEM str_jobids(PM_MESSAGE);
+
+ if (limit > 0) {
+ Mmsg(str_limit, " LIMIT %d", limit);
+ }
+
+ if (JobIds && JobIds[0]) {
+ Mmsg(str_jobids, " AND (Job.PriorJobId IN (%s) OR Job.JobId IN (%s)) ",
+ JobIds, JobIds);
+ }
+
+ db_lock(mdb);
+ Mmsg(mdb->cmd,
+ "SELECT DISTINCT Job.PriorJobId AS JobId, Job.Job, "
+ "Job.JobId AS CopyJobId, Media.MediaType "
+ "FROM Job "
+ "JOIN JobMedia USING (JobId) "
+ "JOIN Media USING (MediaId) "
+ "WHERE Job.Type = '%c' %s ORDER BY Job.PriorJobId DESC %s",
+ (char) JT_JOB_COPY, str_jobids.c_str(), str_limit.c_str());
+
+ if (!QUERY_DB(jcr, mdb, mdb->cmd)) {
+ goto bail_out;
+ }
+
+ if (mdb->result && sql_num_rows(mdb)) {
+ if (JobIds && JobIds[0]) {
+ sendit(ctx, _("These JobIds have copies as follows:\n"));
+ } else {
+ sendit(ctx, _("The catalog contains copies as follows:\n"));
+ }
+
+ list_result(jcr, mdb, sendit, ctx, type);
+ }
+
+ sql_free_result(mdb);
+
+bail_out:
+ db_unlock(mdb);
+}
+
void db_list_joblog_records(JCR *jcr, B_DB *mdb, uint32_t JobId,
DB_LIST_HANDLER *sendit, void *ctx, e_list_type type)
{