Linux下的ClearCase备份脚本
版上搜了一下,备份脚本都是基于Windows的perl脚本,没有Unix,没办法,只能直接写一个,,在Aix上测试通过
备份到本机,只是备了VOB storage和rgy,输出重定向到log里
用Shell包一下,加到Job Scheduler里面,就可以daily backup了
另外,因为AIX上和Unix上的tar命令不太相同,所以脚本为了支持AIX,tar命令的参数就写的麻烦点
#!/usr/bin/perl -w
# CCLT backup scirpt
# written by
my $clearcase = "/opt/rational/clearcase/etc/clearcase";
my $cleartool = "/opt/rational/clearcase/bin/cleartool";
my $vob_rpath = "/ClearCaseStorage VOBs";
my $rgy_rpath = "/var/adm/rational/clearcase rgy";
my $timestamp = &get_timestamp();
my $backup_file = "/opt/install/ccbackup/ccbackup$timestamp.tar.gz";
my $backup_log = "/opt/install/ccbackup/ccbackup$timestamp.log";
open(STDOUT, ">$backup_log");
open(STDERR, ">&STDOUT");
$| = 1;
select(STDERR);
$| = 1;
&lock_vobs();
&stop_cclt();
&backup_cclt();
&start_cclt();
&unlock_vobs();
close(STDOUT);
close(STDERR);
sub get_timestamp {
my ($sec, $min, $hr, $mday, $mon, $yr, $wday, $yday, $isdst) = localtime(time);
return sprintf ("%04d%02d%02d%02d%02d%02d",$yr+1900, $mon+1, $mday, $hr, $min, $sec);
}
sub stop_cclt {
print "==== Stopping ClearCase LT ====\n";
system("$clearcase stop");
print "==== ClearCase LT Stopped ====\n";
}
sub start_cclt {
print "==== Starting ClearCase LT ====\n";
system("$clearcase start");
print "==== ClearCase LT Started ====\n";
}
sub lock_vobs {
print "==== Locking VOBs ====\n";
open(VOBS, "$cleartool lsvob|");
while() {
my ($active, $vob_tag, $vob_stg) = split(/\s+/, $_);
system("$cleartool lock vob:$vob_tag");
}
close(VOBS);
print "==== VOBs Locked ====\n";
}
sub unlock_vobs {
print "==== Unlocking VOBs ====\n";
open(VOBS, "$cleartool lsvob|");
while() {
my ($active, $vob_tag, $vob_stg) = split(/\s+/, $_);
system("$cleartool unlock vob:$vob_tag");
}
close(VOBS);
print "==== VOBs Unlocked ====\n";
}
sub backup_cclt {
print "==== Starting ClearCase LT Backup ====\n";
system("tar cf - -C $vob_rpath -C $rgy_rpath | gzip -qc > $backup_file");
print "==== ClearCase LT Backup Completed ====\n";
}
阅读(1294) | 评论(0) | 转发(0) |