Here is the script I use (with mysql, postgres is probably similar). The backups are physically located in either /misc/BACKUP2 or /misc/BACKUP3 so you will need to adjust that for your own needs.
I run this once a week as the RunBeforeJob script in an admin job in bacula. I use a very low priority so this executes after all the backups for the day have completed. Here is the job definition, the script itself is below. I hope it doesn't get wrapped too badly! ----------------- Job { Name = "Prune" Type = Admin Schedule = "WeeklyCycleAfterBackup" Level = Full Client = XXXXX-fd FileSet="Linux Full Set" Messages = Standard Storage = Disk3 Pool = Default RunScript { Runs When = "Always" Runs On Client = "No" Fail Job On Error = "No" Command = "/usr/local/sbin/prunebacula" } Priority = 30 # run after main backup and backup catalog } -------------------------- #!/bin/bash # Prunes all volumes in bacula that have expired, and then # deletes those volumes that have been pruned. volumes=$(mysql -ubacula -B -N -e"select VolumeName from Media order by VolumeName;" bacula) for i in $volumes do echo "prune volume=$i yes" | bconsole >/dev/null done # now find out which volumes have been pruned, and delete them # volumes=$(mysql -ubacula -B -N -e"select VolumeName from Media WHERE VolStatus='Purged' OR VolBytes=0 order by VolumeName;" bacula) volumes=$(mysql -ubacula -B -N -e"select VolumeName from Media WHERE VolStatus='Purged' order by VolumeName;" bacula) for i in $volumes do bconsole >/dev/null <<EOF delete volume=$i yes EOF rm -f /misc/BACKUP[23]/$i done ls /misc/BACKUP[23]/*.bacula >/tmp/$$.1 volumes=$(mysql -ubacula -B -N -e"select VolumeName from Media order by VolumeName;" bacula) # finally, report on any orphaned files for i in $volumes do grep -v $i </tmp/$$.1 >/tmp/$$.2 rm -f /tmp/$$.1 mv /tmp/$$.2 /tmp/$$.1 done echo "---------" echo "Orphaned files (no longer in bacula DB but still on disk)" cat /tmp/$$.1 rm -f /tmp/$$.1 Andreas Schuldei wrote: > hi! > i dont want to wait untill my filesystem is filled up on my storage > cluster and want to start to purge and recycle volumes now. > > i want to recycle all volumes that have the status "purged". i am not > afraid to enter the database (postgresql here) and run sql queries. > what query should i run? > > will this make bacula reuse the space of old files/volumes? > > /andreas > -- Kevin Keane Owner The NetTech Find the Uncommon: Expert Solutions for a Network You Never Have to Think About Office: 866-642-7116 http://www.4nettech.com This e-mail and attachments, if any, may contain confidential and/or proprietary information. Please be advised that the unauthorized use or disclosure of the information is strictly prohibited. The information herein is intended only for use by the intended recipient(s) named above. If you have received this transmission in error, please notify the sender immediately and permanently delete the e-mail and any copies, printouts or attachments thereof. ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Bacula-users mailing list Bacula-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bacula-users