On 4/12/23 10:44, Chris Wilkinson wrote:
Thanks Bill.

I looked into using the query command but the standard queries prompts the user 
to specify the volume name one by one. I
haven't yet been able to find a way to script this command by reading volume 
names from storage so that the output can be fed
to the delete and rm commands.

My SQL and catalog structure knowledge is minimal but I'll try to figure out an 
additional SQL to add to the query list.

Well, I guess it depends on if the volume names are unique from other ones... I 
mean like if the volumes you want to check
are named like `Test_vol-xxxx` for example, or if they are all in the same pool 
by themselves because then it is easy to do:

#!/bin/bash

for vol in $(echo -e "list media pool=xxxx\n\quit\n" | "${bcbin}" -c "${bccfg}" 
\
  | grep "^| \+[0-9]" | awk '{print $2}'); do

  echo "Checking Volume: ${vol}"
  echo -e "query\n14\n${vol}\n" | "${bcbin}" -c "${bccfg}" | grep "^+\|^|"

done



If they are not in the same pool, but are names similarly, and different from 
other volumes, you can change that first echo
command to something like:
----8<----
for vol in $(echo -e "list media\n\quit\n" | "${bcbin}" -c "${bccfg}" \
  | grep "^| \+[0-9].*| xxxxxx"| awk '{print $2}'); do
----8<----

Where xxxxxx is the beginning of these volume names


BTW, the query list in /etc/bacula/scripts is empty so I copied across the 
query file from the distribution section.

Yes, this is normal. :)


Hope this helps,
Bill

--
Bill Arlofski
w...@protonmail.com

Attachment: signature.asc
Description: OpenPGP digital signature

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

Reply via email to