#!/bin/bash
#
#daily_archive - Archive designated files & directories
##################################
#
#Gather Current Date
Date=`date +%y%m%d`
#
#set archive file name
FILE=archive$DATE.tar.gz
#
#set configuration and destination file
CONFIG_FILE=/home/user/archive/Files_To_Archive
DESTINATION=/home/user/archive/$FILE
####### main script #############
if [ -f $CONFIG_FILE ];then
echo
else
echo
echo "$CONFIG_FILE does NOT exist"
echo "Backup not completed due to missing configuration file"
echo
exit
fi
FILE_NO=1
exec < $CONFIG_FILE
read FILE_NAME
while [ $? -eq 0 ]
do
if [ -f $FILE_NAME -o -d $FILENAME ];then
FILE_LIST="$FILE_LIST $FILE_NAME"
else
echo
echo "$FILE_NAME does NOT exist"
echo "Obviously,I will not include it in this archive"
echo "It is listed on line $FILE_NO of the config file."
echo "Continuing to build archive list..."
echo
fi
FILE_NO=$[$FILE_NO+1]
read FILE_NAME
done
########################################
# Backup the files and compress archive
tar -czf $DESTINATION $FILE_LIST 2>/dev/null