I stripped out some corporate specific info from here... please let me know
if you have a run time problem with this. This script is more for finding a
single file in a client's history and recovering it.
Usages:
searchclient.pl someclient "\.mp3$" "\.txt"
Result:
# ./search_client.pl unixclient '\.txt$' '\.mp3$'
Searching for strings(s): \.txt$ \.mp3$...
Processing 1247533332 (Mon Jul 13 20:02:12 2009) [0/443] ...
1247533332: /local/.../fontconfig-user.txt
1247533332: /local/.../fontconfig-devel.TXT
...
Recovery commands:
recover -t 1247533332 -a "/local/.../fontconfig-user.txt" [OFF070 offline]
recover -t 1247533332 -a "/local/.../fontconfig-devel.TXT" [OFF070 offline]
---- SCRIPT searchclient.pl BELOW ---
#!/usr/bin/perl
if (!@ARGV){
die "Usage: $0 client [-a] <search string>\n\t -a -- search group Archive
only\n";
}
$client = shift;
foreach $arg (@ARGV) {
if ($arg =~ /-a/) {
$arguments = " -q group=Archive ";
} else {
push @searchstrings,$arg;
}
}
if (@searchstrings) {
print "Searching for strings(s): " . join(" ",@searchstrings) . "... \n";
}
my @data = `mminfo -r nsavetime -v $arguments -c $client`;
chomp(@data);
if (!@data) {
die "ERROR: Unable to get list of savetimes - check mminfo query";
}
$totalepochs = $#data;
foreach my $epoch (reverse(@data)){
$epoch =~ s/ *//g;
chomp;
my $tm = localtime($epoch);
print "\nProcessing $epoch ($tm) [" . $epochs++ . "/$totalepochs] ...\n";
open(IN, "nsrinfo -t $epoch $client|") || die "Cannot run nsrinfo ";
$results=0;
while(<IN>){
$results++;
chomp;
if (@searchstrings) {
foreach $x (@searchstrings) {
if (/$x/i) {
$found++;
}
}
if ($found) {
print "\n$epoch: $_\n";
$tapequery = "-q savetime=" . $epoch . ",client=" . $client .
",!near";
$tapes = `mminfo -r volume $tapequery`;
$messages .= "recover -t $epoch -a \"$_\"";
if ($tapes) {
$tapes =~ s/\n/ /g;
$messages .= " [" . $tapes . "offline]";
}
$messages .= "\n";
$found = 0;
}
} else {
print "$epoch: $_\n";
}
}
close(IN);
print "Searched $results files.\n";
}
if ($messages) {
print "\n\nRecovery commands:\n$messages\n";
}
On Tue, Jul 14, 2009 at 2:43 PM, Tim Mooney <Tim.Mooney AT ndsu DOT edu> wrote:
> In regard to: [Networker] Is there a way to read the indexes?, Louis
> Munro...:
>
> Hello all,
>> I'm running networker 7.4 on solaris 10.
>>
>> Is there a way to read the information in the index files?
>> More specifically, I need to know how many files of a certain
>> extension have been backed in the last year for a saveset.
>>
>
> Looking for mp3s? :-)
>
> Assuming you have client indexes going back a year, this type of thing is
> easy. Look at the nsrinfo command and search the archives for this list
> for information on best to use the command.
>
> You basically want to find the exact numeric savetime (nsavetime) for
> the savesets you want to search, using something like
>
> mminfo -ot -q 'client=your.client.name,name=/home' -r nsavetime >
> nsavetimes
>
> Then use nsrinfo to report the contents of each one of those savesets:
>
> for d in `cat nsavetimes`
> do
> nsrinfo -t $d your.client.name | egrep '\.mp3'
> done
>
>
> Of course the commands could be combined, but I find it generally takes me
> a little fiddling with the mminfo query before I have what I want to feed
> to nsrinfo in the loop.
>
> This all requires that your client indexes are still populated though.
>
> Tim
> --
> Tim Mooney Tim.Mooney AT ndsu DOT
> edu
> Enterprise Computing & Infrastructure 701-231-1076 (Voice)
> Room 242-J6, IACC Building 701-231-8541 (Fax)
> North Dakota State University, Fargo, ND 58105-5164
>
>
> To sign off this list, send email to listserv AT listserv.temple DOT edu and
> type
> "signoff networker" in the body of the email. Please write to
> networker-request AT listserv.temple DOT edu if you have any problems with
> this
> list. You can access the archives at
> http://listserv.temple.edu/archives/networker.html or
> via RSS at http://listserv.temple.edu/cgi-bin/wa?RSS&L=NETWORKER
>
To sign off this list, send email to listserv AT listserv.temple DOT edu and
type "signoff networker" in the body of the email. Please write to
networker-request AT listserv.temple DOT edu if you have any problems with this
list. You can access the archives at
http://listserv.temple.edu/archives/networker.html or
via RSS at http://listserv.temple.edu/cgi-bin/wa?RSS&L=NETWORKER
|