File mttroot/mtt/bin/mtt_backup artifact adf69bcca0 part of check-in 68646ff17d


#!/bin/sh
# Does a backup with date of selected files.


while [ -n "`echo $1 | grep '^-'`" ]; do
case $1 in
    -d)
         format=date;
	 shift
	;;
    -v)
         format=version;
	 shift
	;;
    -h)
         echo "Usage: mtt_backup [-d|-v] [lib|doc]";
	 exit
	;;
    *)
         format=date;
esac
done

#Name of archive
if [ -z "$1" ]; then
    mtt="mtt"
else
    mtt="mtt-$1"
fi

## Create appropriate filename
case $format in
    date)
         filename=`date | awk '{printf("%s_%s%s_%s.tgz\n", mtt, $2,$3,$6)}' mtt=$mtt`;
	 shift
	;;
    version)
         filename=`mtt --version | awk '{printf("%s-%s.tar.gz\n", mtt, $NF)}' mtt=$mtt`;
	 shift
	;;

    *)

esac

echo Backup file $filename



#Files to backup
dir=$mtt

#Check whether archive exists here
if [ -f "$filename" ]; then
    echo File $filename already exists - exiting
    exit    
fi

# Listing files to ignore
echo Finding irrelevant files
find $dir -name '*.*' -print |\
  grep 'dvi$\|ps$\|pdf$\|html$\|info$\|gif$\|log$\|dat$\|MTT_work\|core\|~$' >IGNORE
wc IGNORE | awk '{print "Ignoring", $1, "files"}'

#echo examples >> IGNORE

#Inform user
echo Backing up $dir to $filename

#Tar the files
tar --exclude-from IGNORE --create --gzip --file $filename $dir

#Size info
ls -l $filename
#


MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]