#!/bin/sh
# STTA Rev. 1.3 Copyright (c) 2001-2004 Jesús Pérez Lorenzo  --- license GNU GPL 
# stta: (@#) 1.31051043346- [2004_01_29_102036]

STTA_TOOLSDIR="STTATOOLSDIR"
[ -x $STTA_TOOLSDIR/setenv_vars ] &&  . $STTA_TOOLSDIR/setenv_vars

TTAINSTDIR=/opt/tarantella 
. $TTAINSTDIR/var/javaenv

cd $TTAINSTDIR/var

ALL="docroot ens info password preferences serverconfig serverresources tsp"
if [ "$#" -eq 0 ] ; then
  echo "$msg_ttabackupUSAGE";
  exit 1
fi
if [ -d $1 ] ; then 
   DestDir=$1
else
   echo "$1 : $msg_notexistdir !!!"
   exit 2
fi 
if [ "$2" != "" ] ; then 
 case $2 in 
 -nodocroot) newall=`echo $ALL | sed 's/docroot//g'`
             ALL=$newall ; break ;;
  *) if [ -d $2 ] ; then 
          ALL="$2"
     else
           echo "$2 : $msg_notexistdir !!!"
           exit 2
     fi ;;
 esac
fi
ahora=`date +%Y_%m_%d_%H%M%S`
mkdir $DestDir/$ahora
for nomdir in `echo $ALL` 
do
   echo "$msg_cpfiles \"$nomdir\" ..."
   find $nomdir -print -depth | $backup_cmd  $DestDir/$ahora/$nomdir".cpio"
   $ZipTool $DestDir/$ahora/$nomdir".cpio"
done
echo "$msg_cpfiles \"$STTA_defslist\" ..."
cd $STTA_defslist
nameDefs=`basename $STTA_defslist`
cd ..
tar cpvf $DestDir/$ahora/defs".tar"   $nameDefs
$ZipTool $DestDir/$ahora/defs".tar"
   

