Bacula-users

Re: [Bacula-users] Auto-deleting purged volumes

2010-01-06 06:04:10
Subject: Re: [Bacula-users] Auto-deleting purged volumes
From: "Mike Holden" <bacula AT mikeholden DOT org>
To: "bacula-users" <bacula-users AT lists.sourceforge DOT net>
Date: Wed, 6 Jan 2010 11:01:37 -0000
Marek Simon wrote:
> Phil Stracchino napsal(a):
>> I have a disk-based backup setup that uses dated volumes which are used
>> for a 23-hour period then marked 'used', so that I can be certain a
>> particular day's backups are contained in a single file.  They are of
>> course purged after their retention time expires, at which time they are
>> moved to the Scratch pool.
>>
>> What I would LIKE to happen next is to have these purged volumes
>> automatically deleted both from the catalog AND from disk.  Has anyone
>> else already implemented a solution to this problem?  I'd sooner not
>> reinvent the wheel if there's a perfectly good existing solution out there.
>

(top-posting fixed)

> Bacula is not intended to delete anything. The way you have a new volume
> for a new day with a new uniq date-based name is not a good way for
> bacula. You shuld have the volumes with generic names and recycle them
> instead of removing them (you do not destroy the tapes after one use
> either).
> However you always can have a cron script or bacula admin job, which
> finds the old volumes and removes them.
> I have similar script for deleting volumes older then 60 days, usefull
> for automatic tide up when you often add and remove clients.
>
> example:
> STORAGE_PATH=/var/lib/bacula/backup
> /usr/bin/find $STORAGE_PATH/storedevice* -type f -ctime +60 -regex
> '.*-all-[0-9][0-9][0-9][0-9]$' -delete
>
> Marek
>

Attached is the script I wrote to take care of this. What I found is that over 
time,
backups are occasionally larger than expected due to events like software 
updates or
whatever, and disk space usage slowly increases. I initially took care of this 
by adding
extra space using LVM to grow the partition and reiserfs to grow the filesystem 
into the
new space. Eventually though, you run out of physical disk to add!

Although in principle it is good that bacula keeps backed up data until it is 
re-needed,
in practice, it can lead to infinite disk space growth over time.

The attached script is php, and connects to the bacula database (plug in 
appropriate
user name, password and server name in the connect statement at the top). It 
first of
all looks for volumes past their expiry date and purges them. It then looks for 
purged
volumes and deletes them. Finally, it looks in the backup directory (plug in 
your
location here) for files with no matching database entry and deletes them.

Use at your own risk etc. I'm not responsible if it deletes your backups, 
crashes your
car or causes your freezer to thaw out!!!

Automated removal as detailed by Marek above is difficult to implement simply, 
because
you will probably have multiple retention periods on your files, and you need 
to take
this into account in your deletion. Plus, deleting the files while they are 
still listed
in the bacula database is possibly not a good idea!
-- 
Mike Holden

http://www.by-ang.com - the place to shop
for all manner of hand crafted items,
including Jewellery, Greetings Cards and Gifts

Attachment: purgeall
Description: application/php

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users