Bacula-users

Re: [Bacula-users] How to prune/delete job entries from bacula db

2010-01-09 08:13:22
Subject: Re: [Bacula-users] How to prune/delete job entries from bacula db
From: "Timo Neuvonen" <timo-news AT tee-en DOT net>
To: bacula-users AT lists.sourceforge DOT net
Date: Sat, 9 Jan 2010 14:30:04 +0200
> I want do delete all the failed Jobs from the job lists.
>
> I've identified all them with the following sql
>
> # 19
> :List jobs which have no files in db and are possible failed
> SELECT DISTINCT 
> Job.JobId,Job.Name,ClientId,Job.StartTime,Job.Type,Job.Level,JobFiles,JobBytes,JobStatus
> FROM Job
> WHERE JobId not in ( SELECT DISTINCT JobId from File )
> AND JobStatus in ('A','R','E','f','C','e')
> ORDER BY JobId
>
> I've to much of them.
>
> Prune or purge did not help because looks like delete more of the jobs
> I want.
>
> Any idea? Searching list and dokumentation didn't give me an solution.
>
> At the moment only the following sql will help, I think:
>
> delete from job
> WHERE JobId not in ( SELECT DISTINCT JobId from File )
> AND JobStatus in ('A','R','E','f','C','e')
>

If this is a one-time-need, how about collecting all the jobs to be deleted 
into a file, and then write a shell script that calls bconsole and deletes 
those listed jobs one by one the "official" way?

This would be a much safer way than touching the catalog database directly. 
I'm not a Catalog Guru, but I guess you should also delete file records and 
possibly alter/delete some other information to keep catalog consistent.

To do it at low level by oneself, having a look at bacula source code to see 
what the delete console command does, might be a good start.

--
TiN 



------------------------------------------------------------------------------
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

<Prev in Thread] Current Thread [Next in Thread>