Verified Commit 39f1e5c1 authored by anarcat's avatar anarcat
Browse files

improve bacula job timeing queries

give an example of a job for *all* fulls, and also include a
human-readable size.
parent 34eb1ce5
Loading
Loading
Loading
Loading
+24 −2
Original line number Diff line number Diff line
@@ -559,14 +559,25 @@ the job you are interested in:

But then you still have to compute all those duration times
(end-start) in your head, that's annoying. To workaround that problem,
you can talk directly with the PostgreSQL database:
you can talk directly with the PostgreSQL database. The magic query
is:

    SELECT level, jobstatus, starttime, endtime,
           (CASE WHEN endtime IS NULL THEN NOW()
           ELSE endtime END)-starttime AS duration,
           jobfiles, pg_size_pretty(jobbytes)
           FROM job
           WHERE name='colchicifolium.torproject.org'
           ORDER by starttime;

Here's an example:

    root@bacula-director-01:~# sudo -u postgres psql bacula
    could not change directory to "/root": Permission denied
    psql (11.14 (Debian 11.14-0+deb10u1))
    Type "help" for help.

    bacula=# SELECT level, jobstatus, starttime, endtime, (CASE WHEN endtime IS NULL THEN NOW() ELSE endtime END)-starttime AS duration, jobfiles, jobbytes FROM job WHERE name='colchicifolium.torproject.org' ORDER by starttime;
    bacula=# SELECT level, jobstatus, starttime, endtime, (CASE WHEN endtime IS NULL THEN NOW() ELSE endtime END)-starttime AS duration, jobfiles, pg_size_pretty(jobbytes) FROM job WHERE name='colchicifolium.torproject.org' ORDER by starttime;
    level | jobstatus |      starttime      |       endtime       |       duration        | jobfiles |   jobbytes   
    -------+-----------+---------------------+---------------------+-----------------------+----------+--------------
     I     | f         | 2015-12-03 09:57:02 | 2015-12-03 09:57:02 | 00:00:00              |        0 |            0
@@ -610,6 +621,17 @@ you can talk directly with the PostgreSQL database:
     D     | R         | 2022-02-27 18:37:53 |                     | 4 days 03:04:58.45685 |        0 |            0
    (39 rows)

Here's another query showing the last 25 "Full" jobs regardless of the host:

    SELECT name, jobstatus, starttime, endtime,
           (CASE WHEN endtime IS NULL THEN NOW()
           ELSE endtime END)-starttime AS duration,
           jobfiles, pg_size_pretty(jobbytes)
           FROM job
           WHERE level='F'
           ORDER by starttime DESC
           LIMIT 25;

## Listing files from backups

To see which files are in a given host, you can use: