#!/bin/sh
#
# Reclone all backup volumes in the entire cell except those that are 
# replicated.  We'll get those later.
# $Id$
#
# $Log$
#

vos=/usr/afs/bin/vos
cell=sipb.mit.edu
errs=/tmp/clone.errs.$$
header=/tmp/clone.hdr.$$
mailto=sipb-afsreq@mit.edu
mailrepl=sipb-afsreq@mit.edu
host=`/bin/hostname`

volumes=`$vos listvldb -c $cell -noauth | /usr/athena/bin/perl -e 'while(<>) { if /^((\S+)/) { $vol = $1; } if ((/Backup/) && !(/ROnly/)) { print $vol,"\n"; } }'`

for vol in $volumes; do
    $vos backup $vol -c $cell -localauth >/dev/null 2>>$errs
    sleep 5
done

if [ -s $errs ]; then
    cat > $header <<EOF
From: root@${host}
To: $mailto
Reply-To: $mailrepl
Subject: $cell cell nightly cloning errors

EOF

    (cat $header; cat $errs) | /usr/lib/sendmail -t -f${mailrepl}
else
    rm -f $errs
fi




