On 14/3/25 21:03, Stefan G. Weichinger via Bacula-users wrote:
Am 14.03.25 um 07:48 schrieb Stefan G. Weichinger via Bacula-users:

I use an 8-slot autoloader, I added a little bit of SQL to the query file and just run that, it lists my tapes from last-used to most recent. I grab the three oldest, move them to the Scratch pool, purge them, and replace the three oldest in the autoloader with them.

NOTE: This is for Postgres, YMMV:
# 22
:List volumes in Order of LastWritten
SELECT Media.MediaId, Media.VolumeName, Media.PoolId, Pool.Name AS Pool, Media.Slot,          Media.Slot <> 0 AS InChanger, Media.FirstWritten, Media.LastWritten, Media.VolStatus,          GREATEST(0, (extract('epoch' from LastWritten + Media.VolRetention * interval '1second' - NOW())::bigint)) as ExpiresIn,
         Media.VolBytes
     FROM Media
     INNER JOIN Pool
         ON Media.PoolId = Pool.PoolId
     ORDER BY Media.LastWritten;

I wrote it about 6 years ago, previously I'd been looking at the output of "list media" and working out what was oldest.

oh, looks promising, thanks for sharing! I will test that later today when I have to select tapes for the weekend.

(how) do you run it in a cronjob or so?

No, I just have bconsole open permanently in a screen on the system running the director, I just type in "query 22" and read it.

As a cronjob I'd put "echo query 22 | bconsole" in a file and execute that.

        Cheers,
                Gary    B-)


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

Reply via email to