#!/usr/local/apps/perl-5.005_03/bin/perl # ccase-cpio.pl # this wee scripty-thing allegedly backs up a ClearCase VOB. # it pretends to be GNU tar, but ignores most of the command-line # options and spits out a cpio archive, not a tarball. # the argument for --directory should be the -tag, not # the vob storage area. # two things to note: # -- this does not do incrementals. Incrementals are bad, m'kay? # -- you should turn indexing off for any dumps done using this # thing -- Amanda doesn't know how to cope with cpio archives. # written by Matt McLeod , see http://boggle.org/software/ # for license details. # last modified 20000115 use File::Spec; use CCaseUtils; # configuration $ct = "/usr/atria/bin/cleartool"; $find = "/bin/find"; $grep = "/bin/grep"; $tempfile = "/tmp/voblist.$$"; $esttempfile = "/tmp/estimate.$$"; $cpio = "/bin/cpio"; # Usage info if ($ARGV[0] eq undef) { print STDERR < $tempfile"); system("$cpio -om < $tempfile 2> $esttempfile > /dev/null"); open(TEMPFILE,"<$esttempfile"); $size = -1; while () { ($tempsize, $junk) = split(" ", $_); $size += $tempsize; }; close(TEMPFILE); $size = $size * 512; print STDERR "Total bytes written: $size\n"; unlink $esttempfile; unlink $tempfile; exit; }; # you go for the arms, I'll grab the legs... if (system("$ct lock vob:$source_vob > /dev/null 2> /dev/null") eq 0) { $pre_locked = 0; } else { $pre_locked = 1; } # our chosen victim is now defenceless. Ruthlessly # copy it's contents to stdout. system("$find $vobs{$source_vob} -print | $grep -v $vobs{$source_vob}/d/ | $grep -v $vobs{$source_vob}/c/ > $tempfile"); system("$cpio -om < $tempfile 2> $esttempfile"); # release it back into the wild. if (! $pre_locked) { system("$ct unlock vob:$source_vob > /dev/null"); }; open(TEMPFILE,"<$esttempfile"); $size = -1; while () { ($tempsize, $junk) = split(" ", $_); $size += $tempsize; }; close(TEMPFILE); $size = $size * 512; print STDERR "Total bytes written: $size\n"; # mop the blood up. unlink $tempfile; unlink $esttempfile; # run away!