Your suggestion was perfect. This little bash script has the desired effect. It can be altered to find/delete other types of unwanted records such as Error or Read-Only or restricted to a particular pool as you suggested. It doesn’t delete anything on disk, only from the catalog.
#!/bin/bash #Usage: sudo ./delete-purged-volumes.sh any-char #Delete purged Bacula volumes. Do not delete if arg is empty if [[ -z $1 ]]; then echo "Not deleting" fi for vol in $(echo "list volume" | bconsole | grep Purged | awk '{print $4}') do if [[ ! -z $1 ]]; then echo "delete yes volume=$vol" | bconsole > /dev/null echo "Volume $vol deleted" else echo "Volume $vol not deleted" fi done Best -Chris- > On 21 Feb 2022, at 11:22, Josip Deanovic <djosip+n...@linuxpages.net> wrote: > > On 2022-02-21 11:46, Chris Wilkinson wrote: >> Following a failure of a storage device, I have a number of records >> marked as ‘read-only’ in the database. >> The backup jobs has been moved to a new storage so these records are >> now redundant and I’d like to clean them out. >> I looked through bconsole commands but didn’t find a command to do >> this except by finding volumes with read only status and deleting them >> one by one. Is there a semi-automated way to find and delete read-only >> records? > > > Hi Chris > > I think that bconsole delete command would not accept more than > one volume name or volume id. > > You could get the list of your read-only volumes from the database > and then use shell one-liner which would send the delete command > through bconsole in a loop. > > Instead of retrieving the list of volumes from the database you > could also get them from bconsole + some grepping or awking. > > Something like this would give you the list of the names of your > volumes in the Read-Only state from all available pools (you might > want to limit the list to a specific pool using pool=your-pool-name): > echo "list volumes" | bconsole | grep Read-Only | awk '{print $4}' > > Then you can take that list of volume names and in a similar manner > call bconsole tool with the delete command in a loop. > > > Regards! > > -- > Josip Deanovic > > > _______________________________________________ > 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