#!/usr/athena/bin/perl
# $Header: /afs/sipb/project/newdump/scripts/RCS/do-backups.pl,v 1.4 1999/02/05 18:00:48 root Exp $
#
# Strategy:
# 1) list all volumes in cell
# 2) prune down to list of volumes to be backed up
# 3) iterate over list, backing up.
#

require 'flush.pl';

$cell = "sipb.mit.edu";
$ENV{'PATH'} = "/afs/athena.mit.edu/system/afsuser/bin:/afs/athena.mit.edu/system/afsuser/\@sys/etc:/afs/sipb.mit.edu/service/\@sys:/bin:/usr/bin:/bin/athena:/usr/athena/bin:/usr/new:/usr/ucb";

@vollist = ();
$i = 0;
open(VLDB, "vos listvldb -cell $cell|") || die "Can't get VLDB $!";
while (<VLDB>) {
    chop;
    unless (m/^\s/ || m/^\s*$/ || m/\.nb\s*$/ || m/^disk\./ || 
	    m/^Total entries:/ || m/^n\./ ) {
	print $_, "\n";
	$vollist[$i] = $_;
	$i++;
    }
}
close(VLDB);

print "\nContinue Backup? [Y/n] ";
&flush(STDOUT);
$_ = <>;
chop;
if (m/^\s*n/i) {exit;}
print "continuing...\n";

foreach $vol (@vollist) {
    print $vol, "...";
    &flush(STDOUT);
    system ("vos backup $vol -cell $cell -verbose");
}

print "backups done!\n";
exit 0;
