#!/bin/sh
##############################################################################
# NAME : FileArchive.sh #
##############################################################################
##############################################################################
# #
# SOURCE ENVIRONMENT #
# #
##############################################################################
HOME='/home/data'; export HOME
GENERIC_SCRIPT_DIR=$HOME/application/ftp/scripts; export GENERIC_SCRIPT_DIR
CALLER=FileArchive.sh
current_date=`date +%y%m%d%H%M%S`
FTP_ENV=AX; export FTP_ENV
DATE=`date +%Y%m%d-%H%M`
ARGNUM="$#"
if [ $ARGNUM -ne 1 ]
then
echo "Usage: FileArchive.sh filename"
echo "********************** Guidelines *********************************"
cat ftp.msg
exit 101
fi
FILENAME=$1
echo "`date` - Starting execution of ${CALLER} ${FILENAME}"
if [ ! -f $FILENAME ]
then
echo " $FILENAME doesn't exists"
echo "********************** Guidelines *********************************"
cat ftp.msg
exit 102
fi
#################################################################################
# #
# READ FROM PARAMETER FILE #
# #
#################################################################################
FTPINFO=$FILENAME
source ${FILENAME}
export FTPINFO
#
ARCHIVE_DIR=${AX_SOURCE_DIR}
#echo "Archive Directory"
#echo $ARCHIVE_DIR
#
ARCHIVE_FILE_NAME=${AX_SOURCE_FILE_NAME}
#echo "File Name"
#echo $ARCHIVE_FILE_NAME
#
ARCHIVE_TARGET_DIR=${AX_TARGET_DIR}
#echo "Target Directory"
#echo $ARCHIVE_TARGET_DIR
READY_FILE_NAME_TODELETE=${AX_READY_FILE_NAME_TODELETE}
# - make sure target directory exists
mkdir -p $ARCHIVE_TARGET_DIR
#
#
#echo "Source"
#echo ${ARCHIVE_DIR}/${ARCHIVE_FILE_NAME}
#echo "Target"
#echo ${ARCHIVE_TARGET_DIR}/${DATE}_${ARCHIVE_FILE_NAME}
# Add deltion of .rdy file
if [ -f ${ARCHIVE_DIR}/${READY_FILE_NAME_TODELETE} ]
then
echo "`date` - Deleting ready file: ${ARCHIVE_DIR}/${READY_FILE_NAME_TODELETE}"
rm ${ARCHIVE_DIR}/${READY_FILE_NAME_TODELETE}
fi
if [ -f ${ARCHIVE_DIR}/${ARCHIVE_FILE_NAME} ]
then
NEW_FILENAME=${ARCHIVE_TARGET_DIR}/${DATE}_${ARCHIVE_FILE_NAME}
echo "`date` - Archiving file ${ARCHIVE_DIR}/${ARCHIVE_FILE_NAME} as ${NEW_FILENAME}"
mv ${ARCHIVE_DIR}/${ARCHIVE_FILE_NAME} ${NEW_FILENAME}
echo "`date` - Compressing archived file ${NEW_FILENAME}"
compress ${NEW_FILENAME}
#echo "successful"
fi
echo "`date` - Archive completed."
exit 0;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment