On 2022-02-26 00:09, Bill Arlofski via Bacula-users wrote:
Thanks Josip!

I will go look for that post. Sounds like a useful SQL query for
implementing Copy jobs when a history of other jobs already
exists in a pool you'd like to copy from.

I found it in my configurations. I think this is it.
Sorry for bad SQL indentation.

SELECT DISTINCT JobId,StartTime,Type,Level,Name,PriorJobId
 FROM Job
 WHERE Name = 'YOUR_JOB_NAME'
 AND JobBytes > 0
 AND ((Level='F' AND JobStatus IN ('T', 'W') AND StartTime >=
  (SELECT DISTINCT StartTime
   FROM Job
   WHERE Name = 'YOUR_JOB_NAME'
   AND Level='F'
   AND JobStatus IN ('T', 'W')
   ORDER BY StartTime DESC LIMIT 1))
  OR (Level='D'
      AND JobStatus IN ('T', 'W')
      AND StartTime >=
        (SELECT DISTINCT StartTime
         FROM Job
         WHERE Name = 'YOUR_JOB_NAME'
         AND Level='F'
         AND JobStatus IN ('T', 'W')
         ORDER BY StartTime DESC LIMIT 1))
        OR (Level='I'
            AND JobStatus IN ('T', 'W')
            AND StartTime >=
              (SELECT DISTINCT StartTime
               FROM Job
               WHERE Name = 'YOUR_JOB_NAME'
               AND Level='D'
               AND JobStatus IN ('T', 'W')
               ORDER BY StartTime DESC LIMIT 1)
            OR StartTime >=
            (SELECT DISTINCT StartTime
              FROM Job
              WHERE Name = 'YOUR_JOB_NAME'
              AND Level='F'
              AND JobStatus IN ('T', 'W')
              ORDER BY StartTime DESC LIMIT 1)))
        AND NOT JobId = ANY
          (select PriorJobId
           FROM Job
           WHERE Name = 'YOUR_JOB_NAME'
           AND PriorJobId <> 0)
        AND Type<>'C'
        ORDER BY JobId;


Note that in the above query there are six places where
YOUR_JOB_NAME should be replaced with the actual job name.

This used to work on Bacula 7.4. Didn't test it on newer
Bacula versions.


Regards!

--
Josip Deanovic


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

Reply via email to