Chinaunix首页 | 论坛 | 博客
  • 博客访问: 466346
  • 博文数量: 279
  • 博客积分: 4467
  • 博客等级: 上校
  • 技术积分: 2830
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-03 14:43
文章分类

全部博文(279)

文章存档

2013年(1)

2012年(39)

2011年(35)

2009年(29)

2008年(131)

2007年(44)

分类:

2007-11-27 16:18:48

在bcpad中使用rsync备份, 会得到log,
我们需要在BCPAD(MEMBER)中写一个脚本(WINDOWS可用),具体功能如下:
1、从“c:\rsync_script\”与“c:\robosync_script\”中扩展名为log的文件中提取 出没有成功备份数据的信息。
2、这些信息中可能会包括“skipping overly long name”,"file has vanished" 等关键字。
3、将以上信息保存为一个以txt为扩展名的文件,报存在"c"\bcp_report\"中
4、每天定时执行脚本程序。
5、目标时间定在下周二下班前完成。

bcp.pl:

#/usr/bin/perl

#use warnings;

#get current time as filename for report.

@day=localtime(time());
$mon=$day[4]+1;
$report="c:\\bcp_report\\".$mon.$day[3].$day[5].".txt";
open (FILEHANDLE,">>$report");
close(FILEHANDLE);
#`touch c:\bcp_report\$report`;

#`date>>$report`;#linux command...cannot use in dos

 #call subroutine

foreach $dir(qw(c:\\rsync_script\\ c:\\robosync_script\\)){
 
$n=&txt($dir);
}
 
#subroutine

sub txt{
#get all log files

opendir(DH,$dir) or die("can't open $dir:$!\n");
foreach $file(readdir DH){
 
if($file=~/log/){
$file=$dir.$file;
 
open(MSG,$file) or die "can't open $file:$!\n";
 
foreach $_(<MSG>){
 
#get error message and copy to $report.

if(/skipping overly long name/ || /file has vanished/){
#chomp($_);

open FILE,">>$report" or die $!;
print FILE $_;
close FILE;
#`echo $_>>$report`;#

#print "echo $_ >> $report";

#print $_;#temp

}
}
}
close MSG;
}
 
closedir DH;
}

阅读(424) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~