Am 14.03.25 um 15:21 schrieb Bill Arlofski via Bacula-users:
On 3/14/25 4:03 AM, 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.
Hello Stefan,
In a script, you can do:
echo -e "sql\nSELECT......ORDER BY volumename INC;\n\nquit\n" | bconsole
The echo -e: enable interpretation of backslash escapes
The `\n` in the script are line feeds. The two `\n\n` in a row get you
out of the bconsole SQL interface.
This method (echo -e) allows you to enter multiple bconsole commands in
one session using echo.
And, to make things more clear with the long SQL query, you can split
the query up, by appending backslashes to the end of each line like:
----8<----
echo -e "sql\nSELECT
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.Poo;\n\nquit\n" | bconsole
----8<----
Thank you! Will try asap.
I was already wondering how to manage to "install" a query as number 22
somewhere. Your suggestion makes it easier for me to use and edit the
query for now.
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users