#!/bin/sh

FILE="TSM5`date +%b%d_%y@%H`.tar" 
NEW_DIR="`date +%b%d_%y@%H`"
BAK_PATH=//1/control_system/OLD
FULL_FILE_NAME="$BAK_PATH/$NEW_DIR/$FILE"
REMOTE_PATH=//2/BAK/


test -d $BAK_PATH/
if [ $? -ne 0 ]
then
	echo could not find backup directory $BAK_PATH
	exit
fi

echo copying files to $BAK_PATH/$NEW_DIR. Please wait...
# make a new directory to save this baseline of the system
mkdir $BAK_PATH/$NEW_DIR

# save the relevent files
mkdir $BAK_PATH/$NEW_DIR/bin
cp -rc //1/control_system/bin/ $BAK_PATH/$NEW_DIR/bin/
cp $0 $BAK_PATH/$NEW_DIR/
cp //1/etc/config/sysinit.1 $BAK_PATH/$NEW_DIR/
cp //2/etc/config/sysinit.2 $BAK_PATH/$NEW_DIR/
cp //3/etc/config/sysinit.3 $BAK_PATH/$NEW_DIR/
cp //4/etc/config/sysinit.4 $BAK_PATH/$NEW_DIR/
cp //1/etc/config/trap/crt.1 $BAK_PATH/$NEW_DIR/
cp //2/etc/config/trap/crt.2 $BAK_PATH/$NEW_DIR/
cp //3/etc/config/trap/crt.3 $BAK_PATH/$NEW_DIR/
cp //4/etc/config/trap/crt.4 $BAK_PATH/$NEW_DIR/
# touch screen specific files
cp //3/etc/config/absf/absf.3 $BAK_PATH/$NEW_DIR/
cp //3/etc/config/trap/input.3 $BAK_PATH/$NEW_DIR/
cp //4/etc/config/absf/absf.4 $BAK_PATH/$NEW_DIR/
cp //4/etc/config/trap/input.4 $BAK_PATH/$NEW_DIR/

#save the backup to a remote node
test -d $REMOTE_PATH
if [ $? -ne 0 ]
then
	echo  Could not copy backup to local drive : $REMOTE_PATH
	exit
fi

echo secondary save to $REMOTE_PATH/$NEW_DIR. Please wait some more...
mkdir $REMOTE_PATH/$NEW_DIR
cp -rc $BAK_PATH/$NEW_DIR/ $REMOTE_PATH/$NEW_DIR/
echo
echo $0: backup complete
echo 

