Re: needed tapes
Bill Arlofski via Bacula-users <[email protected]>
| Newsgroups | gmane.comp.bacula.user |
|---|---|
| Message-ID | <[email protected]> |
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<----
Hope this helps.
Bill
--
Bill Arlofski
[email protected]
_______________________________________________
Bacula-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bacula-users
signature.asc
(application/pgp-signature, 583 B)
-----BEGIN PGP SIGNATURE----- Version: ProtonMail wsCpBAEBCABdBYJn1DtaCZBIDTDab9XDQDUUAAAAAAAcABBzYWx0QG5vdGF0 aW9ucy5vcGVucGdwanMub3Jn0hrSfA5w8WGKzPIyp3pDwxYhBMuLnlBaSQiu SUbb6UgNMNpv1cNAAAAQ3Af+NwiS3l32VSamFiSV07bDSz0S4nS9pjKmmjo4 +jn3ovaTSgAoIOn+UqOSDl1IiZiksIzAYkWPafzogbd2HKWuNvK3B5btLUY8 W+cn8h+AOILzygIqTqeb9/cxQiA+5I8/Ht/K+UXh15ZeRqJuyVj0NKfQbXMg IvHyZy8Jsd5d8SneiamzKiGYBWamT27AnFt81LCYU+gOzFb5v2uxI2R+jOJ0 gniejmLhlgVFIBzn077OQFnu3haGo/9hp7llZsBDhQo8RizBKuKYmtGRsn5c VBpqe/cX5bXDh1JFxGURWYRMQ2QI1CBnB3yzHzLxnelwhk5MtRAnTYwlutp2 O479xQ== =H5mJ -----END PGP SIGNATURE-----