Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1177167
  • 博文数量: 312
  • 博客积分: 12522
  • 博客等级: 上将
  • 技术积分: 3376
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-27 18:35
文章分类

全部博文(312)

文章存档

2016年(3)

2015年(1)

2013年(1)

2012年(28)

2011年(101)

2010年(72)

2009年(13)

2008年(93)

分类: 项目管理

2010-04-26 10:23:36


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) |
给主人留下些什么吧!~~