#!/bin/sh
# STTA Rev. 1.3 Copyright (c) 2001-2002 Jesús Pérez Lorenzo  --- license GNU GPL 
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=$1
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"
   gzip $DestDir/$ahora/$nomdir".cpio"
done
echo "Copiando Ficheros de \"$ttawebmindefs\" ..."
tar cpvf $DestDir/$ahora/defs".tar"   $ttawebmindefs
gzip $DestDir/$ahora/defs".tar"
   

