Search code examples
bashbacula

Prevent security-query in bacula scripting


I'm trying to script bacula to delete old files that are not used any more. While there are over 1000 old files im not willing to do it manualy.

How far I've come

for filename in $(echo "list volume" |bconsole |grep Purged |awk -F\| '{print $3}')
do 
    echo "delete volume=2012-10-19_23h40m" | bconsole
done

But now I have the problem of the security question where someone have to enter "yes"/"no".

Are you sure you want to delete Volume "2012-10-19_23h40m"? (yes/no)

But the bconsole program is just exiting!

Any ideas?


Solution

  • @brain thanks for the input but I like one liner :D

    what is nearly a one-liner and works like charm

    for filename in $(echo "list volume" |bconsole |grep 2012-08 |awk -F\| '{print $3}'); do bconsole << EOF; rm /media/storage/$filename; done
    delete volume=$filename
    yes
    quit
    EOF
    

    so you can skript everything with an interactive programm :D