#!/bin/sh
TTADIR=/opt/tarantella 
. $TTADIR/var/javaenv
USAGE="$0 {directorio-de-backup} {directorios-de-var}"
ZipTool="gzip";
ttawebmindefs=$TTADIR/defs
cd $TTADIR/var

ALL="docroot ens info password preferences serverconfig serverresources tsp"
if [ "$#" -eq 0 ] ; then
  echo "$USAGE";
  exit 1
fi
if [ -d $1 ] ; then 
   DestDir=/opt/save/tta
else
   echo "Directorio $1 no existe !!!"
   exit 2
fi 
if [ "$2" != "" ] ; then 
 if [ -d $2 ] ; then 
      ALL="$2"
  else
      echo "Directorio $2 no existe !!!"
      exit 2
  fi
fi
ahora=`date +%Y_%m_%d_%H%M%S`
mkdir $DestDir/$ahora
for nomdir in `echo $ALL` 
do
   echo "Copiando Ficheros de \"$nomdir\" ..."
#   find $nomdir -print -depth | cpio -ovO $DestDir/$ahora/$nomdir".cpio"
   tar cvf $DestDir/$ahora/$nomdir".tar" $nomdir
   gzip $DestDir/$ahora/$nomdir".cpio"
done
echo "Copiando Ficheros de \"$ttawebmindefs\" ..."
tar cpvf $DestDir/$ahora/defs".tar"   $ttawebmindefs
gzip $DestDir/$ahora/defs".tar"
   

