#!/bin/csh -ex

#####################################################################################
# Script for backing SRB files into a particular resource
# Call as follows:
# backupColl.sh <backUpResource> <collectionToBeBackedUp>
#
# We suggest that you pipe the output to a file (or use tee to send it
# to stdout as well as to another file.
#
# You need to be a srbAdmin user to perform this backup
# Needs the following variables to be set inside this shell script
#
# binDir  = SRB utilities bin directory
# 
# Also needs  .MdasEnv and .MdasAuth files
#
#####################################################################################


set binDir = .
set testdate=`date "+%Y-%m-%d:%H:%M:%S"`
if ( $1 == "" || $2 == "" ) then 
 echo "Error: Insufficient Arguments"
 echo "Use $0 <backUpResource> <collectionToBeBackedUp>"
 exit 1
else
 echo Starting Backup for Collection $2 into Resource $1  at Time $testdate
endif
$binDir/Sinit -v
$binDir/Schksum -rv $2 
$binDir/Sbkupsrb -Arv -S $1 $2 
$binDir/Schksum -crv -A "RESOURCE='$1'" $2 
$binDir/Sexit
set testdate=`date "+%Y-%m-%d:%H:%M:%S"`
echo BackUp Completed Successfully   at Time $testdate
exit 0
