On 2022-02-25 16:05, Marcelo Slon wrote:
Hi,

I have configured a copy job with the Selection Type = PoolUncopiedJobs
directive.
Is there a way to list the jobs that have not yet been copied before
running this job in the console or by SQL query? Where is this information
stored in the database?

Hi Marcelo,

There is no place in the database that holds that specific information.
Instead, there is a complex SQL query that returns the list of job ids
upon query execution.

For Bacula version 9.6.7 source it can be found in the file src/dird/mac.c
or src/dird/mac_sql.c, I don't remember which one.

The query looks like this (I added few columns in the output
but Bacula requires only the first one to be the jobid column):

SELECT DISTINCT Job.JobId,Job.StartTime,Job.Name,Job.job,Job.JobBytes,Job.JobStatus,Job.Level
 FROM Job,Pool
 WHERE Pool.Name = '%1'
 AND Pool.PoolId = Job.PoolId
 AND Job.Type = 'B'
 AND Job.JobStatus IN ('T','W')
 AND Job.jobBytes > 0
 AND Job.JobId NOT IN
  (SELECT PriorJobId
   FROM Job
   WHERE Type IN ('B','C')
   AND Job.JobStatus IN ('T','W')
   AND PriorJobId != 0)
   ORDER by Job.StartTime;

Note that %1 in the query above must be replaced with the name
of your pool.


To make this knowledge more useful, you could add that
query to your /etc/bacula/query.sql file which would allow
you to use bconsole query command.
You still need to modify it a bit to make bconsole query
command ask you for the name of the pool.

The complete query definition modified for use in query.sql
file would look like this (the number 21 means that this is
the 21st query definition in my /etc/bacula/query.sql file):

# 21
: List the successfully completed backup jobs which have not been copied before
*Enter Pool name:
SELECT DISTINCT Job.JobId,Job.StartTime,Job.Name,Job.job,Job.JobBytes,Job.JobStatus,Job.Level
 FROM Job,Pool
 WHERE Pool.Name = '%1'
 AND Pool.PoolId = Job.PoolId
 AND Job.Type = 'B'
 AND Job.JobStatus IN ('T','W')
 AND Job.jobBytes > 0
 AND Job.JobId NOT IN
  (SELECT PriorJobId
   FROM Job
   WHERE Type IN ('B','C')
   AND Job.JobStatus IN ('T','W')
   AND PriorJobId != 0)
   ORDER by Job.StartTime;


Regards!

--
Josip Deanovic


_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to