- 论坛徽章:
- 0
|
使用NBU备份软件,用NBU命令获得备份策略信息,然后通过脚本来对策略信息进行格式化,但是格式化后,策略信息内容会有不对称的情况。
举个例子,某个备份策略对应的IP是xx.49,但是格式化后,IP变为xx.13。
在hosts文件中,xx.49的主机名为xxx1,而xx.13的主机名为xxx1_new。
请问这种情况应该如何调整脚本?
脚本如下:
#!/usr/bin/perl
if ( ! open BPPLLIST, '<', '/usr/openv/script/output/bppllist.out')
{
die "Cannot open file: $!";
}
while ( <BPPLLIST> )
{
chomp;
if ($includecount==1) {
if ($_ =~ /Schedule:/) {
$includecount=0;
} else {
push (@backupfile,$_);
}
}
if ($windowscount==1) {
if ($_ =~ /Schedule:/ || $_ =~ /------------------/ || $_ =~ /Catalog Disaster Recovery/) {
$windowscount=0;
} else {
push (@windows,$_);
}
}
if ($_ =~ /Policy Name:\s+(\S+)\s*/) { $plname=$1;}
if ($_ =~ /Active:\s+(\S+)\s*/) { $active=$1;}
if ($_ =~ /Schedule:\s+(\S+)\s*/) { $scname=$1;}
if ($scname ne "Default-Application-Backup"){ $rscname=$scname;}
if ($_ =~ /Type:\s+(.*Backup)/) {
$sctype=$1;
if ($sctype ne "Application Backup"){ push (@rsctype,"$sctype");}
}
if ($_ =~ /HW\/OS\/Client:\s+\S+\s+\S+\s+(\S+)/) {
$clientname=$1;
if ( ! open HOSTS, '<', '/usr/openv/script/output/hosts.out'){
die "Cannot open file: $!";
}
while (<HOSTS>) {
chomp;
if ($_ =~ /([^#]\S+)\s+$clientname/) { $clientip=$1;}
}
close HOSTS;
}
if ($_ =~ /Include:\s+(\S+)\s*/) { $include=$1;$includecount=1;push (@backupfile,"$include");}
if ($_ =~ /Daily Windows:/) { $windowscount=1;}
if ($_ =~ /\s+([A-Z]\w*),(\s+Week\s+[1-5])/) { $weekday=$1.$2;push (@backupday,"$weekday");}
if ($_ =~ /(.*of month)$/) { $weekday=$1;push (@backupday,"$weekday");}
if ($_ =~ /SPECIFIC DATE \d - (.*)$/) { $weekday=$1;push (@backupday,"$weekday");}
if ($_ =~ /Frequency:\s+(.*)/) { $weekday=$1;push (@backupday,"$weekday");}
if ($_ =~ /Retention Level:.*\((.*)\)/) { $retention=$1;push (@retention,"$retention");}
if ($_ =~ /^---------------------------------------------------------.*/ && $active eq "yes") {
print "$plname,netbackup2,$clientname,$clientip,@backupfile,@rsctype,@backupday,@retention,@windows\n";
$active=undef;
$rscname='Default-Application-Backup';
@backupday=();
@backupfile=();
@windows=();
@rsctype=();
@retention=();
$weekday=undef;
}
if ($_ =~ /^---------------------------------------------------------.*/ && $active ne "yes") {
$active=undef;
$rscname='Default-Application-Backup';
@backupday=();
@backupfile=();
@windows=();
@rsctype=();
@retention=();
$weekday=undef;
}
}
close BPPLLIST; |
|