From: Graham P. <gr...@ws...> - 2003-12-16 15:30:44
|
Made a small mod to the sql for retrieving the filenames. This stops the listing of directories so only files can be restored. I assume you can't restore a directory but I have not attempted it so can not be sure This is the change my $sql = "SELECT DISTINCT concat( Path.Path, Filename.name ) FROM Path, Filename, File WHERE File.PathId=Path.PathId AND File.FilenameId=Filename.FilenameId AND ( File.JobId="; $sql .= join " OR File.JobId=", @$jobs; $sql .= " ) and Filename.Name != ' '"; It the and Filename.Name != ' ' thats added. I now have a fully working browser system for setting up backup lists, backing up and restoring some or all files. It is just going into production so we'll see how user friendly it is. I have got around the storage problem, and also there is a similar problem with selecting filesets if doing a full restore, by some clever, even if I say so myself, perl programming to supply the correct keystrokes. It does require that the jobs/clients/filesets etc are named in a particular way. If anyone wants any advise on this I can share what my experience. Graham On Tue, 2003-12-09 at 13:33, Kern Sibbald wrote: > This looks fine, it is the equivalent of what I do in Bacula with the > exception that I restrict the search to a single FileSet, which has its > advantages and disadvantages. I'm thinking of restricting it to a single > FileSet base name. This is to adapt to the user who abuses Jobs by > running the same Job name with two different FileSets, which is probably > rare and not well advised. > > On Tue, 2003-12-09 at 14:02, Graham Purcocks wrote: > > All > > > > Here is what I have done. Its not perfect as I only one job per client > > for backing up a laptop. However, it should be a start for other uses. > > > > It is perl and uses the DBI and CGI interface. > > > > > > my $db = DBI->connect( "dbi:mysql:bacula", "bacula", "", { AutoCommit => 0 } ); > > > > # Get the client ID. > > my $client = $db->selectrow_array( "SELECT Clientid FROM Client WHERE Name='$clientname'" ); > > > > # Get the time of the last full backup. > > my $lastfull = $db->selectrow_array( > > "SELECT JobTDate > > FROM Job > > WHERE ClientId=$client AND Type='B' AND Level='F' AND JobStatus='T' > > ORDER BY JobTDate DESC > > LIMIT 1" ) if $client; > > > > # Get the ID's of all the jobs made since then. > > my $jobs = $db->selectcol_arrayref( > > "SELECT JobId > > FROM Job > > WHERE ClientId=$client AND Type='B' AND JobStatus='T' AND JobTDate >= $lastfull" ) > > if $lastfull and $client; > > > > my @files; > > > > # Get the list of full pathnames. > > if( $jobs and @$jobs ) { > > my $sql = "SELECT DISTINCT concat( Path.Path, Filename.name ) > > FROM Path, Filename, File > > WHERE File.PathId=Path.PathId AND File.FilenameId=Filename.FilenameId AND ( File.JobId="; > > $sql .= join " OR File.JobId=", @$jobs; > > $sql .= " )"; > > my $fileset = $db->selectcol_arrayref( $sql ); > > @files = @$fileset if $fileset and @$fileset; > > } > > > > $db->disconnect(); > > > > map{s/^\s*\d+\s.{15}\s*// } @files; > > @files = grep { !/^Archive:/ and /\/./ and !/\/$/ } @files; > > > > my %labels = map { $_ => $_ } @files; > > > > # To handle long name > > foreach (values %labels) { > > $_ = "... " . substr($_,-126,126) if length $_ > 130; > > } > > > > print > > table( { -width => '100%', -border => 0 }, > > TR( > > th( { align => 'left' }, > > "Please select the file(s) you would like to retrieve then click on 'Retrieve Selected Files' or click 'Retrieve All Files' to get everything." > > ), > > ), > > TR( > > td( > > scrolling_list( > > -name => 'files', > > "-values" => [ sort keys %labels ], > > -labels => \%labels, > > -size => 25, > > -multiple => 'true', > > ), > > ), > > ), > > ); > > > > > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by: SF.net Giveback Program. > > Does SourceForge.net help you be more productive? Does it > > help you create better code? SHARE THE LOVE, and help us help > > YOU! Click Here: http://sourceforge.net/donate/ > > _______________________________________________ > > Bacula-users mailing list > > Bac...@li... > > https://lists.sourceforge.net/lists/listinfo/bacula-users -- Graham Purcocks <gr...@ws...> Weather Services International Ltd |