Bacula-users

Re: [Bacula-users] Searching for files

2010-10-22 07:45:09
Subject: Re: [Bacula-users] Searching for files
From: Phil Stracchino <alaric AT metrocast DOT net>
To: bacula-users AT lists.sourceforge DOT net
Date: Fri, 22 Oct 2010 07:41:53 -0400
On 10/22/10 02:47, ladolf wrote:
> I would also like to know the answer to this question. Sometimes I
> need to restore a file and I know part of file name. I don't know
> which letters are upper case. If I know which job to use then I use
> "restore" command in bconsole. I select the option "Enter list of
> comma separated JobIds to select" or "Select the most recent backup
> for a client". Then I use "find" command. But I cannot find any help
> for "find" command (unless the string saying that I can use
> wildcards). And it is case sensitive. It would be great if the
> command would support regular expressions. Sometimes I need to list
> many folders to find the file.
> 
> If I don't know when the file has been backed up then this task can
> be really tedious. I have to search in many jobs. There is an option
> in restore that says "List Jobs where a given File is saved". But in
> this case you have to know the exact filename. And even with this I
> cannot see this command working.
> 
> Maybe anyone knows how to query the bacula database directly to get
> search result for a file.

At the simplest possible level: start up bconsole, use the SQL query
function, and enter this query:

SELECT FROM Filename where Name like "%what you know of the filename here%";

That is case insensitive, and % in a SQL query is a wildcard.  If you
know something of the path where the file should be, you can search for
that in the Path table the same way to narrow it down.

You could combine the name and path queries to make a more complex query
like this:

SELECT DISTINCT p.Path, n.Name FROM Path AS p, Filename AS n, File AS f
WHERE f.FilenameId = n.FilenameId AND f.PathId = p.PathId AND n.Name
LIKE "%partial filename%" AND p.Path LIKE "%partial path%" ORDER BY
p.Path, n.Name;

This query could also be performed as:

SELECT DISTINCT Path, Name FROM File LEFT JOIN Path ON File.PathId =
Path.Pathid LEFT JOIN Filename ON File.FilenameId = Filename.FilenameId
WHERE Name LIKE "%partial filename%" AND Path LIKE "%partial path%"
ORDER BY Path, Name;



-- 
  Phil Stracchino, CDK#2     DoD#299792458     ICBM: 43.5607, -71.355
  alaric AT caerllewys DOT net   alaric AT metrocast DOT net   phil AT 
co.ordinate DOT org
         Renaissance Man, Unix ronin, Perl hacker, Free Stater
                 It's not the years, it's the mileage.

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users