On 9/16/25 12:39, Gary Dale wrote:
Internet searches have been futile. The ones that actually mention bconsole suggest what I've been trying to do should work, but it doesn't.

Through my initial setup struggles, my storage volumes have become a disjointed mess. To make matters worse, there are close to a hundred volumes showing "Error" when I "List Volumes". I have only about 20 that show up as physical disk volumes. And automatic volume creation seems to be failing. All my backups for the last 5 days have failed.

To fix this, I'm trying to go back to the start (without purging and reinstalling bacula) by removing everything to date. However, I can't do that for the volumes - way to many of them. So I'm trying to run a bash script to cycle through them to purge them.

I've found multiple answers that suggest using a bash for loop then doing something like:         echo "purge volume ${volname} yes" | bconsole  - where $volname is created by the for loop - should work. And it does actually to a point. It will invoke the "purge volume" dialogue then asks which pool to use. Inserting the pool number after the volume command (e.g. echo "purge volume 2 ${volname} yes" | bconsole) doesn't work either. Nor does inserting \n into the echoed command at various points.

Being able to put bconsole commands into a bash script seems like something that will be generally useful but I can't find a way to make it work.

The following is a simple script to allow passing answers for bconsole's questions. For example, my query command 8 lists volumes needed for a restore, and I can list for a client by:

[root@cnode1 ~]# bcommand query 8 : joshnuc-fd
cmd2 = joshnuc-fd
Connecting to Director bacula.pvct.lan:9101
1000 OK: 10002 s3-dir Version: 15.0.2 (21 March 2024)
Enter a period to cancel a command.
query 8
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
No results to list.
No results to list.
Enter Client Name: joshnuc-fd
+
|
+
+
+
|
+
+
+
|
+
+
+-----------------+
| VolumeName      |
+-----------------+
| vchanger1_17_19 |
| vchanger1_9_18  |
| inc_8           |
| inc_4           |
| inc_9           |
| inc_5           |
| inc_0           |
+-----------------+
No results to list.
No results to list.
You have messages.
quit



[root@cnode1 scripts]# cat bcommand
#!/bin/sh
bconsole=/usr/sbin/bconsole
cmd1=$1
cmd2=
shift
while [ ! "z$1" == "z:" ] && (( $# )) ; do
  cmd1="$cmd1 "$1
  shift
done
if [ "z$1" == "z:" ]; then
  shift
  while (( $# )); do
    cmd2="$cmd2 "$1
    shift
  done
fi
echo cmd2 = $cmd2
cmd2a=`echo $cmd2`
$bconsole <<EOD
$cmd1
$cmd2a
quit
EOD
exit 0




Any ideas?



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

Reply via email to